nz.ac.waikato.modeljunit.examples.gsm
Class GSM11Impl

java.lang.Object
  extended by nz.ac.waikato.modeljunit.examples.gsm.GSM11Impl

public class GSM11Impl
extends java.lang.Object

This is a simple Java implementation of the GSM 11.11 standard. This class pretends to be the SIM card within a mobile phone. That is, tt manages the security and the contents of the various files and directories stored within a typical SIM card.

It handles only a very small subset of the files and directories that a real SIM would, supports only CHV1 security, and has many other limitations and omissions. The goal of this class is to illustrate how we can use model-based testing to test such an implementation, and mutation-testing (see jumble.sourceforge.net) to measure the quality of the generated tests.

For example, executing a sequence of 100,000 randomly-generated test steps from the SimCard model takes only about 1 second, but gives 95.2% code coverage of this class and (a more demanding metric) covers 84% of the 298 mutations generated by Jumble 1.0 for this class. (Done with generate(100000), with setResetProbability(0.01), and with all Jumble mutations turned on, except for mutation of class pool constants).

Author:
marku

Field Summary
static int MF
           
static int PERM_ADM
           
static int PERM_ALWAYS
          Constants for file access permissions
static int PERM_CHV1
           
static int PERM_NEVER
           
 
Constructor Summary
GSM11Impl()
           
 
Method Summary
 byte[] cmd(byte[] apdu)
          This corresponds to sending a command to the SIM.
protected  boolean equalsChv(byte[] chv1, byte[] chv2, int pos2)
          True if chv1[0..7] equals chv2[pos2..pos2+7].
protected  int getByte(byte[] buf, int pos)
          Reads one unsigned bytes from buf[pos].
protected  int getWord(byte[] buf, int pos)
          Reads a two-byte word from buf[pos..pos+1].
protected  void setWord(byte[] buf, int pos, int value)
          Writes a two-byte word into buf[pos..pos+1].
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MF

public static final int MF
See Also:
Constant Field Values

PERM_ALWAYS

public static final int PERM_ALWAYS
Constants for file access permissions

See Also:
Constant Field Values

PERM_CHV1

public static final int PERM_CHV1
See Also:
Constant Field Values

PERM_ADM

public static final int PERM_ADM
See Also:
Constant Field Values

PERM_NEVER

public static final int PERM_NEVER
See Also:
Constant Field Values
Constructor Detail

GSM11Impl

public GSM11Impl()
Method Detail

cmd

public byte[] cmd(byte[] apdu)
This corresponds to sending a command to the SIM. It returns an array of bytes as a response. The caller is expected to know the length of the valid data within the returned array (typically 0), and the position of the two status bytes that follow the data. Note that in this Java implementation, the returned array may be reused, so successive calls will overwrite the contents.

Parameters:
apdu - Bytes 1..4 determine the command and its parameters
Returns:
The response array (ignore the length).

getWord

protected int getWord(byte[] buf,
                      int pos)
Reads a two-byte word from buf[pos..pos+1].


getByte

protected int getByte(byte[] buf,
                      int pos)
Reads one unsigned bytes from buf[pos].


setWord

protected void setWord(byte[] buf,
                       int pos,
                       int value)
Writes a two-byte word into buf[pos..pos+1].


equalsChv

protected boolean equalsChv(byte[] chv1,
                            byte[] chv2,
                            int pos2)
True if chv1[0..7] equals chv2[pos2..pos2+7].



Copyright © 2009 ModelJUnit Project. All Rights Reserved.