1 Scope
该文档规定UICC和终端的接口。
该文档规定:
-UICC的物理特性需求;
-UICC和终端之间交换APDU的电气接口,基于ISO/IEC 7816-3;
-该接口的初始通信建立和传输协议;
-作为UICC APDU接口逻辑结构基础的模型;
-UICC APDU接口的通信命令和程序;
-UICC APDU接口的独立于应用程序的文件和协议。
UICC和终端之间的管理程序、初始卡管理和可选通信接口不在本文件范围内。
2 References
3 Definition of terms, symbols, abbreviations and coding conventions
4 Physical characteristics
5 Electrical specifications of the UICC - Terminal interface
6 Initial communication establishment procedures
6.3 Answer To Reset content
6.3.0 Introduction
The ATR is the first string of bytes sent from the UICC to the terminal after a reset has been performed. The ATR is defined in ISO/IEC 7816-3 [11].
在执行复位操作后,ATR是从UICC发送给终端的第一个字节串,ISO/IEC 7816-3 [12]定义了ATR。
7 Transmission protocols
8 Application and file structure
9 Security features
10 Structure of commands and responses
10.1 Command APDU
10.1.0 Structure and case
Code | Length | Description | Grouping | 备注 |
---|---|---|---|---|
CLA | 1 | Class of instruction | Header | |
INS | 1 | Instruction code | Header | |
P1 | 1 | Instruction parameter 1 | Header | |
P2 | 1 | Instruction parameter 2 | Header | |
Lc | 0 or 1 | Number of bytes in the command data field | Body | |
Data | Lc | Command data string | Body | |
Le | 0 or 1 | Maximum number of data bytes expected in response of the command | Body |
四种结构:
Case | Structure | 备注 |
---|---|---|
1 | CLA INS P1 P2 | |
2 | CLA INS P1 P2 Le | |
3 | CLA INS P1 P2 Lc Data | |
4 | CLA INS P1 P2 Lc Data Le |
10.2 Response APDU
10.2.0 Structure
Case | Length | Description | 备注 |
---|---|---|---|
Data | Lr | Response data string | |
SW1 | 1 | Status byte 1 | |
SW2 | 1 | Status byte 2 |
11 Commands
CLA | INS | P1 | P2 | Lc | Data | Le | Output Len | Data | SW1SW2 | 备注 | |
---|---|---|---|---|---|---|---|---|---|---|---|
SELECT | M | M | M | M | O | M | O | M* | M | M | 一般有Lc;没有Le |
STATUS | M | M | M | M | N | N | O | O* | O | M | 一般有Le;Output可能有,可能没有 |
READ BINARY | M | M | M | M | N | N | M | M* | M | M | |
UPDATE BINARY | M | M | M | M | M | M | N | N | N | M | 没有Output |
READ RECORD | M | M | M | M | N | N | M | M* | M | M | |
UPDATE RECORD | M | M | M | M | M | M | N | N | N | M | 没有Output |
INCREASE | M | M | M | M | M | M | M | M* | M | M | |
VERIFY PIN | M | M | M | M | O | O | N | N | N | M | 没有Output |
CHANGE PIN | M | M | M | M | M | M | N | N | N | M | 没有Output |
DISABLE PIN | M | M | M | M | M | M | N | N | N | M | 没有Output |
ENABLE PIN | M | M | M | M | M | M | N | N | N | M | 没有Output |
UNBLOCK PIN | M | M | M | M | O | O | N | N | N | M | 没有Output |
DEACTIVATE FILE | M | M | M | M | M | M | N | N | N | M | 没有Output |
ACTIVATE FILE | M | M | M | M | M | M | N | N | N | M | 没有Output |
AUTHENTICATE | M | M | M | M | O | O | O | M* | M | M | |
MANAGE CHANNEL | M | M | M | M | N | N | O | O* | O | O | Output可选 |
GET CHALLENGE | M | M | M | M | N | N | M | M* | M | M | Output为1个字节 |
TERMINAL CAPABILITY | M | M | M | M | M | M | N | N | N | M | 没有Output |
12 Transmission oriented commands
13 Application independent files
13.1 EFDIR
image.png13.2 EFICCID (ICC Identification)
image.pngSIM卡ICCID存储位置,以及内容存储方式:
ICCID文件:98-68-10-61-58-01-85-49-96-16
ICCID内容:89-86-01-16-85-10-58-94-69-61
自动解析脚本:
https://c.runoob.com/compile/9/
import re
class TestProgram:
def check_input_raw_data(self, str_data):
str_data_check = re.search('^[0-9A-Fa-f]+$', str_data)
if str_data_check:
return True
else:
return False
def get_input_raw_data(self, test_str):
str_data = re.sub('\s','',test_str).replace('-', '')
if self.check_input_raw_data(str_data):
pattern = re.compile('.{2}')
str_list = pattern.findall(str_data)
str_list_reverse = []
for str_item in str_list:
str_list_reverse.append(str_item[::-1])
str_reverse = '-'.join(str_list_reverse)
return str_reverse
if __name__ == '__main__':
test_program = TestProgram()
iccid = test_program.get_input_raw_data('98-68-10-61-58-01-85-49-96-16')
print(iccid)
参考资料:
ITU上IIN的描述:
https://www.itu.int/en/ITU-T/inr/forms/Pages/iin.aspx
该链接下面有一些规范的文档:
https://www.itu.int/pub/T-SP
然后进入页面的Lists Annexed,也就是如下链接:
https://www.itu.int/en/publications/ITU-T/Pages/publications.aspx?parent=T-SP&view=T-SP1
E.118就是IIN List:
https://www.itu.int/dms_pub/itu-t/opb/sp/T-SP-E.118-2018-PDF-E.pdf
https://www.ansi.org/other_services/registration_programs/IIN?menuid=10
https://baike.baidu.com/item/iccid
https://blog.csdn.net/teavamc/article/details/78607803
13.3 EFPL (Preferred Languages)
image.pngAcces | Condition | 含义 |
---|---|---|
READ | ALW | 读权限为Always,就是该文件对ME一直可读 |
UPDATE | PIN | 写权限为PIN,就是ME需要PIN码,才可写该文件;当然,若用户关闭了PIN码,则可直接操作该文件 |
DEACTIVATE | ADM | ADM权限,就是只能由该文件的生成者card issue来DEACTIVATE |
ACTIVATE | ADM | ADM权限,就是只能由该文件的生成者card issue来ACTIVATE |
该文件遵从3GPP TS 23.038规范的SMS default 7-bit coded alphabet编码,获取到的两字节编码遵从ISO639-1规范:
https://www.iso.org/iso-639-language-codes.html
https://id.loc.gov/vocabulary/iso639-1.html
https://www.loc.gov/standards/iso639-2/php/code_list.php
比如SIM卡数据为:6B 6B 64 65
则表明1st language code为kk(Kazakh),2nd language code为de(German)。
14 Application independent protocol
15 Support of APDU-based UICC applications over USB
Annex A (normative): UCS2 coding of Alpha fields for files residing on the UICC
81编码
第一个字节为0x81,即表示81编码。
第二个字节表示字符的个数。
第三个字节是一个16位数字基准的15到8比特位,也就是说这个数字基准的bit16和bit7到bit1为0。
第四个字节如果bit8为0,则bit7到bit1表示一个GSM Default Alphabet character,也就是一个7bit Default编码字符(可查看3G TS 23.038 6.2.1 GSM 7 bit Default Alphabet);如果bit8为1,则bit7到bit1表示一个偏移值,该偏移值与上述的16位数字基准可构成一个UCS2编码。
之后的有效字节和第四个字节的定义一致。
image.png
第二个字节为0x05,表示之后的字符为5个;
第三个字节为0x13,生成数字基准,二进制表示为0000 1001 1000 0000,即是0x0910;
网友评论