|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.javacard.apduio.T1Block
public class T1Block
The T1Block class implemenys a Java representation of the T=1 transport protocol for APDU, as defined in the ISO 7816-3 specifications. T=1 messages have the following block format: +-----+-----+-----+-------------+-----+ | NAD | PCB | LEN | ... INF ... | LRC | +-----+-----+-----+-------------+-----+ The NAD, PCB, LEN and LRC fields are one byte in length each. The INF field, if existent, is LEN bytes in length. There are three types of blocks: - Information blocks (I-blocks) which carry data. - Receive blocks (R-blocks) which convey acknowledgements. - Supervisory block (S-blocks) used for control purposes. The NAD byte is encoded as follows: 7 6 5 4 3 2 1 0 +---+-----------+---+-----------+ | R | S A D | R | D A D | +---+-----------+---+-----------+ where: SAD is "Source Address" DAD is "Destination Address" "R" is "Reserved for Future Use" In our reference case, the terminal is identified by 1, whereas the card is identified by 2. The PCB field for an I-block is encoded as follows: 7 6 5 4 3 2 1 0 +---+-----------+---+-----------+ | 0 | S | M | R F U | +---+-----------+---+-----------+ where: S is the sequence bit N(S) M is the chanining bit, where "1" means chained block, "0" means last block in chain. The PCB field for an R-block is encoded as follows: 7 6 5 4 3 2 1 0 +---+-----------+---+-----------+ | 1 0 | E r r o r C o d e | +---+-----------+---+-----------+ where: Error code of 0-N(R)-0000 means error free acknowledgement. Error code of 0-N(R)-0001 means character parity error. Error code of 0-N(R)-0010 means other errors. The PCB field for an S-block is encoded as follows: 7 6 5 4 3 2 1 0 +---+-----------+---+-----------+ | 1 1 | O p C o d e | +---+-----------+---+-----------+ where: 000000 means RESYNC. 000001 means IFS request and 100001 means IFS response. 000010 means ABORT request and 100010 means ABORT response. 000011 means WTX request and 100011 means WTX response. The LEN field conveys the information length. '00' means INF field not present; '01' to 'FE' is the length of the INF field; 'FF' is RFU. INF carries information. When present, INF in an I-block carries application information. INF is absent from R-blocks; and INF conveys control information on S-blocks performing a IFS or WTX commands, absent otherwise. LRC is the longitudinal redundancy check for the entire block. When computed across all fields from NAD to LRC inclusive by xor-ing all bytes, it shall yield '00' as a result.
Field Summary | |
---|---|
static byte |
NULL_ADDRESS
Null adrress value |
static byte |
S_ABORT_REQ
S_ABORT_REQ = 11000010 |
static byte |
S_ABORT_RES
S_ABORT_REQ = 11100010 |
static byte |
S_IFS_REQ
S_IFS_REQ = 11000001 |
static byte |
S_IFS_RES
S_IFS_REQ = 11100001 |
static byte |
S_RESYNC_REQ
S_RESYNC_REQ = 11000000 |
static byte |
S_RESYNC_RES
S_RESYNC_REQ = 11100000 |
static byte |
S_WTX_REQ
S_WTX_REQ = 11000011 |
static byte |
S_WTX_RES
S_WTX_REQ = 11100011 |
Constructor Summary | |
---|---|
T1Block()
Main constructor. |
Method Summary | |
---|---|
boolean |
checkBlock()
Verifies the consistency of this T=1 Block by calculating the LRC. |
static boolean |
checkBlock(T1Block theBlock)
Verifies the consistency of the T=1 Block by calculating the LRC. |
byte |
getBlockType()
Returns the T=1 Block type. |
byte[] |
getINFBytes()
Returns the T=1 Block INF bytes. |
int |
getIntINF()
Returns the T=1 Block INF first byte. |
int |
getLEN()
Returns the T=1 Block LEN field |
byte |
getSBlockType()
Returns the control parameter type for this S-Block. |
boolean |
getSequence()
Returns the sequence flag for this I-Block or R-Block. |
boolean |
isLastBlock()
Returns the last block flag for this I-Block. |
static T1Block |
readBlock(byte[] buffer,
int offset,
int len)
Reads T=1 block information from the specified buffer and reconstructs a T1Block object from it. |
void |
readBlockInstance(byte[] buffer,
int offset,
int len)
Reads T=1 block information from the specified buffer and reconstructs it in this block. |
void |
setIBlock(byte src,
byte dst,
boolean seqFlag,
boolean chainingFlag,
byte[] infoData,
int infoSize)
Sets this T1Block object as an I-Block with the parameters specified. |
void |
setIBlock(byte src,
byte dst,
boolean seqFlag,
boolean chainingFlag,
byte[] infoData,
int infoOffset,
int infoSize)
Sets this T1Block object as an I-Block with the parameters specified. |
void |
setRBlock(byte src,
byte dst,
boolean seqFlag)
Sets this T1Block object as an R-Block with the parameters specified. |
void |
setSBlock(byte src,
byte dst,
int ctrlType,
int infData)
Sets this T1Block object as an S-Block with the parameters specified. |
byte[] |
toByteArray()
Transfers the current T=1 Block into a byte array representation. |
java.lang.String |
toString()
Returns a string representation of this I-Block object for debugging and tracing purposes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final byte NULL_ADDRESS
public static final byte S_RESYNC_REQ
public static final byte S_RESYNC_RES
public static final byte S_IFS_REQ
public static final byte S_IFS_RES
public static final byte S_ABORT_REQ
public static final byte S_ABORT_RES
public static final byte S_WTX_REQ
public static final byte S_WTX_RES
Constructor Detail |
---|
public T1Block()
Method Detail |
---|
public void setIBlock(byte src, byte dst, boolean seqFlag, boolean chainingFlag, byte[] infoData, int infoSize) throws T1Exception
src
- Source address.dst
- Destination address.seqFlag
- Sequence flag.chainingFlag
- chaining flag.infoData
- Byte array containing I-Block data.infoSize
- Size in bytes of data to copy.
T1Exception
- if a T=1 protocol inconsistency occurs.public void setIBlock(byte src, byte dst, boolean seqFlag, boolean chainingFlag, byte[] infoData, int infoOffset, int infoSize) throws T1Exception
src
- Source address.dst
- Destination address.seqFlag
- Sequence flag.chainingFlag
- chaining flag.infoData
- Byte array containing I-Block data.infoSize
- Size in bytes of data to copy.infoOffset
- Offset of data to copy from byte array.
T1Exception
- if a T=1 protocol inconsistency occurs.public void setRBlock(byte src, byte dst, boolean seqFlag) throws T1Exception
src
- Source address.dst
- Destination address.seqFlag
- Sequence flag.
T1Exception
- if a T=1 protocol inconsistency occurs.public void setSBlock(byte src, byte dst, int ctrlType, int infData) throws T1Exception
src
- Source address.dst
- Destination address.ctrlType
- S-Block control parameter.infData
- Optional INF field data for S-Block, conly LSB is considered.
T1Exception
- if a T=1 protocol inconsistency occurs.public byte[] toByteArray()
public static T1Block readBlock(byte[] buffer, int offset, int len) throws T1Exception
buffer
- Buffer containing block information.offset
- Offset inside the buffer containing block information.len
- Length inside the buffer with the block information.
T1Exception
- if an error in the data is found.public void readBlockInstance(byte[] buffer, int offset, int len) throws T1Exception
buffer
- Buffer containing block information.offset
- Offset inside the buffer containing block information.len
- Length inside the buffer with the block information.
T1Exception
- if an error in the data is found.public boolean checkBlock()
public static boolean checkBlock(T1Block theBlock)
theBlock
- Block to check.
public byte getBlockType()
public byte[] getINFBytes()
public int getIntINF()
public int getLEN()
public boolean isLastBlock()
public boolean getSequence()
public byte getSBlockType()
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |