以下の内容はhttps://smartcardguy.hatenablog.jp/entry/2018/08/11/153334より取得しました。
定義
- 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を返す。
- Transport LayerにはTPDUプロトコルがISO 7816-3で定義。簡単に以下の2つのパターンが存在するということだけ抑えておこう。
- T=0 protocol : byte-oriented
- T=1 protocol : block-oriented
Command APDU

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

body (Optional)
trailer (Mandatory)
- SW1 : Status word 1
- SW2 : Status word 2. SW1, SW2と合わせてステータスを表す。例)0x9000 : Success
C-APDU / R-APDUパターン (4 cases)

Case 1 - No command data, no reponse data
- No data are transferred to or from the card.
- C-APDU contains only the header.
- R-APDU contains only the trailer status word.
Case 2 - No command data, send reponse data
- No data are transferred to the card, but data are returned from the card.
- The body of the C-APDU contains one byte - the Le field, which specifies the number of data bytes in the corresponding R-APDU.
Case 3 - Receive command data, no reponse data
- Data are transferred to the card, but no data are returned from the card as a result of processing the command.
- The body of the C-APDU includes the Lc field and the data field. The Lc byte specifies the length of the data field.
- The R-APDU contains only the trailer status word.
Case 4 - Receive command data, send reponse data
- Data are transferred to the card, and data are returned from the card as a result of processing the command.
- The body of the C-APDU includes the Lc field, the data field, and the Le field.
- The R-APDU contains both the data and the trailer status word.
Status Word
Link
cardwerk.com
以上の内容はhttps://smartcardguy.hatenablog.jp/entry/2018/08/11/153334より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます
不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14