Interface ApduInterpreterSpi


public interface ApduInterpreterSpi
Interface defining an APDU interpreter for processing commands sent to storage cards.

Its implementation is provided by ApduInterpreterFactorySpi.

Upon calling processApdu, implementations determine how to invoke the appropriate methods of CommandProcessorApi based on the APDU class byte (CLA) and instruction (INS).

APDU Processing Strategy

The interpreter follows a two-pathway processing model:

Error Handling Strategy

This interface follows a trust-based validation approach:

  • Validation is performed upstream by the card extension that generates the APDUs. Since this extension is part of the same ecosystem, its output is trusted.
  • CommandProcessorApi does not perform parameter validation and trusts the incoming data to be correct.
  • Exceptions propagate to the caller unless they represent normal protocol conditions (e.g., authentication failure, unsupported instruction).
  • Status words are returned only for protocol-level conditions, not validation errors.

Status Words Usage

Implementations return ISO 7816-4 / PC/SC compliant status words for the following conditions:

Status Words returned by implementations
Status WordCodeUsage
Success0x9000Successful execution
Security status not satisfied0x6982Authentication failed (PC/SC compliant)
INS not supported0x6D00Unknown instruction code

Exception Propagation

The following error conditions may result in exceptions:

  • Hardware/communication errors (card not responding, transmission failure) - thrown by CommandProcessorApi
  • Protocol-level errors that cannot be represented by status words - may be thrown by implementations

Note: Parameter validation (P1/P2 values, data lengths, key numbers, etc.) is the responsibility of the card extension generating the APDUs, not this interface or its implementations.

PC/SC Compliance

Storage card commands (CLA=0xFF) follow the PC/SC v2.01.09 specification:

  • LOAD KEY: FF 82 [P1] [P2] 06 [6-byte key]
  • GENERAL AUTHENTICATE: FF 86 00 00 05 [version][addr-MSB][addr-LSB][key-type][key-num]
  • GET DATA (UID): FF CA 00 00 [Le]
  • READ BINARY: FF B0 [P1] [P2] [Le]
  • UPDATE BINARY: FF D6 [P1] [P2] [Lc] [data]
Since:
1.0.0
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    byte[]
    processApdu(byte[] apdu)
    Processes an APDU command by invoking the corresponding methods of CommandProcessorApi based on the card type.
    void
    Sets the command processor responsible for handling APDU execution.