Security chip and file operation method thereof

By dividing the life cycle state in the security chip and determining the file operation processing results based on the status, the problem of low file operation security in the prior art is solved, and higher security and flexibility are achieved.

CN119760760APending Publication Date: 2025-04-04ZHONGGUANCUN XINHAIZEYOU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411587949.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-07
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

File operations in existing security chips are less secure and are vulnerable to attacks that lead to information leakage or system crashes.

Method used

By dividing the life cycle states (uninitialized state, initialized state, issue state and terminated state) in the security chip, deciding whether to respond to file operation commands based on the current life cycle state, so as to achieve refined control of file operations.

Benefits of technology

Improve the security of file operations in security chips, prevent unauthorized file operations, and enhance the security of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119760760A_ABST
    Figure CN119760760A_ABST
Patent Text Reader

Abstract

The present application discloses a security chip and a file operation method thereof, and relates to the field of security chip technology. After receiving a file operation command sent by an interface device, the method can obtain the current first life cycle state of the security chip, and determine the processing result of the file operation command based on the first life cycle state. The processing result is to respond to the file operation command or to prohibit responding to the file operation command. Since the method divides the life cycle state for the security chip and decides whether to respond to the file operation command based on the life cycle state of the security chip, that is, the file operation in the security chip is finely controlled according to the first life cycle state, compared with the method of directly responding to the file operation command in the related art, the method can improve the security of the file operation in the security chip to a certain extent, thereby improving the security of the security chip.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of security chips, and in particular to a security chip and a file operation method thereof. Background Art

[0002] The power grid's electricity consumption information collection system includes a large number of terminal devices, each of which can collect power data and exchange power data with other devices. To ensure the safe interaction of power data, a security chip is set in each terminal device.

[0003] Creating a file in a security chip is a prerequisite for all subsequent security operations (such as reading and writing files). Currently, if a security chip receives a file operation command, it can directly respond to the file operation command and perform the corresponding file operation. This shows that the security of file operations in security chips is currently low. Summary of the invention

[0004] The present application provides a security chip and a file operation method thereof, which can solve the problem of low security of file operations in current security chips. The technical solution is as follows:

[0005] On the one hand, a file operation method of a security chip is provided, the method comprising:

[0006] Receiving file operation commands sent by the interface device;

[0007] In response to the file operation command, obtaining a current first life cycle state of the security chip;

[0008] Based on the first life cycle state, a processing result of the file operation command is determined, where the processing result includes: one of responding to the file operation command and prohibiting responding to the file operation command.

[0009] Optionally, the first life cycle state is one of an uninitialized state, an initialized state, a released state, and a terminated state; and determining a processing result of the file operation command based on the first life cycle state includes:

[0010] If the first life cycle state is the uninitialized state or the terminated state, it is determined that the processing result of the file operation command is that responding to the file operation command is prohibited.

[0011] Optionally, after determining that the first life cycle state is an uninitialized state, the method further includes:

[0012] A prompt message is issued, wherein the prompt message is used to prompt that the security chip is currently in the uninitialized state, and if a file operation is required on the security chip, the life cycle state of the security chip is switched from the uninitialized state to the initialized state.

[0013] Optionally, the first life cycle state is one of an uninitialized state, an initialized state, a released state, and a terminated state; and determining a processing result of the file operation command based on the first life cycle state includes:

[0014] If the first life cycle state is neither the uninitialized state nor the terminated state, determining based on the first life cycle state, in the case where permission authentication of the interface device is required, determining a processing result of the file operation command based on a permission authentication result of the interface device;

[0015] If the first life cycle state is neither the uninitialized state nor the terminated state, determining based on the first life cycle state that, without performing authority authentication on the interface device, the processing result of the file operation command is a response to the file operation command;

[0016] The authority authentication result includes: having the operation authority and not having the operation authority.

[0017] Optionally, determining the processing result of the file operation command based on the authority authentication result of the interface device includes:

[0018] If the authority authentication result of the interface device is that it has the operation authority, determining the processing result of the file operation command is to respond to the file operation command;

[0019] If the authority authentication result of the interface device is that the interface device does not have the operation authority, then the processing result of the file operation command is determined to be that the response to the file operation command is prohibited.

[0020] Optionally, before determining the processing result of the file operation command, the method further includes:

[0021] If the first life cycle state is the issued state, determining that the interface device needs to be authenticated;

[0022] If the first life cycle state is the initialization state, it is determined that there is no need to perform authority authentication on the interface device.

[0023] Optionally, the first life cycle state is a release state; before determining the processing result of the file operation command based on the authority authentication result of the interface device, the method further includes:

[0024] Receiving authentication data having a first length sent by the interface device;

[0025] Based on the authentication data and the reference data having the first length, splicing to obtain intermediate data having a second length, wherein the second length is twice the first length, the reference data is obtained by performing an XOR operation on a random number and a target character, and the lengths of the random number and the target character are both the first length;

[0026] Encrypting the intermediate data to obtain ciphertext data having a length of the second length;

[0027] performing an XOR operation on the first ciphertext sub-data and the second ciphertext sub-data in the ciphertext data to obtain the third ciphertext sub-data, wherein the length of the first ciphertext sub-data and the length of the second ciphertext sub-data are both the first length, and the position of the first ciphertext sub-data in the ciphertext data has no intersection with the position of the second ciphertext sub-data in the ciphertext data;

[0028] Performing an XOR operation on the third ciphertext sub-data and the target character to obtain verification data;

[0029] If the verification data is the same as the authentication data, determining that the authority authentication result of the interface device is having the operation authority;

[0030] If the verification data is different from the authentication data, it is determined that the authority authentication result of the interface device is that the interface device does not have the operation authority.

[0031] Optionally, encrypting the intermediate data to obtain ciphertext data having a length of the second length includes:

[0032] The intermediate data is encrypted using the national encryption SM1 algorithm to obtain ciphertext data having a length of the second length.

[0033] Optionally, the method further includes:

[0034] Receiving a state switching command sent by the interface device;

[0035] In response to the state switching command, the life cycle state of the security chip is switched from the first life cycle state to a second life cycle state.

[0036] In another aspect, a security chip is provided, the security chip comprising: a processor, the processor being configured to:

[0037] Receiving file operation commands sent by the interface device;

[0038] In response to the file operation command, obtaining a current first life cycle state of the security chip;

[0039] Based on the first life cycle state, a processing result of the file operation command is determined, where the processing result includes: one of responding to the file operation command and prohibiting responding to the file operation command.

[0040] On the other hand, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the method described in the above aspects is implemented.

[0041] The beneficial effects brought about by the technical solution claimed in this application include at least:

[0042] The present application provides a security chip and a file operation method thereof. After receiving a file operation command sent by an interface device, the method can obtain the current first life cycle state of the security chip and determine the processing result of the file operation command based on the first life cycle state. The processing result is to respond to the file operation command or to prohibit responding to the file operation command. Since the method divides the life cycle state of the security chip and decides whether to respond to the file operation command based on the life cycle state of the security chip, that is, to perform fine control on the file operation in the security chip according to the first life cycle state, compared with the method of directly responding to the file operation command in the related art, the method can improve the security of the file operation in the security chip to a certain extent, thereby improving the security of the security chip.

[0043] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 is a flow chart of a file operation method of a security chip provided by an embodiment of the present application;

[0045] Figure 2 is a flowchart of another file operation method of a security chip provided by an embodiment of the present application;

[0046] Figure 3 is a flow chart of a method for determining whether an interface device has operation authority provided by an embodiment of the present application;

[0047] Figure 4 It is a schematic diagram of the structure of a security chip provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] Embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0049] The power grid's electricity consumption information collection system includes a large number of terminal devices, each of which can collect power data and exchange power data with other devices. To ensure the secure interaction of power data, a security chip is set in each terminal device. The security chip supports at least one of the hardware encryption and decryption algorithms such as SM1, SM2 and SM3, so it can provide security functions (such as data encryption and decryption) for terminal devices to ensure the interactive security of power data, thereby enhancing the security of terminal devices.

[0050] The security chip includes an on-chip operating system (COS), which can also be called a chip operating system. The COS can control and manage various resources and functions inside the security chip to ensure the security, integrity and reliability of power data. The COS mainly includes the following parts: underlying firmware, file system, security system, communication processing module, and command management module. Among them, the underlying firmware is mainly responsible for hardware initialization of the security chip, loading COS, providing a unified hardware abstraction to call the interface, firmware update and hardware security functions. The file system is responsible for the management of the internal storage space of the terminal device or security chip, including operations such as file creation, deletion, reading and writing. The file system can ensure the security and integrity of data during storage and transmission. The security system can provide security functions, mainly including encryption, decryption, signing and verification, etc., to protect sensitive data stored in the terminal device or security chip from illegal access or tampering. The communication processing module is responsible for the communication management between the security chip and the external device, including the reception, parsing and execution of commands. Through communication processing, secure communication between COS and external devices can be ensured. The command management module is responsible for the management and scheduling of commands within the security chip to ensure that various operations can be performed in a predetermined order and logic.

[0051] Creating a file in the security chip is a prerequisite for all subsequent security operations (such as reading and writing files). Currently, when performing file operations (such as creating files) in the security chip, the default is a secure production environment, so files can be freely created and read and written inside the security chip without authorization authentication.

[0052] However, if the production environment is attacked by the outside world, the information of the security chip will be out of control. For example, hackers can use file creation commands to create and access files or directories that should not be exposed, thereby leaking sensitive information stored in the security chip; modify or delete important system files or user data, causing system crashes or data loss; create storage malware to steal information, destroy data, or control the operation of the device; create or modify system files to obtain higher permissions to further attack the system or access sensitive data; and may also make the information in the file system inconsistent or damaged, causing the device to not work properly or need to be repaired. It can be seen that the security of file operations in security chips is currently low.

[0053] The present application embodiment provides a file operation method for a security chip, which is applied to the security chip. Figure 1 , the method comprising:

[0054] Step 101: Receive a file operation command sent by an interface device.

[0055] If the user needs to perform a file operation in the security chip, the interface device can be triggered to send a file operation command to the security chip. Correspondingly, the security chip can receive the file operation command. The file operation command may include one of the following commands: a file creation command, a file read command, a file write command, and a file update command.

[0056] Step 102: In response to the file operation command, obtain the current first life cycle state of the security chip.

[0057] After the security chip receives the file operation command, in response to the file operation command, the current first life cycle state of the security chip can be obtained. The first life cycle state is one of the multiple life cycle states. The multiple life cycle states may include four states: uninitialized state, initialized state, issued state and terminated state. The switching of the four states is unidirectional and irreversible. In other words, the life cycle state of the security chip can only be switched from the uninitialized state to the initialized state, then to the issued state, and finally to the terminated state.

[0058] Step 103: Determine a processing result of the file operation command based on the first life cycle state.

[0059] The processing result includes: one of responding to the file operation command and prohibiting responding to the file operation command.

[0060] In an embodiment of the present application, if the first life cycle state of the security chip is an uninitialized state or a terminated state, that is, the security chip is currently in an uninitialized state, the security chip can determine that the processing result of the file operation command is to prohibit responding to the file operation command, and then the file operation command can be discarded.

[0061] If the first life cycle state of the security chip is the initialization state, the security chip can determine that the processing result of the file operation command is a response to the file operation command, and then the security chip can perform the corresponding file operation. If the first life cycle state of the security chip is the issuance state, the security chip can determine the processing result of the file operation command based on the authority authentication result of the interface device. Specifically, if the authority authentication result is that the operation authority is possessed, the security chip can determine that the processing result is a response to the file operation command. If the authority authentication result is that the operation authority is not possessed, the security chip can determine that the processing result is a prohibition of responding to the file operation command.

[0062] In summary, the embodiment of the present application provides a file operation method for a security chip. After receiving the file operation command sent by the interface device, the method can obtain the current first life cycle state of the security chip, and determine the processing result of the file operation command based on the first life cycle state. The processing result is to respond to the file operation command or to prohibit responding to the file operation command. Since the method divides the life cycle state of the security chip and decides whether to respond to the file operation command based on the life cycle state of the security chip, that is, the file operation in the security chip is finely controlled according to the first life cycle state, compared with the method of directly responding to the file operation command in the related art, this method can improve the security of the file operation in the security chip to a certain extent, thereby improving the security of the security chip.

[0063] Figure 2 is a flowchart of another file operation method of a security chip provided by an embodiment of the present application, and the method is applied to a security chip. Figure 2 , the method may include:

[0064] Step 201: Receive a file operation command sent by an interface device.

[0065] If the user needs to perform a file operation in the security chip (such as creating a file, reading a file, or updating a file, etc.), the interface device can be triggered to send a file operation command to the security chip. Correspondingly, the security chip can receive the file operation command. The file operation command may include one of the following commands: a file creation command, a file reading command, a file writing command, and a file updating command.

[0066] Optionally, the file operation command can be an application protocol data unit (APDU) command. When the file operation command is a file creation command, the file creation command can be used to create multiple types of files, and the security chip can only create one file when executing a file creation command once. Creating a file usually refers to creating a new file entity, and the process of creating a file includes creating a file header and allocating storage space for the file body. The file header is used to store file metadata, which includes file name, file size, file type, file permissions (such as read, write, execute permissions) and file creation time. The file body is the area where file data is actually stored.

[0067] Among them, various types of files may include: master file (MF), directory definition file (DDF), application definition file (ADF), elementary file (EF), transparent file, linear fixed-length file, secret file (SF) and other types of files. MF is the root of the entire file system and can be regarded as the root directory. The root directory is the basic directory that is created first. Only after MF is created can files other than MF, such as DDF, ADF and EF, be created. The other types of files may include: private files. Private files usually set corresponding permissions to ensure that private files are not read out. In this way, the security of file operations in the security chip is guaranteed.

[0068] Optionally, the design of the file creation command can be as shown in Table 1. As can be seen from Table 1, the message of the file creation command may include: a CLA field, an INS field, a P1 field, a P2 field, an Lc field, and a data (DATA) field (i.e., a DATA domain). Among them, the P2 field is used to indicate the type of the file to be created, and the field value of the P2 field can be 00, 01, 02, 03, 04, or 05. 00 indicates the creation of MF, 01 indicates the creation of DDF, 02 indicates the creation of ADF, 03 indicates the creation of a transparent file, 04 indicates the creation of a linear fixed-length file, and 05 indicates the creation of a secure file. The Lc field is used to indicate the length of the DATA field.

[0069] Table 1

[0070]

[0071]

[0072]

[0073] It is understandable that, as shown in Table 1, the length of the DATA field of different types of files is different. The information required to create different types of files may be different, and the information may be recorded in the DATA field in the file creation command. The content of the DATA field of various types of files may be as shown in Table 1.

[0074] In the embodiment of the present application, the security chip can also create public files and user private files according to user conditions, and set corresponding permissions to ensure that private files are not read out.

[0075] Step 202: In response to the file operation command, obtain the current first life cycle state of the security chip.

[0076] In the embodiment of the present application, the life cycle of the security chip includes multiple life cycle states (also referred to as life cycle stages). The first life cycle state is one of the multiple life cycle states.

[0077] The multiple life cycle states may include: uninitialized state, initialized state, issued state and terminated state. The switching of the four states is unidirectional and irreversible. In other words, the life cycle state of the security chip can only be switched from the uninitialized state to the initialized state, then to the issued state, and finally to the terminated state.

[0078] Among them, the uninitialized state refers to the stage where the security chip is in after it is produced and before it is initialized. The initialized state refers to the stage where the security chip can perform any read and write operations on the security chip without the need for permission authentication after it is initialized. The issued state refers to the stage where permission authentication is required to perform read and write operations on the security chip. The terminated state refers to the state where the security chip stops performing file operations.

[0079] Step 203: If the first life cycle state is an uninitialized state or a terminated state, determine that the processing result of the file operation command is to prohibit responding to the file operation command.

[0080] In an embodiment of the present application, the security chip processes file operation commands differently after receiving them in different life cycle states to ensure the security of the security chip. Specifically, the security chip must be initialized before creating a file. It can be seen that when the security chip is in an uninitialized state, the security chip will not respond to file operation commands. When the security chip is in a terminated state, regardless of whether the interface device has operation permissions for files in the security chip, the security chip will not respond to file operation commands sent by the interface device. When the security chip is in an initialized state or a released state, the security chip can decide whether to respond to file operation commands sent by the interface device based on whether the interface device needs to perform permission authentication, and if permission authentication is required, based on the permission authentication result of the interface device.

[0081] Based on this, after the security chip obtains the first life cycle state, if it is determined that the first life cycle state is an uninitialized state or a terminated state, it can be determined that the processing result of the file operation command is a prohibition of responding to the file operation command. That is, at this time, the security chip does not allow the creation of files and related read and write operations. In this way, the security chip can be guaranteed before initialization and after the life cycle is terminated.

[0082] It is understandable that, when the security chip determines that the first life cycle state is an uninitialized state, it can also send a prompt message to the interface device. The prompt message is used to prompt that the security chip is in an uninitialized state, and if a file operation is required on the security chip, the life cycle state of the security chip needs to be switched from the uninitialized state to the initialized state. Among them, performing a file operation on the security chip means that: the interface device sends a file operation command to the security chip, and the security chip responds to the file operation command to perform the corresponding file operation.

[0083] Step 204: If the first life cycle state is neither an uninitialized state nor a terminated state, determine whether permission authentication is required for the interface device based on the first life cycle state.

[0084] If the security chip determines that the interface device does not need to be authenticated based on the first life cycle state, step 205 may be executed. If the security chip determines that the interface device needs to be authenticated based on the first life cycle state, step 206 may be executed.

[0085] In the embodiment of the present application, when the security chip is in the initialization state, as long as the security chip receives the file operation command sent by the interface device, it can respond to the file operation command. In other words, the interface device does not need to have the operation authority for the file in the security chip to perform file operations on the security chip. When the security chip is in the issuance state, the interface device needs to have the operation authority to perform file operations on the security chip. That is, the interface device needs to have the operation authority before the security chip will respond to the file operation command sent by the interface device and perform operations such as file creation, reading, writing or updating.

[0086] Based on this, if the security chip determines that the first life cycle state is the initialization state, it can be determined that there is no need to authenticate the interface device. If the security chip determines that the first life cycle state is the issuance state, it can be determined that there is a need to authenticate the interface device.

[0087] Step 205: Determine that the processing result of the file operation command is a response to the file operation command.

[0088] If the security chip determines that there is no need to perform authority authentication on the interface device, it may determine that the processing result of the file operation command is a response to the file operation command.

[0089] Step 206: Determine the processing result of the file operation command based on the authority authentication result of the interface device.

[0090] If the security chip determines that the interface device needs to be authenticated, the processing result of the file operation command can be determined based on the authentication result of the interface device, wherein the authentication result includes: having the operation authority or not having the operation authority.

[0091] In the embodiment of the present application, if the security chip determines that the authority authentication result of the interface device is that it has the operation authority, then the processing result of the file operation command can be determined to be a response to the file operation command. If the security chip determines that the authority authentication result of the interface device is that it does not have the operation authority, then the processing result of the file operation command can be determined to be a prohibition of responding to the file operation command.

[0092] After obtaining the processing result of the file operation command, the security chip can process the file operation command based on the processing result of the file operation command. Specifically, if the processing result is a response to the file operation command, the security chip can execute the file operation indicated by the file operation command. If the processing result is a prohibition of responding to the file operation command, the security chip can discard the file operation command.

[0093] If the file operation command is a file creation command, then the file operation is a file creation operation. If the file operation command is a file read command, then the file operation is a file read operation. If the file operation command is a file update command, then the file operation is a file update operation.

[0094] In the embodiment of the present application, when the first life cycle state is the release state, see Figure 3 The process by which the security chip determines whether the interface device has the operation permission may include:

[0095] Step 2061: Receive authentication data of a first length sent by an interface device.

[0096] When the security chip is in the release state, if the interface device needs to perform file operations on the security chip, it can perform permission authentication. Specifically, the interface device can send a random number acquisition command to the security chip. After the security chip receives the random number acquisition command, it can respond to the random number acquisition command and send the internally obtained random number to the interface device. After receiving the random number, the interface device can generate authentication data based on the random number and send the authentication data to the security chip. Accordingly, the security chip can obtain the authentication data.

[0097] The length of the random number and the length of the authentication data are both first lengths. The first length may be 8 bytes. The random number acquisition command may be "0084000008".

[0098] In an embodiment of the present application, the interface device may send an external authentication command to the security chip. The external authentication command includes authentication data. For example, the external authentication command may be "0082000008+8 bytes of authentication data".

[0099] Step 2062: Based on the authentication data and the reference data having a first length, concatenate to obtain intermediate data having a second length.

[0100] The second length is twice the first length. The reference data is obtained by performing XOR on the random number and the target character, and the lengths of the random number and the target character are both the first length. The random number is the random number sent to the interface device. The target character may be pre-stored in the security chip, for example, 0xAA. 0x represents hexadecimal.

[0101] Taking the first length of 8 bytes as an example, the process of the security chip executing step 2062 is exemplarily described as follows:

[0102] After receiving the authentication data sent by the interface device, the security chip can XOR the 8-byte random number with the 8-byte target character to obtain 8-byte reference data. Then, the security chip can splice the 8-byte reference data after the 8-byte reference data to obtain 16-byte intermediate data.

[0103] Step 2063: Encrypt the intermediate data to obtain ciphertext data with a second length.

[0104] After obtaining the intermediate data, the security chip may encrypt the intermediate data based on the authentication key, thereby obtaining ciphertext data having a second length.

[0105] In an embodiment of the present application, the security chip can encrypt the intermediate data using an encryption algorithm based on the authentication key, thereby obtaining ciphertext data with a length of the second length. Optionally, the encryption algorithm can be the national secret SM1 algorithm. For example, it can be the electronic code book (ECB) mode of the national secret SM1 algorithm.

[0106] It can be understood that if the file creation instruction is used to instruct the creation of MF, the authentication key includes: the manufacturer key. After the MF is successfully established, the master key MF-key defaults to 00H. If the file creation instruction is used to instruct the establishment of DDF, ADF or EF under MF, the authentication key includes: the master key MF-key. If the file creation instruction is used to instruct the establishment of DDF, ADF or EF under DDF, the authentication key includes the master key DDF-key of DDF. If the file creation instruction is used to instruct the establishment of EF under ADF, the authentication key includes: the master key DF-key of ADF.

[0107] Step 2064: Perform an XOR operation on the first ciphertext sub-data and the second ciphertext sub-data in the ciphertext data to obtain the third ciphertext sub-data.

[0108] The length of the first ciphertext sub-data and the length of the second ciphertext sub-data are both the first length. Furthermore, the position of the first ciphertext sub-data in the ciphertext data has no intersection with the position of the second ciphertext sub-data in the ciphertext data.

[0109] For example, assuming that the second length is 16 bytes, the first ciphertext sub-data may be the first 8 bytes of ciphertext sub-data in the 16-byte ciphertext data, and the second ciphertext sub-data may be the last 8 bytes of ciphertext sub-data in the 16-byte ciphertext data.

[0110] Step 2065: XOR the third ciphertext sub-data with the target character to obtain verification data.

[0111] After obtaining the third ciphertext sub-data, the security chip may perform an XOR operation on the third ciphertext sub-data and the target character to obtain verification data.

[0112] Step 2066: If the verification data is the same as the authentication data, then determine that the authority authentication result of the interface device is that it has the operation authority.

[0113] The security chip can compare the verification data with the authentication data sent by the interface device to see if they are the same. If the security chip determines that the verification data is the same as the authentication data, it can be determined that the interface device has passed the authority authentication, and then it can be determined that the authority authentication result of the interface device has the operation authority.

[0114] Step 2067: If the verification data is different from the authentication data, it is determined that the authority authentication result of the interface device is that the interface device does not have the operation authority.

[0115] After comparing the verification data with the authentication data sent by the interface device, if the security chip determines that the verification data is different from the authentication data, it can be determined that the interface device has not passed the authority authentication, and then it can be determined that the authority authentication result of the interface device is that it does not have the operation authority.

[0116] According to the description of the above steps 203 to 206, the method provided in the embodiment of the present application divides the life cycle of the security chip into four states: uninitialized state, initialized state, issued state, and terminated state, and sets different permission requirements in different life cycle states, so that the security chip selects corresponding security policies in different life cycle states. Thus, the flexibility and security of file operations in the security chip are guaranteed.

[0117] Step 207: Receive a state switching command sent by the interface device.

[0118] The interface device can know the current life cycle state of the security chip. If the user needs to change the life cycle state of the security chip, the interface device can be triggered to send a state switching command to the security chip to instruct the security chip to change its life cycle state. Correspondingly, the security chip can receive the state switching command.

[0119] Optionally, the state switching command may be an APDU command. The message of the state switching command may include: a CLA field, an INS field, a Pl field, a P2 field, and an Lc field, but does not include a DATA field and a Le field. That is, the DATA field and the Le field do not exist in the message of the state switching command.

[0120] It is understandable that in the message of the state switching command for instructing the security chip to switch to any two different life cycle states, the field value of at least one field is different. For example, the field value of the P2 field in the message of the state switching command for instructing the life cycle state to switch from the initialization state to the release state is different from the field value of the P2 field in the message of the state switching command for instructing the life cycle state to switch from the release state to the termination state.

[0121] In addition, the security chip can switch the life cycle state from the uninitialized state to the initialized state in response to the initialization chip command sent by the interface device. It can be seen that the state switching command used to instruct the life cycle state of the security chip to switch from the uninitialized state to the initialized state is the initialization chip command. Among them, the initialization chip command is used to instruct the initialization of the data area of ​​the security chip, as well as the writing of basic chip information, chip type, and establishment of manufacturer keys. The content of the data area after initialization is 00H, and after the security chip is initialized, the initial value of the key is 8 bytes or 16 bytes 00H. H represents hexadecimal.

[0122] Table 2 shows the field values ​​of each field in the message of the chip initialization command. As can be seen from Table 2, in the message, the field value of the CLA field can be BF, the field value of the INS field can be FC, and the P1 field is used to indicate the size of the file system set when the chip is initialized, and to select the security algorithm mode. For example, the length of the field value of the P1 field can be 1 byte, bit0-bit3 in the 1 byte is used to set the size of the file system, and bit4-bit7 is used to select the security algorithm mode. The selection of the security algorithm mode refers to starting or shutting down the differential power analysis (DPA) mode. The P2 field is used to indicate the type of chip, and the field value of the P2 field can be 0 or 1, 0 represents an ordinary chip, and 1 represents a key chip. The field value of the Lc field is 00.

[0123] Table 2

[0124]

[0125]

[0126] Table 3 shows the field values ​​of each field in the message of the state switching command for indicating switching the life cycle state of the security chip to the release state or to the termination state. As can be seen from Table 3, the field value of the CLA field can be 00, the field value of the INS field can be F0, and the field value of the P1 field can be 00. The field value of the P2 field can be 01 or 02. Among them, 01 is used to indicate that the life cycle state is switched to the release state, and 02 is used to indicate that the life cycle state is switched to the termination state. The field value of the Lc field is 00.

[0127] Table 3

[0128]

[0129] It is understandable that after the life cycle of the security chip switches to the release state, some private instructions will not be allowed to be executed, and some public instructions require relevant permissions to be executed.

[0130] Step 208: In response to the state switching command, switch the life cycle state of the security chip from the first life cycle state to the second life cycle state.

[0131] In the embodiment of the present application, the switching of the four life cycle states of the security chip is unidirectional and irreversible. Therefore, the second life cycle state is located after the first life cycle state. For example, if the first life cycle state is an uninitialized state, the second life cycle state can be an initialized state. If the first life cycle state is an initialized state, the second life cycle state can be an issued state. If the first life cycle state is an issued state, the second life cycle state can be a terminated state.

[0132] Since the interface device can send a state switching command to the security chip to switch the life cycle state of the security chip, and since the security chip determines the processing result of the file operation command based on the first life cycle state, the method can change the processing result of the file operation command by changing the life cycle state of the security chip, thereby enriching the application methods of the security chip and providing application flexibility of the security chip.

[0133] The following is an exemplary description of the switching of the life cycle state of the security chip and the process of determining the processing result of the file operation command in different life cycle states:

[0134] Example 1: Successfully create MF when the security chip is in an uninitialized state

[0135] The interface device sends an initialization chip command "BFFCE60000" to the security chip. In response to the initialization chip command, the security chip sets the security algorithm selection mode, file system size, chip type, connects to the cryptographic device to establish the manufacturer key, and sets the security chip to the initial state, that is, switches the life cycle state of the security chip from the uninitialized state to the initial state.

[0136] Then, the interface device sends a file creation command "80E000000B3F00000019000018000000" to the security chip to instruct the creation of MF. In response to the file creation command, the security chip obtains that the first life cycle state of the security chip is the initial state. Therefore, it can be determined that there is no need to perform permission authentication on the interface device, and determines that the processing result of the file operation command is a response to the file creation command. After that, the security chip can create MF according to the command content of the file creation command. After the MF is successfully created, the security chip can return a success status to the interface device so that the interface device can proceed to the next step.

[0137] MF can manage the free space in the storage area of ​​the security chip for users. Users can create EF, SF and dedicated files (DF) in this space through interface devices. Among them, MF can be used as DDF, and can be entered from any application environment. MF is the entry point of the entire security chip. The DF can be DDF or ADF.

[0138] Example 2: The DDF, transparent file, and secure file are created successfully when the security chip is in the initialization state

[0139] The interface device sends a file creation command "80E000010D DF010d60220000000019000000" to the security chip. The file creation command is used to instruct the security chip to create a directory file DF01 of type DDF. In response to the file creation command, the security chip detects that the security chip is currently in the initial state, that is, it does not need to authenticate the interface device, so it can create the DDF directory file DF01 according to the command content of the file creation command.

[0140] After completing the creation of the directory file DF01, the interface device can send a "00A4000002DF01" command to the security chip. In response to the command, the security chip can select the DF01 directory file, and then create transparent files and security files under the directory file DF01. The process of creating a transparent file may include: the interface device sends a file creation command "80E000030D 00010022001010 112222110304" for instructing the creation of a transparent file 0001, and the security chip responds to the file creation command and creates a transparent file 0001 with a length of 22H in the storage area of ​​the directory file DF01.

[0141] After the transparent file is created, the security chip can also update the content of the transparent file in response to the file update command sent by the interface device, and read the content of the transparent file in response to the file read command sent by the interface device, and return the read data to the interface device. Specifically, the interface device can send a file update command "00d6000001 02" to the security chip, and the file update command is used to indicate that the data stored in the first byte of the transparent file 0001 is updated to 02. Accordingly, the security chip can update the data stored in the first byte of the transparent file 0001 to 02 in response to the file update command. The interface device sends a file read command "00b0000001". In response to the file read command, the security chip can read the data 02 stored in the first byte of the transparent file 0001 and return the data 02 to the interface device.

[0142] The process of creating a security file may include: the interface device sends a file creation command "80E0000508 0002005000112222" to the security chip. The file creation command is used to instruct the creation of a security file 0002. In response to the file creation command, the security chip can create a security file 0002 with a length of 50H in the storage area of ​​the directory file DF01. Afterwards, the interface device can send a file update command "84d4010020C79475DF1F5FF9EEADB46E44CE0709A9FF6CAB7E7968BFD1754CC447C1B289C6" for the security file 0002. The file update command is used to instruct the update of the first key of the security chip. In response to the file update command, the security chip can implement the update of the first key. And after the update is successful, the security chip can return a success status to the interface device so that the interface device can perform the next operation.

[0143] Example 3: The ADF is created successfully when the security chip is in the release state, but the linear fixed-length file fails

[0144] When the security chip is in the initial state, the interface device sends a file creation command "80E0000212AF01040000000000031104050F A000000001" to the security chip for instructing the creation of a file AF01 of type ADF. After receiving the file creation command, the security chip can create a file and set the file to AF01 file after the creation is completed, and then create a transparent file and a secure file under the AF01 file.

[0145] Then, the interface device sends a state switching command "00F0000100" for indicating the modification of the life cycle state of the chip. In response to the state switching command, the security chip switches the life cycle state from the initial state to the released state. Afterwards, the interface device sends a file creation command "80E000040F0003040301000 00110110000110102" for indicating the creation of a linear fixed-length file 0003. In response to the file creation command, the security chip detects that the current life cycle state is the released state, and then determines that the interface device needs to be authenticated first, and the file can be created only after the authentication is passed, so it is determined that the creation of the linear fixed-length file 0003 has failed. In addition, the security chip returns a state of authentication authority not being satisfied (i.e., there is no authority to perform file operations on the security chip) to the interface device to prompt the interface device to perform an authentication operation.

[0146] Example 4: Successfully create an ADF, a linear fixed-length file, and a security file when the security chip is in the release state

[0147] When the security chip is in the initial state, the interface device sends a file creation command "80E0000212AF02040000000000031 104050F A000000002" for instructing the creation of a file AF02 of type ADF. After receiving the file creation command, the security chip can create a file and set the file as an AF02 file after the creation is completed, and then create a transparent file and a secure file under the AF02 file.

[0148] Then, the security chip can switch the life cycle state from the initialization state to the issuance state in response to the state switching command "00F0000100" sent by the interface device. After that, the interface device starts to perform permission authentication. Specifically, the interface device sends a random number acquisition command "0084000008" to the security chip, and the security chip responds to the random number acquisition command and returns the internally obtained 8-byte random number to the interface device, so that the interface device can generate 8-byte authentication data based on the random number.

[0149] The interface device sends an external authentication command "0082000008+8byte authentication data" to the security chip. In response to the external authentication command, the security chip performs permission authentication on the interface device based on the 8byte authentication data to obtain the permission authentication result of the interface device. The specific permission authentication process may include: the security chip performs XOR on the 8byte random number and the 8byte target character "0xAA" to obtain 8byte reference data, and then splices the 8byte reference data to the existing 8byte authentication data to form a complete 16byte authentication data (i.e. intermediate data). Then, the security chip uses the authentication key to perform SM1-ECB encryption calculation on the 16byte authentication data to obtain 16byte ciphertext data, and then performs XOR on the first 8byte ciphertext sub-data and the last 8byte ciphertext sub-data in the 16byte ciphertext data to obtain 8byte ciphertext data (i.e. the third ciphertext sub-data), and then XORs the 8byte ciphertext data obtained by XOR with the 8byte "0xAA" to obtain the final 8byte authentication data (i.e. verification data). Afterwards, the security chip can compare the authentication data sent by the receiving device with the 8-byte authentication data calculated by itself, and after confirming that the two are the same, it determines that the receiving device has passed the authority authentication, and then the subsequent process of creating, updating and reading files can be carried out.

[0150] The process of creating, updating and reading the linear fixed-length file 0003 may include: the interface device sends a file creation command "80E000040F000304030100000110110000110102" to the security chip to instruct the creation of the linear fixed-length file 0003. After receiving the command, the security chip detects that the interface device has the authority to create the file, and then successfully creates the linear fixed-length file 0003 with a length of 04H in the storage area of ​​the file AF02. After the linear fixed-length file 0003 is successfully created, the interface device sends a file update command "00dc00010411223344" to the security chip to instruct the update of the linear fixed-length file. Since the interface device has the operation authority, the security chip responds to the file update command and can directly update the first record of the linear fixed-length file 0003 to 11223344.

[0151] The interface device sends a file read command "00b2000104" to the security chip to instruct the reading of the linear fixed-length file 0003. Since the interface device has the operation authority, the security chip responds to the file read command and can directly read the first record 11223344 of the linear fixed-length file 0003 and return the record to the interface device.

[0152] The process of creating and updating the security file 0004 may include: the interface device sends a file creation command "80E0000508 0004010000112222" to the security chip for instructing the creation of the security file 0004. Since the interface device has the operation authority, the security chip responds to the file creation command and creates a security file 0004 with a length of 100H in the file AF02 storage area. After the security file 0004 is successfully created, the interface device sends a file update command "84d4020020129475CE1F5DF9EFA DB46744CE0709A9346CAB7E79685FC175433447C1C289C6". The file update command is used to instruct the update of the security file 0004. Since the interface device has the operation authority, the security chip responds to the file update command and can directly update the second key of the security file 0004 to the corresponding data. Furthermore, after the operation is successful, the security chip can return a success status to the interface device so that the interface device can perform the next operation.

[0153] Example 5: Failed to create ADF, linear fixed-length file, or secure file when the security chip is in the terminated state

[0154] When the security chip is in the issuing state, the interface device sends a state switching command "00F0000200" to the security chip. In response to the state switching command, the security chip switches the life cycle state from the issuing state to the terminating state. Then, the interface device sends a file creation command "80E0000212AF02040000000000031 104050F A000000002" to instruct the creation of a file AF02 of type ADF. The security chip receives the file creation command, checks that it is currently in the terminating state, and returns a message to the interface device indicating that the file creation failed.

[0155] The interface device performs permission authentication. After successful authentication, it attempts to re-execute the creation of file AF02 and sends the file creation command "80E0000212AF02040000000000031104050FA000000002". The security chip receives the file creation command, checks that it is currently in the terminated state, and returns a message that the file creation failed.

[0156] The interface device attempts to send a file creation command to create a linear fixed-length file or a security file. The security chip receives the file creation command, checks that the current life cycle state of the security chip is terminated, and then returns a message that the file creation failed.

[0157] According to the description of Examples 1 to 5 above, when the current life cycle state of the security chip is the uninitialized state, the security chip is first initialized to switch the life cycle state of the security chip to the initial state. When the security chip is in the initial state, no permission is required to create files, read, write, etc. on the security chip. Then, according to security needs, the user can trigger the interface device to send a state switching command to switch the life cycle state of the security chip to the released state.

[0158] When the security chip is in the release state, the corresponding permissions are required to execute file operation commands. In other words, the security chip will implement strict permission control on the interface devices at this time. Only authorized interface devices can perform security operations such as creating files, reading, and writing in the security chip. When the security chip is in the termination state, no operations such as creating files, reading, and writing are allowed, regardless of authorization or not.

[0159] By adopting the above method of selecting corresponding commands according to the life cycle status of the chip and performing corresponding authority control to perform file operations in the security chip, safe creation and safe use of files in the security chip can be achieved.

[0160] It is understandable that the order of the steps of the file operation method of the security chip provided in the embodiment of the present application can be appropriately adjusted, and the steps can also be increased or decreased accordingly according to the situation. For example, step 207 and step 208 can also be deleted according to the situation. Any technician familiar with the technical field can easily think of a method of change within the technical scope disclosed in this application, which should be included in the protection scope of this application, so it will not be repeated.

[0161] In summary, the embodiment of the present application provides a file operation method for a security chip. After receiving the file operation command sent by the interface device, the method can obtain the current first life cycle state of the security chip, and determine the processing result of the file operation command based on the first life cycle state. The processing result is to respond to the file operation command or to prohibit responding to the file operation command. Since the method divides the life cycle state of the security chip and decides whether to respond to the file operation command based on the life cycle state of the security chip, that is, the file operation in the security chip is finely controlled according to the first life cycle state, compared with the method of directly responding to the file operation command in the related art, this method can improve the security of the file operation in the security chip to a certain extent, thereby improving the security of the security chip.

[0162] The present application embodiment provides a security chip, see Figure 4 The security chip 300 includes a processor 301. The processor 301 is used to:

[0163] Receiving file operation commands sent by the interface device;

[0164] In response to the file operation command, obtaining a current first life cycle state of the security chip;

[0165] Based on the first life cycle state, a processing result of the file operation command is determined, where the processing result includes: one of responding to the file operation command and prohibiting responding to the file operation command.

[0166] Optionally, the first life cycle state is one of: an uninitialized state, an initialized state, a released state, and a terminated state. The process of the processor 301 determining the processing result of the file operation command based on the first life cycle state may include:

[0167] If the first life cycle state is an uninitialized state or a terminated state, it is determined that the processing result of the file operation command is that a response to the file operation command is prohibited.

[0168] Optionally, the processor 301 may also be used for:

[0169] After determining that the first life cycle state is an uninitialized state, a prompt message is issued, the prompt message is used to prompt that the security chip is currently in an uninitialized state, and if a file operation is required on the security chip, the life cycle state of the security chip is switched from the uninitialized state to the initialized state.

[0170] Optionally, the first life cycle state is one of: an uninitialized state, an initialized state, a released state, and a terminated state. The process of the processor 301 determining the processing result of the file operation command based on the first life cycle state may include:

[0171] If the first life cycle state is neither an uninitialized state nor a terminated state, determining based on the first life cycle state, if permission authentication of the interface device is required, determining a processing result of the file operation command based on a permission authentication result of the interface device;

[0172] If the first life cycle state is neither an uninitialized state nor a terminated state, determining based on the first life cycle state that the processing result of the file operation command is a response to the file operation command without performing authority authentication on the interface device;

[0173] The result of the authority authentication includes: having the operation authority and not having the operation authority.

[0174] Optionally, the process of the processor 301 determining the processing result of the file operation command based on the authority authentication result of the interface device may include:

[0175] If the authority authentication result of the interface device is that it has the operation authority, determining the processing result of the file operation command is a response to the file operation command;

[0176] If the authority authentication result of the interface device is that the interface device does not have the operation authority, the processing result of the file operation command is determined to be that the response to the file operation command is prohibited.

[0177] Optionally, the processor 301 may also be used for:

[0178] Before determining the processing result of the file operation command, if the first life cycle state is the issuing state, it is determined that the interface device needs to be authenticated; if the first life cycle state is the initializing state, it is determined that the interface device does not need to be authenticated.

[0179] Optionally, the first life cycle state is the release state. The processor 301 may also be used for:

[0180] Before determining the processing result of the file operation command based on the authority authentication result of the interface device, receiving authentication data having a first length sent by the interface device;

[0181] Based on the authentication data and the reference data of the first length, the intermediate data of the second length is concatenated, wherein the second length is twice the first length, and the reference data is obtained by performing an XOR operation on the random number and the target character, and the lengths of the random number and the target character are both the first length;

[0182] Encrypting the intermediate data to obtain ciphertext data having a second length;

[0183] Performing an XOR operation on the first ciphertext sub-data and the second ciphertext sub-data in the ciphertext data to obtain the third ciphertext sub-data, wherein the length of the first ciphertext sub-data and the length of the second ciphertext sub-data are both the first length, and the position of the first ciphertext sub-data in the ciphertext data has no intersection with the position of the second ciphertext sub-data in the ciphertext data;

[0184] XOR the third ciphertext sub-data with the target character to obtain verification data;

[0185] If the verification data is the same as the authentication data, then the authority authentication result of the interface device is determined to have the operation authority;

[0186] If the verification data is different from the authentication data, it is determined that the authority authentication result of the interface device is that the interface device does not have the operation authority.

[0187] Optionally, the process in which the processor 301 encrypts the intermediate data to obtain ciphertext data having a second length may include:

[0188] The national secret SM1 algorithm is used to encrypt the intermediate data to obtain ciphertext data with a length of the second length.

[0189] Optionally, the processor 301 may also be used for:

[0190] Receiving a state switching command sent by an interface device;

[0191] In response to the state switching command, the life cycle state of the security chip is switched from the first life cycle state to the second life cycle state.

[0192] In summary, an embodiment of the present application provides a security chip, which, after receiving a file operation command sent by an interface device, can obtain the current first life cycle state of the security chip, and determine the processing result of the file operation command based on the first life cycle state. The processing result is to respond to the file operation command or to prohibit responding to the file operation command. Since the life cycle state can be divided for the security chip, and whether to respond to the file operation command can be determined based on the life cycle state of the security chip, that is, the file operation in the security chip is finely controlled according to the first life cycle state, compared with the method of directly responding to the file operation command in the related art, the security of the file operation in the security chip can be improved to a certain extent, thereby improving the security of the security chip.

[0193] Please continue to see Figure 4 , the security chip 300 may also include: a memory 303. The processor 301 is connected to the memory 303, such as through a bus 302. The processor 301 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor 301 may also be a combination that implements a computing function, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.

[0194] The bus 302 may include a path to transmit information between the above components. The bus 302 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 302 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 4 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.

[0195] The memory 303 is used to store a computer program corresponding to the file operation method of the security chip of the above embodiment of the present application, and the computer program is controlled and executed by the processor 301. The processor 301 is used to execute the computer program stored in the memory 303 to implement the content shown in the above method embodiment.

[0196] The present application embodiment provides a computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the file operation method of the security chip provided in the above method embodiment can be implemented. For example, Figure 1 or Figure 2 The method shown.

[0197] The embodiment of the present application further provides an electronic device, which may include the security chip provided by the above device embodiment. Optionally, the electronic device may be a terminal device in a power grid.

[0198] It should be noted that the logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be specifically implemented in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purposes of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection portion with one or more wirings (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.

[0199] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0200] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.

[0201] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0202] In this application, unless otherwise clearly specified and limited, the terms "installed", "connected", "connected", "fixed" and the like should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection or an indirect connection through an intermediate medium, it can be the internal connection of two elements or the interaction relationship between two elements, unless otherwise clearly defined. For ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to specific circumstances.

[0203] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A file operation method for a security chip, characterized in that: The method comprises: Receiving file operation commands sent by the interface device; In response to the file operation command, obtaining a current first life cycle state of the security chip; Based on the first life cycle state, a processing result of the file operation command is determined, where the processing result includes: one of responding to the file operation command and prohibiting responding to the file operation command.

2. The method according to claim 1, characterized in that The first life cycle state is one of an uninitialized state, an initialized state, a released state, and a terminated state; and based on the first life cycle state, determining a processing result of the file operation command includes: If the first life cycle state is the uninitialized state or the terminated state, it is determined that the processing result of the file operation command is that responding to the file operation command is prohibited.

3. The method according to claim 2, characterized in that After determining that the first life cycle state is an uninitialized state, the method further includes: A prompt message is issued, wherein the prompt message is used to prompt that the security chip is currently in the uninitialized state, and if a file operation is required on the security chip, the life cycle state of the security chip is switched from the uninitialized state to the initialized state.

4. The method according to claim 1, characterized in that: The first life cycle state is one of an uninitialized state, an initialized state, a released state, and a terminated state; and based on the first life cycle state, determining a processing result of the file operation command includes: If the first life cycle state is neither the uninitialized state nor the terminated state, determining based on the first life cycle state, in the case where permission authentication of the interface device is required, determining a processing result of the file operation command based on a permission authentication result of the interface device; If the first life cycle state is neither the uninitialized state nor the terminated state, determining based on the first life cycle state that, without performing authority authentication on the interface device, the processing result of the file operation command is a response to the file operation command; The authority authentication result includes: having the operation authority and not having the operation authority.

5. The method according to claim 4, characterized in that Determining a processing result of the file operation command based on the authority authentication result of the interface device includes: If the authority authentication result of the interface device is that it has the operation authority, determining the processing result of the file operation command is to respond to the file operation command; If the authority authentication result of the interface device is that the interface device does not have the operation authority, then the processing result of the file operation command is determined to be that the response to the file operation command is prohibited.

6. The method according to claim 4, characterized in that Before determining the processing result of the file operation command, the method further includes: If the first life cycle state is the issued state, determining that the interface device needs to be authenticated; If the first life cycle state is the initialization state, it is determined that there is no need to perform authority authentication on the interface device.

7. The method according to claim 4, characterized in that The first life cycle state is a release state; before determining the processing result of the file operation command based on the authority authentication result of the interface device, the method further includes: Receiving authentication data having a first length sent by the interface device; Based on the authentication data and the reference data having the first length, splicing to obtain intermediate data having a second length, wherein the second length is twice the first length, the reference data is obtained by performing an XOR operation on a random number and a target character, and the lengths of the random number and the target character are both the first length; Encrypting the intermediate data to obtain ciphertext data having a length of the second length; performing an XOR operation on the first ciphertext sub-data and the second ciphertext sub-data in the ciphertext data to obtain the third ciphertext sub-data, wherein the length of the first ciphertext sub-data and the length of the second ciphertext sub-data are both the first length, and the position of the first ciphertext sub-data in the ciphertext data has no intersection with the position of the second ciphertext sub-data in the ciphertext data; Performing an XOR operation on the third ciphertext sub-data and the target character to obtain verification data; If the verification data is the same as the authentication data, determining that the authority authentication result of the interface device is having the operation authority; If the verification data is different from the authentication data, it is determined that the authority authentication result of the interface device is that the interface device does not have the operation authority.

8. The method according to claim 7, characterized in that Encrypting the intermediate data to obtain ciphertext data having a length of the second length includes: The intermediate data is encrypted using the national encryption SM1 algorithm to obtain ciphertext data having a length of the second length.

9. The method according to any one of claims 1 to 8, characterized in that: The method further comprises: Receiving a state switching command sent by the interface device; In response to the state switching command, the life cycle state of the security chip is switched from the first life cycle state to a second life cycle state.

10. A security chip, characterized in that: The security chip includes: a processor, and the processor is used for: Receiving file operation commands sent by the interface device; In response to the file operation command, obtaining a current first life cycle state of the security chip; Based on the first life cycle state, a processing result of the file operation command is determined, where the processing result includes: one of responding to the file operation command and prohibiting responding to the file operation command.

11. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 9 is implemented.