OpenCard  
 
OCF, the OpenCard Framework is a standard Java framework for working with Smart Cards.  
 

opencard.tests.terminal
Interface CommandCodes

All Known Implementing Classes:
BullCodes, ISOCodes, MFC35Codes, MFC41Codes

public abstract interface CommandCodes

Provides parameterization of APDU Command Codes. The majority of the methods is used to get the CLAss and INStruction bytes for specific commands.
This interface needs implementations for specific cards (e.g. MFC4.0) or for card standards (e.g. ISO compliant cards)

Version:
$Id: CommandCodes.java,v 1.1 1999/12/03 09:31:36 damke Exp $

Field Summary
static short MASTER_FILE
          The master file ID (conforms to the ISO standard).
 
Method Summary
 byte getAppendRecordByte()
          The append record instruction.
 byte getAskRandomByte()
          The ask random/get challenge instruction.
 int getBlockSize()
          The maximum block size for data transfers.
 byte getClassByte()
          The CLAss byte for non-ISO commands.
 byte getCreateFileByte()
          The create file instruction.
 byte getDecreaseByte()
          The decrease instruction.
 byte getDeleteFileByte()
          The delete file instruction.
 byte getEraseBinaryByte()
          the erase binary instruction
 byte getExternalAuthByte()
          The external authenticate instruction.
 byte getGenerateKeyByte()
          the generate key instruction
 byte getGetResponseByte()
          the get response instruction
 byte getGiveRandomByte()
          The give random instruction
 byte getIncreaseByte()
          The increase instruction.
 byte getInvalidateByte()
          The invalidate instruction.
 byte getReadBinaryByte()
          The read binary instruction.
 byte getReadRecordByte()
          The read record instruction.
 byte getRehabilitateByte()
          The rehabilitate instruction.
 byte getSearchByte()
          the Search blank word instruction
 byte getSelectByte()
          The select instruction.
 byte getUpdateBinaryByte()
          The update binary instruction.
 byte getUpdateRecordByte()
          The update record instruction.
 byte getVerifyCHVByte()
          The verify CHV instruction.
 boolean needsZeroLc()
          Whether a command data length of zero is explicit.
 boolean needsZeroLe()
          Whether an expected response data length of zero is explicit.
 boolean needsZeroLe(boolean info)
          Whether an expected explicit zero Le is specified for select.
 java.lang.String toString()
          A usual toString method
 

Field Detail

MASTER_FILE

public static final short MASTER_FILE
The master file ID (conforms to the ISO standard).
Method Detail

getBlockSize

public int getBlockSize()
The maximum block size for data transfers.
Returns:
the block size for splitting read and write commands

needsZeroLc

public boolean needsZeroLc()
Whether a command data length of zero is explicit. The commands to invalidate or rehabilitate a file on the smartcard neither provide nor request data. With the MFC 4.1, the command APDU will consist of only 4 bytes, while previous MFC cards require an explicit Lc byte with value 0.
Returns:
true iff a zero Lc byte has to be part of the APDU

needsZeroLe

public boolean needsZeroLe()
Whether an expected response data length of zero is explicit. The commands to increase or decrease the value of a record in a structured file return the contents of the record and the amount that was sent with the command. For MFC 3.5 and 4.0, no expected length byte (Le) has to be provided. With the MFC 4.1, this byte is required but can be set to 0, so the card will send as many bytes as there are to send.
This method is also used to build the command APDU for reading a record. In the case of the MFC 4.1, the expected length must be set to zero to avoid trouble with secure messaging.
Finally, there is the select command. The MFC 3.5 and 4.0 do not allow an Le byte for select, the MFC 4.1 does. The german GeldKarte even requires the Le byte, at least in some cases. See also needsZeroLe(boolean).
This method could have been named isZeroLeSufficient or something like that, but since it corresponds to needsZeroLc, a corresponding name has been chosen, too.
Returns:
true iff Le has to be specified for increase or decrease
See Also:
needsZeroLc(), needsZeroLe(boolean)

needsZeroLe

public boolean needsZeroLe(boolean info)
Whether an expected explicit zero Le is specified for select. With the german GeldKarte, a zero Le must be given only if some bytes are expected at all. This method deals with this special case.
Parameters:
info - whether a response is expected at all
Returns:
true if a zero Le has to be appended, false otherwise
See Also:
needsZeroLe()

getClassByte

public byte getClassByte()
The CLAss byte for non-ISO commands.
Returns:
the CLAss of non-ISO standard INStructions

getSelectByte

public byte getSelectByte()
The select instruction.

getReadBinaryByte

public byte getReadBinaryByte()
The read binary instruction.

getReadRecordByte

public byte getReadRecordByte()
The read record instruction.

getUpdateBinaryByte

public byte getUpdateBinaryByte()
The update binary instruction.

getUpdateRecordByte

public byte getUpdateRecordByte()
The update record instruction.

getAppendRecordByte

public byte getAppendRecordByte()
The append record instruction. It is not supported until MFC 4.1, but it has to be in the interface.

getIncreaseByte

public byte getIncreaseByte()
The increase instruction.

getDecreaseByte

public byte getDecreaseByte()
The decrease instruction.

getCreateFileByte

public byte getCreateFileByte()
The create file instruction.

getDeleteFileByte

public byte getDeleteFileByte()
The delete file instruction.

getInvalidateByte

public byte getInvalidateByte()
The invalidate instruction.

getRehabilitateByte

public byte getRehabilitateByte()
The rehabilitate instruction.

getVerifyCHVByte

public byte getVerifyCHVByte()
The verify CHV instruction.

getExternalAuthByte

public byte getExternalAuthByte()
The external authenticate instruction.

getAskRandomByte

public byte getAskRandomByte()
The ask random/get challenge instruction.

getGiveRandomByte

public byte getGiveRandomByte()
The give random instruction

getEraseBinaryByte

public byte getEraseBinaryByte()
the erase binary instruction

getGetResponseByte

public byte getGetResponseByte()
the get response instruction

getGenerateKeyByte

public byte getGenerateKeyByte()
the generate key instruction

getSearchByte

public byte getSearchByte()
the Search blank word instruction

toString

public java.lang.String toString()
A usual toString method
Overrides:
toString in class java.lang.Object