SIM卡相关知识介绍

SIM卡简介

SIM卡(Subscriber Identity Module)是一种用于存储移动电话用户身份信息的智能卡,它是移动通信系统中的重要组成部分。SIM卡主要由微处理器CPU、程序存储器ROM、工作存储器RAM、数据存储器EEPROM和串行通信单元组成。SIM卡中微处理器CPU是整个系统的核心部件,主要完成数据处理、指令接收和任务分配等操作;程序存储器ROM主要用于存放系统程序,用户不可更改;工作存储器RAM主要用于存放正在运行的程序,如通话记录、短信等;数据存储器EEPROM主要用于存储用户信息、电话号码等重要数据;串行通信单元主要负责与其他设备进行通信。

SIM卡的主要作用是识别用户身份,使用户能够接入移动通信网络并使用移动通信服务。当用户插入SIM卡时,移动设备会读取卡内的信息,然后将用户身份信息发送给移动通信网络,以便进行身份验证和授权。此外,SIM卡还可以存储一些个人信息和设置,如语音信箱号码、短信中心号码、网络设置等。

SIM卡根据尺寸和功能的不同,可以分为以下几种类型:

  1. 标准SIM卡:也称为大SIM卡,尺寸为25mm x 15mm x 0.76mm,是最早的SIM卡类型,现在已经逐渐被微型SIM卡和纳米SIM卡所取代。

  2. Micro-SIM卡:也称为小SIM卡或第二代SIM卡,尺寸为15mm x 12mm x 0.76mm,比标准SIM卡小一半,常用于早期的智能手机和平板电脑。

  3. Nano-SIM卡:也称为第三代SIM卡,尺寸为12.3mm x 8.8mm x 0.67mm,比微型SIM卡小一半,是目前主流的SIM卡类型,用于大多数智能手机和平板电脑。

  4. eSIM卡:eSIM卡(Embedded SIM)是一种嵌入式SIM卡,也称为嵌入式晶片SIM卡。与传统的实体SIM卡不同,eSIM卡是一种内置在设备中的芯片,可以通过软件进行配置和激活,而不需要物理插入或更换卡片。

  5. 虚拟SIM卡:虚拟SIM卡是一种基于云技术的新型SIM卡,它不需要实体卡片,而是通过软件模拟实现了SIM卡的功能。用户可以通过手机应用程序或网站来管理虚拟SIM卡,包括激活、充值、更换号码等操作。虚拟SIM卡也被叫做软卡或云卡,remote SIM就是虚拟SIM卡的一种。

SIM卡卡操作

在SIM卡的触点连接到接口设备的触点之前,电路应保持不活动状态。接口设备与SIM卡之间的交互,应通过以下操作顺序进行。
1)接口设备应对SIM卡施加一个类(Class)的操作条件,即激活、冷复位和可能的一个或多个热复位。如果SIM卡支持该类(Class),则会复位应答。接口设备以一个完整有效的复位应答和一个类(Class)操作条件结束。接口设备应能重复整个操作。
2)为了交换信息,SIM卡和接口设备应就传输协议和传输参数值需要达成一致。即以接口设备为主机的字符半双工传输。当卡不需要传输时(例如,在处理完一个命令响应对之后,在启动下一个命令响应对之前),如果卡支持时钟停止,接口设备可以停止时钟信号。
3)接口设备应该支持执行去激活操作。应在SIM卡的触点与接口设备的触点机械断开之前完成去激活操作。

1、“激活”操作

为了启动与机械连接的SIM卡的交互,接口设备应该按照A、B或C类的顺序激活SIM卡
1) RST 需要被拉低
2) VCC需要上电
3) 需要将接口设备的I/O设置成接收模式,在激活期间,接口设备忽略I/O上的状态
4) CLK需要被提供时钟信号
Note 1 电源上电、将I/O设置成接收模式、CLK被提供时钟信号,三者之间的延时没有被定义。
Note 2 接口设备允许在短路的时候执行去激活操作
如下图,在Ta之前是“激活”操作,在Ta之后是冷复位

2、“冷复位”操作

在激活结束时(RST处于“L”状态,VCC上电,接口设备中的I/O处于接收模式,CLK被提供时钟信号),SIM卡准备进行冷复位。在冷复位之前,SIM卡的内部状态没有被定义。
由上图可知,CLK时钟信号在Ta时被提供。在200个时钟周期(延时ta)内,SIM卡将I/O置为状态“H”。在时钟信号被施加到CLK(时间为Ta + tb)后,在400个时钟周期(延迟tb)内,RST保持在状态“L”,从而导致冷复位。当RST处于“L”状态时,接口设备忽略l/O状态。
在时间Tb, RST被置于状态“H”。在RST信号上升沿之后(时间Tb +tc),I/O上的应答将在400到40000个时钟周期(延迟tc)之间开始。如果在40000时钟周期内没有应答,并且RST处于“H”状态时,接口设备将执行去激活操作。
Note : 上面所提到的时间都是以时钟频率f作为时间的参考源,所以不同的CLK频率,对应的各个时间节点是不一样的。不能笼统的认为是固定的时间。


3、“热复位”操作

热复位的应答与之前的冷复位的应答不同,接口设备可以在任何时候热复位SIM卡,甚至在复位的应答期间,但不是在接收到强制字符TS和T0之前。在字符T0的前缘之后,热复位不能少于4464 (=12x 372)时钟周期。
警告:在复位应答期间启动热复位,可能会损坏与先前版本兼容的SIM卡(ISO / IEC 7816 - 3:1997)
根据下图,接口设备通过将RST置于状态“L”,至少400个时钟周期(延迟te)来启动热复位(时间Tc),这个时候电源VCC保持供电状态,CLK提供合适且稳定的时钟信号。在RST被设置成“L”后,SIM卡需要在200个时钟周期(延迟td)内将I/O设置为状态“H”。当RST处于“L”状态时,接口设备忽略I/O上的状态。
在Td时, RST被置于状态“H”。在RST信号上升沿之后(时间Td +tf),I/O上的应答将在400到40000个时钟周期(延迟tf)之间开始。如果在40000时钟周期内没有应答,并且RST处于“H”状态时,接口设备将执行去激活操作。

4、“类(Class)选择”操作

下图阐述了“类选择”的操作条件。
1) 如果应答复位带有类的指示,指示了所应用的类,可以继续正常操作。或者,接口设备可以执行去激活,并在延迟至少10ms后,应用该SIM卡支持的另一个类。
2) 如果应答复位没有类的指示,则接口设备保持当前的类。如果完成应答复位后,SIM卡不工作,则接口设备应执行一个去激活操作,延迟至少10ms后,可以应用另一个类。
3) 如果卡没有应答复位,则接口设备应执行去激活。①或者延迟至少10ms后,应用另一个类(如果有的话),②或者中止选择过程。在中止一个选择过程后,接口设备可以启动另一个选择过程。
一旦选定,在正常工作过程中不得更改等级。如果要更改,接口设备应执行去激活操作,并在延迟至少10ms后应用另一个类。

5、信息交互操作

完成复位应答后,SIM卡等待来自接口设备的字符,其传输由传输参数控制,它们的解释由一个协议规定。下图给出了传输参数和协议的选择原则。
如果应答复位(特定模式的卡)中存在TA2,则接口设备应使用特定的传输参数值启动特定的传输协议。
否则(卡处于可协商模式),对于传输参数,应答复位时使用的值(即传输参数的默认值)继续适用如下。
1) 如果卡接收到的第一个字符的值是’FF’,则接口设备应该已经启动了PPS交换;传输参数的默认值将继续应用,直到成功完成PPS交换,之后接口设备将使用传输参数的协商值启动协商后的传输协议。
2) 否则,接口设备应启动“第一个提供的传输协议”。当卡只提供一种传输协议时,接口设备应该这样做传输参数的默认值。这种卡不需要支持PPS交换。

6、“时钟停止”操作

对于支持时钟停止的SIM卡,当接口设备认为没有来自SIM卡的传输,并且当l/O保持在状态“H”至少1860个时钟周期(延迟tg)时,根据下图,接口设备可以在CLK上停止时钟(时间为Te),这个期间VCC保持供电,RST处于状态“H”。
当时钟停止时(从时间Te到时间Tf), CLK根据时钟停止指示器X的要求,保持在状态“H”或状态“L”。
在Tf时,接口设备重启时钟,在至少700个时钟周期(Tf+th时刻)之后,l/O上的信息交换可以继续进行。

7、“去激活”操作

当信息交换完成或终止(如SIM卡无响应、检测到卡被取走)时,接口设备按以下顺序断开电路,见下图。
1) RST状态设为“L”
2) CLK应置于状态“L”(除非时钟已停止在状态“L”)
3) I/O应置于状态“L”
4) VCC应停止供电。


————————————————
版权声明:本文为CSDN博主「湉湉家的小虎子」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/zangqihu/article/details/131853593

remote SIM启动

  remote SIM是高通虚拟SIM卡的一种叫法,也常被叫做软卡、云卡。

remote SIM的启动流程见下图:


 remote SIM启动日志:

10-22 12:11:21:095  1533 2027 D QcCardState:Slot 1 SEED sendRemoteEvent UIM_REMOTE_CONNECTION_AVAILABLE(1) for card:454006109986504. 
10-22 12:11:21:112  1533 2027 D QCPlatFormTransferV26:sendRemoteEvent: ret: UIM_REMOTE_SUCCESS(0), event: RemoteUimEvent(slot=1, event=1, atr=3B9F95801FC78031E073FE21135786850986984418A3, errorCode=0, usage=0, transport=0, apduTimeout=14000, disableAllPolling=0, pollTimer=2700000, hasUsage=true),polltimer=true.
10-22 12:11:21:113  1533 3011 V QCPlatFormTransferV26:uimRemoteEventResponse: 1,0
10-22 12:11:21:116  1533 3011 V QCPlatFormTransferV26:uimRemoteConnectIndication: 1
10-22 12:11:21:133  1533 2027 D QcCardState:Slot 1 SEED sendRemoteEvent UIM_REMOTE_CARD_RESET(5) for card:454006109986504.
10-22 12:11:21:137  1533 2027 D QCPlatFormTransferV26:sendRemoteEvent: ret: UIM_REMOTE_SUCCESS(0), event: RemoteUimEvent(slot=1, event=5, atr=3B9F95801FC78031E073FE21135786850986984418A3, errorCode=0, usage=0, transport=0, apduTimeout=14000, disableAllPolling=0, pollTimer=2700000, hasUsage=true),polltimer=true.

UIM_REMOTE_CONNECTION_AVAILABLE(1)就是APP下发connection available,modem收到这个event就会关掉物理卡(如果有的话),进入虚拟卡模式。

uimRemoteConnectIndication: 1 就是APP收到了modem发的连接可用指示,就可再发下一个event。

UIM_REMOTE_CARD_RESET(5)就是APP下发card reset,ATR到modem,这里就是模拟物理卡的冷复位操作,之后modem就开始读取SIM卡的参数了。

APDU

APDU:Application Protocol Data Unit ,是卡的一种数据传输协议,具体内容见ETSI TS 102 221。

APDU命令的组成结构:

Table 10.1: Contents of command APDU

Code LengthDescriptionGrouping
CLA1Class of instructionHeader
INS1Instruction code
P11Instruction parameter 1
P21Instruction parameter 2
Lc0 or 1Number of bytes in the command data fieldBody
DataLcCommand data string
Le0 or 1Maximum number of data bytes expected in response of the command

APDU支持的命令:

Table 10.5: Coding of Instruction Byte of the Commands for a telecom application

COMMANDCLAINS

           Command APDUs 
SELECT FILE

STATUS  
READ BINARY  
UPDATE BINARY  
READ RECORD 
UPDATE RECORD 
SEARCH RECORD  
INCREASE 
RETRIEVE DATA  
SET DATA  
VERIFY PIN  
CHANGE PIN  
DISABLE PIN 
ENABLE PIN  
UNBLOCK PIN 
DEACTIVATE FILE  
ACTIVATE FILE 
AUTHENTICATE 
GET CHALLENGE  
TERMINAL CAPABILITY 
TERMINAL PROFILE  
ENVELOPE  
FETCH 
TERMINAL RESPONSE  
MANAGE CHANNEL  
MANAGE SECURE CHANNEL 
TRANSACT DATA  
SUSPEND UICC 
 
  Transmission oriented APDUs 
GET RESPONSE 

'0X' or '4X' or '6X' 
'8X' or 'CX' or 'EX' 
'0X' or '4X' or '6X' 
'0X' or '4X' or '6X' 
'0X' or '4X' or '6X'  
'0X' or '4X' or '6X' 
'0X' or '4X' or '6X' 
'8X' or 'CX' or 'EX' 
'8X' or 'CX' or 'EX' 
'8X' or 'CX' or 'EX' 
'0X' or '4X' or '6X' 
'0X' or '4X' or '6X' 
'0X' or '4X' or '6X' 
'0X' or '4X' or '6X' 
'0X' or '4X' or '6X'  
'0X' or '4X' or '6X' 
'0X' or '4X' or '6X'  
'0X' or '4X' or '6X'  
'0X' or '4X' or '6X' 
'8X' or 'CX' or 'EX'  
'80' 
'80' 
'80' 
'80' 
'0X' or '4X' or '6X' 
'0X' or '4X' or '6X' 
'0X' or '4X' or '6X' 
'80' 

'0X' or '4X' or '6X' 
 

'A4'
'F2'
'B0'
'D6'
'B2'
'DC' 
'A2'
'32' 
'CB'
'DB'
'20'
'24'
'26' 
'28'
'2C'
'04'
'44'
'88', '89'
'84'
'AA'
'10'
'C2'
'12' 
'14'
'70'
'73' 
'75'
'76' 


'C0'

APDU命令的返回结构:

Table 10.6: Contents of Response APDU

Code LengthDescription
DataLrResponse data string
SW11Status byte 1
SW21Status byte 2

Data是可选的,Lr是length of the response data field。SW1和SW2是状态字,必须有的。下面列出各种状态字。

状态字:

正常处理:

Table 10.7: Status byte coding - normal processing

SW1SW2Description
'90''00'- Normal ending of the command
'91''XX'- Normal ending of the command, with extra information from the proactive UICC containing a command for the terminal. Length 'XX' of the response data
'92''XX'- Normal ending of the command, with extra information concerning an ongoing data transfer session.

延迟处理:

Table 10.8: Status byte coding - postponed processing

SW1SW2Error description
'93''00'- SIM Application Toolkit is busy. Command cannot be executed at present, further normal commands are allowed

警告

Table 10.9: Status byte coding - warnings

SW1SW2Description
'62''00'- No information given, state of non volatile memory unchanged
'62''81'- Part of returned data may be corrupted
'62''82'- End of file/record reached before reading Le bytes or unsuccessful search
'62''83'- Selected file invalidated
'62''85'- Selected file in termination state
'62''F1'- More data available
'62''F2'- More data available and proactive command pending
'62''F3'- Response data available
'63''F1'- More data expected
'63''F2'- More data expected and proactive command pending
'63''CX'- Command successful but after using an internal update retry routine 'X' times 
- Verification failed, 'X' retries remaining (see note)
NOTE: For the VERIFY PIN command, SW1SW2 indicates that the command was successful but 
the PIN was not correct and there are 'X' retries left. For all other commands it indicates 
the number of internal retries performed by the card to complete the command.

执行错误:

Table 10.10: Status byte coding - execution errors

SW1SW2Description
'64''00'- No information given, state of non-volatile memory unchanged
'65''00'- No information given, state of non-volatile memory changed
'65''81'- Memory problem

基本检查错误:

Table 10.11: Status byte coding - checking errors

SW1SW2Description
'67''00'- Wrong length
'67''XX'- The interpretation of this status word is command dependent, except for SW2 = '00'
'6B''00'- Wrong parameter(s) P1-P2
'6D''00'- Instruction code not supported or invalid
'6E''00'- Class not supported
'6F''00'- Technical problem, no precise diagnosis
'6F''XX'- The interpretation of this status word is command dependent, except for SW2 = '00'

不支持CLA中的功能:

Table 10.12: Status byte coding - functions in CLA not supported

SW1SW2Description
'68''00'- No information given
'68''81'- Logical channel not supported
'68''82'- Secure messaging not supported

命令不允许:

Table 10.13: Status byte coding - command not allowed

SW1SW2Description
'69''00'- No information given
'69''81'- Command incompatible with file structure
'69''82'- Security status not satisfied
'69''83'- Authentication/PIN method blocked
'69''84'- Referenced data invalidated
'69''85'- Conditions of use not satisfied
'69''86'- Command not allowed (no EF selected)
'69''89'- Command not allowed - secure channel - security not satisfied

参数错误:

Table 10.14: Status byte coding - wrong parameters

SW1SW2Description
'6A''80'- Incorrect parameters in the data field
'6A''81'- Function not supported
'6A''82'- File not found
'6A''83'- Record not found
'6A''84'- Not enough memory space
'6A''86'- Incorrect parameters P1 to P2
'6A''87'- Lc inconsistent with P1 to P2
'6A''88'- Referenced data not found

应用错误:

Table 10.15: Status byte coding - application errors

SW1SW2Error description
'98''50'- INCREASE cannot be performed, max value reached
'98''62'- Authentication error, application specific
'98''63'- Security session or association expired
'98''64'- Minimum UICC suspension time is too long
NOTE: Applications may define their own error codes.

APDU举例:

下面是读取SIM卡文件6FAD内容的所有APDU:

D ApduController:modem_apdu NATIVE_REQ:SOFTSIM,1,00A40804047FFF6FAD
D ApduController:modem_apdu NATIVE_RSP:SOFTSIM,1,612A
D ApduController:modem_apdu NATIVE_REQ:SOFTSIM,1,00C000002A
D ApduController:modem_apdu NATIVE_RSP:SOFTSIM,1,62288202412183026FADA50FC0010091047F206FAD920100DE01008A01058B036F0606800200048801189000
D ApduController:modem_apdu NATIVE_REQ:SOFTSIM,1,00B0000004
D ApduController:modem_apdu NATIVE_RSP:SOFTSIM,1,000001029000

APDU解码:

普通解码:

APDU解码可参见ETSI TS 102 221 10 Structure of commands and responses 和 11 Commands。

如00A40804047FFF6FAD解码如下:

00:CLA

A4:INS,SELECT FILE

08:P1,Select by path from MF

04:P2,Return FCP template

04:Lc,Number of bytes in the command data field

7FFF6FAD:path,7FFF 6FAD

'61xx' 和 '6Cxx'解码

过程字节“61xx”指示终端的传输层向UICC发出GET RESPONSE命令。GET RESPONSE命令头的P3设置为“xx”。例如APDU举例中的例子:

00A40804047FFF6FAD

612A

00C000002A

过程字节“6Cxx”指示终端的传输层立即重新发送先前的命令头,将P3设置为“xx”

具体参见协议:ETSI TS 102 221 7.3.1.1.5 Use of procedure bytes '61xx' and '6Cxx'

FCP template tag = '62'解码

The response data contains the File Control Parameters (FCP) template of the selected file. The contents of the FCP depend on the selected file.

具体参见:ETSI TS 102 221 11.1.1.3 Response Data

我根据这部分协议写了个FCP类APDU初步解析的python程序:

def parse_apdu_response_fcp(apdu_resp_str):
    """
    解析APDU响应字符串,打印状态码和数据等信息
    ETSI TS 102 221
    11.1.1.3 Response Data
    11.1.1.4 File control parameters
    """
    tag_d = {
        "62": "FCP template tag = '62'",
        "82": "File Descriptor",
        "83": "File Identifier",
        "84": "DF name (AID)",
        "A5": "Proprietary information",
        "8A": "Life Cycle Status Integer",
        "8B": "Security attributes",
        "8C": "Security attributes",
        "AB": "Security attributes",
        "C6": "PIN Status Template DO",
        "81": "Total file size",
        "80": "File size",
        "88": "Short File Identifier (SFI)"
    }

    """
    3GPP TS 31.102
    H.1	List of SFI Values at the USIM ADF Level
    """
    sfi_d = {
        "01": "'6FB7', Emergency call codes",
        "02": "'6F05', Language indication",
        "03": "'6FAD', Administrative data",
        "04": "'6F38', USIM service table",
        "05": "'6F56', Enabled services table",
        "06": "'6F78', Access control class",
        "07": "'6F07', IMSI",
        "08": "'6F08', Ciphering and integrity keys",
        "09": "'6F09', Ciphering and integrity keys for packet switched domain",
        "0A": "'6F60', User PLMN selector",
        "0B": "'6F7E', Location information",
        "0C": "'6F73', Packet switched location information",
        "0D": "'6F7B', Forbidden PLMNs",
        "0E": "'6F48', CBMID",
        "0F": "'6F5B', Hyperframe number",
        "10": "'6F5C', Maximum value of hyperframe number",
        "11": "'6F61', Operator PLMN selector",
        "12": "'6F31', Higher Priority PLMN search period",
        "13": "'6F62', Preferred HPLMN access technology",
        "14": "'6F80', Incoming call information",
        "15": "'6F81', Outgoing call information",
        "16": "'6F4F', Capability configuration parameters 2",
        "17": "'6F06', Access Rule Reference",
        "18": "'6FE4', EPS NAS Security Context",
        "19": "'6FC5', PLMN Network Name",
        "1A": "'6FC6', Operator Network List",
        "1B": "'6FCD', Service Provider Display Information",
        "1C": "'6F39', Accumulated Call Meter (see note)",
        "1D": "'6FD9', Equivalent HPLMN",
        "1E": "'6FE3', EPS location information"
    }
    print(apdu_resp_str)
    if len(apdu_resp_str) == 4 + int(apdu_resp_str[2:4], 16) * 2 + 4:
        sw1 = apdu_resp_str[-4:-2]
        sw2 = apdu_resp_str[-2:]
        print(f"{sw1}{sw2}:sw1 sw2")

    index = 0
    while index < 4 + int(apdu_resp_str[2:4], 16) * 2:
        tag = apdu_resp_str[index:index+2]
        print(f"{tag}:tag, {tag_d.get(tag)}")

        index = index + 2
        length = int(apdu_resp_str[index:index+2], 16)
        print(f"{apdu_resp_str[index:index+2]}:length")

        index = index + 2
        value = apdu_resp_str[index:index + length * 2]
        print(f"{value}:value")
        if tag == "88" and length == 1:
            sfi = "{:0>2}".format(hex(int(value, 16) >> 3)[2:])
            print(f"{value}'s SFI is {sfi}, {sfi_d.get(sfi)}")
        if tag == "A5":
            parse_apdu_response_tag_A5(value)

        if tag != "62":
            index = index + length * 2




def parse_apdu_response_tag_A5(apdu_resp_str):
    """
    ETSI TS 102 221
    11.1.1.4.6 Proprietary information
    """
    tag_d = {
        "A5": "Proprietary information",
        "80": "UICC characteristics",
        "81": "Application power consumption",
        "82": "Minimum application clock frequency",
        "83": "Amount of available memory",
        "84": "File details",
        "85": "Reserved file size",
        "86": "Maximum file size",
        "87": "Supported system commands",
        "88": "Specific UICC environmental conditions",
        "89": "Platform to Platform CAT Secured APDU"
    }
    print(apdu_resp_str)

    index = 0
        while index < 4 + int(apdu_resp_str[2:4], 16) * 2:
        tag = apdu_resp_str[index:index + 2]
        if tag[0] in ['C', 'D', 'E', 'F']:
            print(f"{tag}:tag, is private")
        else:
            print(f"{tag}:tag, {tag_d.get(tag)}")

        index = index + 2
        length = int(apdu_resp_str[index:index + 2], 16)
        print(f"{apdu_resp_str[index:index + 2]}:length")

        index = index + 2
        value = apdu_resp_str[index:index + length * 2]
        print(f"{value}:value")

        if tag != "A5":
            index = index + length * 2

if __name__ == '__main__':
    # apdu_resp_str = "62178202412183026F7E8A01058B036F06058002000B8801589000"
    # apdu_resp_str = "621B8202412183026FD9A5038001718A01058B036F06028002000C88009000"
    # apdu_resp_str = "622282054221002C0E83026F06A506D00130D201038A01058B036F060A800202688801B89000"
    # parse_apdu_response_fcp(apdu_resp_str)
    # apdu_resp_str = "A503800171"
    # parse_apdu_response_tag_A5(apdu_resp_str)

 用该程序解码APDU举例中的:62288202412183026FADA50FC0010091047F206FAD920100DE01008A01058B036F0606800200048801189000

得到:

62288202412183026FADA50FC0010091047F206FAD920100DE01008A01058B036F0606800200048801189000
9000:sw1 sw2
62:tag, FCP template tag = '62'
28:length
8202412183026FADA50FC0010091047F206FAD920100DE01008A01058B036F060680020004880118:value
82:tag, File Descriptor
02:length
4121:value
83:tag, File Identifier
02:length
6FAD:value
A5:tag, Proprietary information
0F:length
C0010091047F206FAD920100DE0100:value
C0010091047F206FAD920100DE0100
C0:tag, is private
01:length
00:value
8A:tag, Life Cycle Status Integer
01:length
05:value
8B:tag, Security attributes
03:length
6F0606:value
80:tag, File size
02:length
0004:value
88:tag, Short File Identifier (SFI)
01:length
18:value
18's SFI is 03, '6FAD', Administrative data

AT

CRSM:

这里只介绍和SIM相关的AT指令CRSM,详见:3GPP TS 27.007

8.18    Restricted SIM access +CRSM

Table 78: +CRSM action command syntax

CommandPossible response(s)
+CRSM=<command>[,<fileid>[,<P1>,<P2>,<P3>[,<data>[,<pathid>]]]]

+CRSM: <sw1>,<sw2>[,<response>]

+CME ERROR: <err>

+CRSM=?

<command>: (command passed on by the MT to the SIM; refer 3GPP TS 51.011 [28]):
176    READ BINARY
178    READ RECORD
192    GET RESPONSE
214    UPDATE BINARY
220    UPDATE RECORD
242    STATUS
203    RETRIEVE DATA
219    SET DATA
all other values are reserved


举例:

AT读卡文件参数都是十进制的:

6F60:

[14:33:28.766]收←◆at+crsm=192,28512,0,0,0
+CRSM: 144,0,"62178202412183026F608A01058B036F060580020028880150"

OK

[14:34:18.839]收←◆at+crsm=176,28512,0,0,40
+CRSM: 144,0,"64F010400064F090400064F010800064F0908000FFFFFF0000FFFFFF0000FFFFFF0000FFFFFF0000"

OK

如何清除RPLMN?
AT+CRSM=214,28542,0,0,11,"FFFFFFFFFFFFFFFFFFFF01"
+CRSM: 144,0,""
OK
AT+CRSM=214,28531,0,0,14,"FFFFFFFFFFFFFFFFFFFFFFFFFF01"
+CRSM: 144,0,""
OK
AT+CRSM =214,28643,0,0,18,"0BF6FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF01"
+CRSM: 144,0,""
OK

常用卡文件

详细内容可查阅:3GPP TS 31.102

LTE 的 RPLMN 文件 EFepsloci 0x6FE3,SFI: '1E'
2/3G CS 域RPLMN EFloci 6F7E,SFI: '0B'
2/3G PS 域 RPLMN EFpsloci 6F73,SFI: '0C'
OPLMN, EFOPLMNwACT (Operator controlled PLMN selector with Access Technology):6F61,SFI: '11'
UPLMN, EFPLMNwAcT (User controlled PLMN selector with Access Technology):6F60,SFI: '0A'
FPLMN, EFFPLMN (Forbidden PLMNs):6F7B,SFI: '0D'
ICCID:2FE2
EFLRPLMNSI (Last RPLMN Selection Indication): 6FDC
EFUST (USIM Service Table):6F38,SFI: '04'
EFEHPLMN (Equivalent HPLMN): 6FD9,SFI: '1D'
EFHPPLMN(Higher Priority PLMN search period),6F31 ,SFI: '12' 高优先级回网
EFIMSI (IMSI),6F07,SFI: '07'
EF5GS3GPPLOCI (5GS 3GPP location information),4F01,SFI: '01'
EFHPLMNwAcT (HPLMN selector with Access Technology) :6F62 , SFI: '13'  MMGSDI_USIM_HPLMNWACT,      /**< Home PLMN selector With Access Technology. */


6FD9或00B09D   EHPLMN 
6F73或00B08C   23G PS RPLMN 
6F61或00B091    OPLMN
6F60或00B08A   UPLMN
6F7B或00B08D    FPLMN
6FE3或00B09E     RPLMN LTE
6F7E或00B08B     CS RPLMN
举例:6F7E为长文件,0B为短文件,有时modem不一定来查长文件,如果搜了长的没,就搜短的,短的方式是在短文件+'80',如这个是0B,那么就是8B。00B0为查询,即是00B08B。

参考文档:

ISO/IEC 7816-3: "Identification cards - Integrated circuit cards - Part 3: Cards with contacts - 
Electrical interface and transmission protocols".

80-p6929-1_a_remote_sim_application_overview.pdf

ETSI TS 102 221 Smart Cards;UICC-Terminal interface; Physical and logical characteristics

3GPP TS 31.102 3rd Generation Partnership Project;Technical Specification Group Core Network and Terminals;Characteristics of the Universal Subscriber Identity Module (USIM) application

ISO_IEC_7816-3-2006在线阅读:
https://www.doc88.com/p-7793986729065.html

高清可复制 ISO IEC 7816-4-2020:
https://www.doc88.com/p-23073104984189.html

【科普贴】SIM卡接口协议(ISO7816-3)详解_sim卡协议_湉湉家的小虎子的博客-CSDN博客

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
SIM的VPP引脚是可选的,它通常用于编程或擦除SIM的内部存储器。VPP引脚的功能是提供编程电压,以便对SIM进行写入或擦除操作。在一般情况下,VPP引脚可以悬空,也就是不连接到任何电源或地线。具体是否需要使用VPP引脚,以及如何连接VPP引脚,需要根据具体的SIM设计参考来确定。 #### 引用[.reference_title] - *1* [SIM电路知识小结](https://blog.csdn.net/weixin_43772512/article/details/119296156)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [SIM相关知识总结](https://blog.csdn.net/BJTUYBYUAN/article/details/120200965)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [SIM引脚定义](https://blog.csdn.net/zyl615110/article/details/78188770)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值