Command
public struct Command
An APDU Command per ISO/IEC 7816-4. Command APDU encoding options:
case 1: |CLA|INS|P1 |P2 | len = 4
case 2s: |CLA|INS|P1 |P2 |LE | len = 5
case 3s: |CLA|INS|P1 |P2 |LC |...BODY...| len = 6..260
case 4s: |CLA|INS|P1 |P2 |LC |...BODY...|LE | len = 7..261
case 2e: |CLA|INS|P1 |P2 |00 |LE1|LE2| len = 7
case 3e: |CLA|INS|P1 |P2 |00 |LC1|LC2|...BODY...| len = 8..65542
case 4e: |CLA|INS|P1 |P2 |00 |LC1|LC2|...BODY...|LE1|LE2| len =10..65544
LE, LE1, LE2 may be 0x00.
LC must not be 0x00 and LC1|LC2 must not be 0x00|0x00
-
Constructs a CommandAPDU from the four header bytes. This is case 1 in ISO 7816, no command body.
Declaration
Swift
public init(cla: UInt8, ins: UInt8, p1: UInt8, p2: UInt8, ne: Int? = nil) throws
Parameters
cla
CLA byte
ins
Instruction byte
p1
P1 byte
p2
P2 byte
ne
Nr of expected bytes in response. Default: 0
-
Constructs a CommandAPDU from the four header bytes, command data, and expected response data length. This is case 4 in ISO 7816, command data and Le present. The value Nc is taken as
dataLength
. If Ne or Nc are zero, the APDU is encoded as case 1, 2, or 3 per ISO 7816.Declaration
Swift
public init(cla: UInt8, ins: UInt8, p1: UInt8, p2: UInt8, data: Data?, ne: Int? = nil) throws
Parameters
cla
CLA byte
ins
Instruction byte
p1
P1 byte
p2
P2 byte
ne
Nr of expected bytes in response. Default: 0
-
APDU body data
Declaration
Swift
public var data: Data? { get }
-
APDU class identifier
Declaration
Swift
public var cla: UInt8 { get }
-
APDU Instruction
Declaration
Swift
public var ins: UInt8 { get }
-
APDU P1
Declaration
Swift
public var p1: UInt8 { get }
-
APDU P2
Declaration
Swift
public var p2: UInt8 { get }
-
APDU Le - Expected length in response body
Declaration
Swift
public var ne: Int? { get }
-
APDU Lc - Command body length
Declaration
Swift
public var nc: Int { get }
-
APDU raw
Declaration
Swift
public var bytes: Data { get }