ResponseAPDU

public final class ResponseAPDU

A response APDU as defined in ISO/IEC 7816-4. It consists of a conditional body and a two byte trailer. This class does not attempt to verify that the APDU encodes a semantically valid response.

Instances of this class are immutable. Where data is passed in or out via byte arrays, defensive cloning is performed.

See also

CommandAPDU

Author

Andreas Sterbenz

Author

JSR 268 Expert Group

Author

Godfrey Chung

Version

1.0

Date

6 Nov 2017

  • nr

    Returns the number of data bytes in the response body (Nr) or 0 if this APDU has no body. This call is equivalent to data.count.

    Declaration

    Swift

    public var nr: Int { get }
  • Returns a copy of the data bytes in the response body. If this APDU as no body, this method returns a byte array with a length of zero.

    Declaration

    Swift

    public var data: [UInt8] { get }
  • sw1

    Returns the value of the status byte SW1 as a value between 0 and 255.

    Declaration

    Swift

    public var sw1: UInt8 { get }
  • sw2

    Returns the value of the status byte SW2 as a value between 0 and 255.

    Declaration

    Swift

    public var sw2: UInt8 { get }
  • sw

    Returns the value of the status bytes SW1 and SW2 as a single status word SW. It is defined as UInt16(sw1) << 8 | UInt16(sw2).

    Declaration

    Swift

    public var sw: UInt16 { get }
  • Returns a copy of the bytes in this APDU.

    Declaration

    Swift

    public var bytes: [UInt8] { get }
  • Constructs a ResponseAPDU from a byte array containing the complete APDU contents (conditional body and trailed).

    Note that the byte array is cloned to protect against subsequent modification.

    Throws

    CardError.illegalArgument if apdu.length is less than 2

    Declaration

    Swift

    public init(apdu: [UInt8]) throws

    Parameters

    apdu

    the complete response APDU