GET STATUSコマンドで確認してみましょう
SIMツールキット用サンプルアプレットのビルド、sysmoUSIM-SJS1 4FFへのロードおよびインストールを実行することができました。次は、インストールされたアプレットの存在について、GET STATUSコマンドを使ってあらためて確認してみましょう。
cheerio-the-bear.hatenablog.com
カードにロードされているモジュールの確認
sysmoUSIM-SJS1 4FF専用に用意されているpythonスクリプトのヘルプには出力されませんが、--list-applets オプションが実装されていることに気付きました。GET STATUSコマンド(F2)を送信してくれるようです。
if args.list_applets: (data, status) = ac.send_wrapped_apdu_ram('80f21000024f0000c0000000') while status == '6310': (partData, status) = ac.send_wrapped_apdu_ram('80f21001024f0000c0000000') data = data + partData while len(data) > 0: aidlen = int(data[0:2],16) * 2 aid = data[2:aidlen + 2] state = data[aidlen + 2:aidlen + 4] privs = data[aidlen + 4:aidlen + 6] num_instances = int(data[aidlen + 6:aidlen + 8], 16) print('AID: ' + aid + ', State: ' + state + ', Privs: ' + privs) data = data[aidlen + 8:] while num_instances > 0: aidlen = int(data[0:2],16) * 2 aid = data[2:aidlen + 2] print("\tInstance AID: " + aid) data = data[aidlen + 2:] num_instances = num_instances - 1
GET STATUSコマンド(F2)にGET RESPONSEコマンド(C0)を付けて送信していますが、このP2パラメータはGlobal Platform Card Specification v2.3ではDeprecatedです。v2.2には載っていますが、レスポンスデータのフォーマットが異なります。
CLA | 80 |
---|---|
INS | F2 (GET STATUS) |
P1 | 10 (Executable Load Files and Executable Modules) |
P2 | 00 (Deprecated!) |
Lc | 02 |
Data | 4F00 |
DataフィールドはSearch Criteriaですが、指定なしですね。
The GET STATUS command message data field shall contain at least one TLV coded search qualifier: the AID (tag '4F'). It shall be possible to search for all the occurrences that match the selection criteria according to the reference control parameter P1 using a search criteria of '4F' '00'.
GET STATUSコマンドを実行してみる
実際に実行してみると、こうなります。ENVELOPE (SMS-PP DOWNLOAD)に詰められて何度もコマンドが送信されているのは、カードからの応答にSW 6310 (More data available)が何度も登場しているからですね。
$ python shadysim.py --pcsc --list-applets --kic 9A665E9CDA096DAE9C04894785EB0B18 --kid 1A8DD88431450CAF8D3719F6380F0A18 ... C-APDU : a0c2000046d144820283818B3e400881556677887ff6001129120000042d027000002815060115150000001bb804aa02e7b97bcbf090d7a5670d88f0cf47344826694cf1c99d6b5bbfdbeb R-APDU + SW : 9f35 C-APDU : a0c0000035 R-APDU + SW : 02710000300a000000000000000000000263100da0000000090001ffffffff890001000210a0000000090001ffffffff89000000009000 C-APDU : a0c2000046d144820283818B3e400881556677887ff6001129120000042d0270000028150601151500000037a4d45e5a44929ed737065b0ce5f3c62e2ae379528083b96bea4c96ca00aeb6 R-APDU + SW : 9f23 C-APDU : a0c0000023 R-APDU + SW : 027100001e0a000000000000000000000263100fa0000000090001ffffffff89b000109000 C-APDU : a0c2000046d144820283818B3e400881556677887ff6001129120000042d0270000028150601151500000037a4d45e5a44929ed737065b0ce5f3c62e2ae379528083b96bea4c96ca00aeb6 R-APDU + SW : 9f35 C-APDU : a0c0000035 R-APDU + SW : 02710000300a000000000000000000000263100da0000000871002ff49ffff890001000110a0000000871002ff49ffff89040b00009000 C-APDU : a0c2000046d144820283818B3e400881556677887ff6001129120000042d0270000028150601151500000037a4d45e5a44929ed737065b0ce5f3c62e2ae379528083b96bea4c96ca00aeb6 R-APDU + SW : 9f32 C-APDU : a0c0000032 R-APDU + SW : 027100002d0a000000000000000000000263100aff434e5258104004020301000110ff434e525810400402030000000000009000 C-APDU : a0c2000046d144820283818B3e400881556677887ff6001129120000042d0270000028150601151500000037a4d45e5a44929ed737065b0ce5f3c62e2ae379528083b96bea4c96ca00aeb6 R-APDU + SW : 9f27 C-APDU : a0c0000027 R-APDU + SW : 02710000220a0000000000000000000002900007d07002ca44900101000108d07002ca449001019000 AID: a0000000090001ffffffff8900, State: 01, Privs: 00 Instance AID: a0000000090001ffffffff8900000000 Instance AID: a0000000090001ffffffff89b00010 AID: a0000000871002ff49ffff8900, State: 01, Privs: 00 Instance AID: a0000000871002ff49ffff89040b0000 AID: ff434e52581040040203, State: 01, Privs: 00 Instance AID: ff434e52581040040203000000000000 AID: d07002ca449001, State: 01, Privs: 00 Instance AID: d07002ca44900101
SIMツールキット用アプレットをロードしたときに指定したパッケージのAID "D07002CA449001" と、アプレット/モジュールのAID "D07002CA44900101"がレスポンスの末尾に見えています。..ですよね、このスクリプトでは "Instance AID" と表現されていますけど。
Name | Length | Presence |
---|---|---|
Length of Executable Load File AID | 1 | Mandatory |
Executable Load File AID | 5-16 | Mandatory |
Executable Load File Life Cycle State | 1 | Mandatory |
Privileges | 1 | Mandatory |
Number of Executable Modules | 1 | Conditional |
Length of Executable Module AID | 1 | Conditional |
Executable Module AID | 5-16 | Conditional |
... | ... | ... |
Length of Executable Module AID | 1 | Conditional |
Executable Module AID | 5-16 | Conditional |
うまくロードできているかどうか、今後はこのコマンドでも確認するようにします。