Smart Card Guy

Smart Card, Java Card, PCI DSS, IoT Device Security

APDU (Smart card application protocol data unit)

定義

  • ISO 7816-4で定義したSmart Card向け通信プロトコル
  • CAD(Card Acceptance Device - Reader、TerminalのようなHost)側からCardへ送るCommand APDU(C-APDU)と、Card側からCADへ送るResponse APDU(R-APDU)で構成。
  • Smart Card - CADの構成で、Smart Cardはいつもpassive(Slave)ロール。CAD側からC-APDUが来るのを待ってそれに対し、R-APDUを返す。

Command APDU

f:id:blog-guy:20180630102534p:plain

header (Mandatory)
  • CLA : Class of Instruction
  • INS : Instruction Code
  • P1 : Parameter 1
  • P2 : Parameter 2
body (Optional)
  • Lc : length of data field
  • Data Field : Cardへ送るデータ
  • Le : Maximum of bytes expected in the data field of the response to the command

Response APDU

f:id:blog-guy:20180630102552p:plain

body (Optional)
  • Data Field
trailer (Mandatory)
  • SW1 : Status word 1
  • SW2 : Status word 2. SW1, SW2と合わせてステータスを表す。例)0x9000 : Success

Link