Method and device for preventing mistaken erasing and writing of SIM card and storage medium

By obtaining and storing the keys in the SIM card and decrypting the esque instruction ciphertext, we ensure that the key and plaintext exist only when executed in the correct order, solving the risk of the SIM card being erroneously when the program runs away, and improving data security and errone reliability.

CN120111487APending Publication Date: 2025-06-06CHINA MOBILE M2M +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510231051.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-02-28
Publication Date
2025-06-06

AI Technical Summary

Technical Problem

In the case of running programs, SIM cards still have the risk of being erroneously erected, resulting in irreversible damage to the data.

Method used

By obtaining the key and storing, obtaining the erotic instruction ciphertext from the preset address, decrypting the ciphertext using the key, obtaining the plaintext instructions and executing it, ensuring that the key and plaintext will exist briefly only when it is fully executed in the correct order.

Benefits of technology

It effectively prevents the SIM card data from being erroneously erroneous when the program runs away, and improves the security and reliability of SIM card data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120111487A_ABST
    Figure CN120111487A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of SIM card data processing, and provides an SIM card error erasing prevention method and device and a storage medium, and the method comprises the steps: responding to an erasing command, obtaining a secret key, and storing the secret key; obtaining an erasing instruction ciphertext from a first preset address; decrypting the erasing instruction ciphertext according to the key to obtain an erasing instruction plaintext; deleting the key; executing the erasing instruction plaintext; and determining that the erasing instruction plaintext is executed completely, and deleting the erasing instruction plaintext. The erasing instruction is hidden, the erasing instruction plaintext can be obtained only by decrypting the erasing instruction ciphertext through the secret key, data of the SIM card cannot be erased due to lack of the erasing instruction plaintext even if a program runs away, and the secret key and the erasing instruction plaintext adopt a ready-to-use and ready-to-delete strategy to avoid long-term existence of the secret key and the erasing instruction plaintext. And the erasing operation of the SIM card is protected from the angles of space and time, so that the erasing is more reliable, and the data security is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of SIM card data processing, and in particular to a method, a device and a storage medium for preventing a SIM card from being accidentally erased. Background Art

[0002] As a carrier of user identity in mobile communications, the SIM card stores the user's unique identification code and network authentication key, provides authentication services for mobile devices to access the network, and is the identity authorization for users to access cellular connections. The key authentication data of the SIM card and user and service data are stored in the non-volatile memory in the card, such as ROM, EEPROM, and Flash. Due to the importance of SIM card data and the erasability of non-volatile memory, once the card data is mistakenly deleted or destroyed due to unexpected factors such as software defects and external interference, it will cause irreversible damage to the card itself, thereby affecting the normal operation of the terminal equipment.

[0003] In the prior art, in order to ensure the reliability of data erasure in SIM cards, there are mainly two data erasure protection methods: pure software and a combination of software and hardware. The pure software method ensures the reliability of data erasure by setting the software switch state. However, in the pure software method, when the program runs away, that is, when the program execution order is disordered, the runaway program may mistakenly modify the switch state, or skip the switch state check and directly execute the data erasure step, resulting in the SIM card still being mistakenly erased. The combination of software and hardware solution adds hardware circuits and software to improve the ability to prevent mistaken erasure. A hardware switch is set on the basis of the software switch, and it can be normally erased only after unlocking with the correct key value sequence. However, after adding the hardware circuit, although it can effectively reduce the risk of the program being interfered with and running away, it will increase the hardware cost, and when the program runs away, there may still be a situation where the erase operation is mistakenly unlocked.

[0004] Therefore, in the event of a program failure, how to ensure the reliability of SIM card data erasure is an urgent problem to be solved. Summary of the invention

[0005] The invention provides a method, a device and a storage medium for preventing a SIM card from being accidentally erased, so as to solve the defect in the prior art that a SIM card has the risk of being accidentally erased when a program runs away.

[0006] The present invention provides a method for preventing accidental erasure of a SIM card, comprising: In response to an erase command, obtaining a key and storing the key; Obtaining a ciphertext of an erase instruction from a first preset address; Decrypt the erase instruction ciphertext according to the key to obtain the erase instruction plaintext; deleting the key; Execute the erase instruction plaintext; Determine that the erase instruction plaintext has been executed, and delete the erase instruction plaintext.

[0007] According to a method for preventing accidental erasure of a SIM card provided by the present invention, in response to an erase command, obtaining a key and storing the key comprises: In response to an erase command, obtaining a command code according to a frame format of the erase command; The command code is used as the key and stored in a second preset address.

[0008] According to a method for preventing accidental erasure of a SIM card provided by the present invention, decrypting the ciphertext of the erasure instruction according to the key to obtain the plaintext of the erasure instruction includes: According to the key, based on a symmetric encryption algorithm, the erase instruction ciphertext is processed to obtain the erase instruction plaintext; Wherein, the erase instruction ciphertext is generated based on the same symmetric encryption algorithm.

[0009] According to a method for preventing accidental erasure of a SIM card provided by the present invention, decrypting the ciphertext of the erasure instruction according to the key to obtain the plaintext of the erasure instruction includes: Performing XOR processing on the key and the erase instruction ciphertext to obtain the erase instruction plaintext; The erase instruction ciphertext is generated by performing XOR processing on the key and the erase instruction plaintext.

[0010] According to a method for preventing accidental erasure of a SIM card provided by the present invention, in response to an erase command, obtaining a key and storing the key comprises: In response to the erase command, checking the operating parameters; When it is determined that the operating parameter meets the preset condition, obtaining the key from the erase command and storing the key at a second preset address; When it is determined that the operating parameters do not meet the preset conditions, the erase process is stopped and a preset software trap is triggered.

[0011] The present invention also provides a method for preventing accidental erasure and burning of a SIM card, comprising: Get keys and program data; Use the key to encrypt the erase instruction plaintext to obtain the erase instruction ciphertext; Burning the erase instruction ciphertext and the program data to the SIM card; Wherein, when the program data is executed, the above-mentioned method for preventing accidental erasure of a SIM card can be implemented.

[0012] According to a method for preventing accidental erasure and burning of a SIM card provided by the present invention, part of the data in the program data that implements the method for preventing accidental erasure and burning of a SIM card is in assembly format.

[0013] The present invention also provides a SIM card, comprising a microprocessor, a FLASH memory and a memory, wherein the FLASH memory stores program data, and when the program data is executed by the microprocessor, the above-mentioned method for preventing accidental erasure of a SIM card is implemented.

[0014] The present invention also provides an electronic device, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, a method for preventing accidental erasure and burning of a SIM card as described above is implemented.

[0015] The present invention also provides a non-transitory computer-readable storage medium on which a computer program is stored. When the computer program is executed by a processor, the method for preventing accidental erasure and burning of a SIM card as described in any one of the above is implemented.

[0016] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the method for preventing accidental erasure and burning of a SIM card as described above is implemented.

[0017] The present invention provides a method, device and storage medium for preventing accidental erasure of a SIM card, which at least has a beneficial effect: in response to an erase instruction, that is, when an erase operation is required, a key is obtained and stored, an erase instruction ciphertext is obtained from a first preset address, and the erase instruction ciphertext is decrypted using the key to obtain the erase instruction plaintext, and then the erase instruction plaintext is executed to perform an erase operation. The erase instruction ciphertext cannot be executed directly, that is, there is no program instruction in the SIM card that is directly executed to implement the erase operation. It is necessary to obtain the key and decrypt it, and the erase instruction plaintext can be obtained before the erase operation can be implemented, so as to achieve the effect of hiding the erase instruction. Even in the state where the program runs away, the data will not be erased because there is no erase instruction plaintext. In addition, after decrypting and obtaining the erase instruction plaintext, the stored key will be deleted, and after the erase instruction plaintext is executed, the erase instruction plaintext will also be deleted, that is, the key and the erase instruction plaintext adopt a use-and-delete strategy, so that only when they are completely executed in the correct order, the key and the erase instruction plaintext will exist temporarily, avoiding the long-term existence of the key and the erase instruction plaintext. In this way, the erase instruction is hidden from a spatial perspective. Only by decrypting the erase instruction ciphertext with a key can the erase instruction plaintext be temporarily obtained. Even if the program runs away, the data on the SIM card cannot be erased due to the lack of the erase instruction plaintext. From a temporal perspective, a use-and-delete strategy is adopted for the key and the erase instruction plaintext to avoid the long-term existence of the key and the erase instruction plaintext. The erase operation of the SIM card is protected from the perspectives of space and time, making the erase of the SIM card more reliable and improving the security of the SIM card data. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 The present invention is a flowchart of a method for preventing accidental erasure of a SIM card.

[0020] Figure 2 The present invention is a schematic diagram of the execution process of one embodiment of a method for preventing accidental erasure of a SIM card provided by the present invention.

[0021] Figure 3 The present invention provides a schematic diagram of a frame format of an erase command in one embodiment of a method for preventing accidental erase of a SIM card.

[0022] Figure 4 It is a structural schematic diagram of the electronic device provided by the present invention.

[0023] Reference numerals: DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] The SIM card has a built-in COS (Chip Operating System). When the data in the SIM card needs to be erased or written in the terminal, such as a mobile phone or tablet computer, the COS of the SIM card needs to call the erase instruction to execute the erase program to erase the data. The data erase protection method of pure software and the combination of software and hardware. Before calling the erase instruction, COS will first verify the conditions such as software switch to ensure the security of the erase operation. Program runaway means that the execution process deviates from the expected track due to abnormal reasons such as logic errors, memory leaks, pointer errors, stack overflows, interference, etc. during the program running. In the case of program runaway, the SIM card COS may skip the verification steps such as software switch and directly jump to the step of executing the erase instruction, resulting in the wrong execution of the data erase operation.

[0026] In order to avoid accidental erasure of SIM card data, the following Figure 1 and Figure 2 A method for preventing accidental erasure of a SIM card of the present invention is described, comprising: S100: In response to an erase command, obtaining a key and storing the key; S200: Obtaining a ciphertext of an erase instruction from a first preset address; S300: decrypting the erase instruction ciphertext according to the key to obtain the erase instruction plaintext; S400: deleting the key; S500: Execute the erase instruction plain text; S600: Determine that the execution of the erase instruction plain text is complete, and delete the erase instruction plain text.

[0027] In response to the erase instruction, that is, when an erase operation is required, the key is obtained and stored, the erase instruction ciphertext is obtained from the first preset address, the erase instruction ciphertext is decrypted using the key, the erase instruction plaintext is obtained, and then the erase instruction plaintext is executed to perform the erase operation. The erase instruction ciphertext cannot be executed directly, that is, there is no program instruction in the SIM card that can be directly executed to implement the erase operation. It is necessary to obtain the key and decrypt it, and the erase instruction plaintext can be obtained before the erase operation can be implemented, so as to achieve the effect of hiding the erase instruction. Even in the state where the program runs away, the data will not be erased because there is no erase instruction plaintext. In addition, after decrypting and obtaining the erase instruction plaintext, the stored key will be deleted, and after the execution of the erase instruction plaintext is completed, the erase instruction plaintext will also be deleted, that is, the key and the erase instruction plaintext adopt a use-and-delete strategy, so that only when they are fully executed in the correct order will the key and the erase instruction plaintext exist for a short time, avoiding the long-term existence of the key and the erase instruction plaintext.

[0028] In this way, the erase instruction is hidden from a spatial perspective. Only by decrypting the erase instruction ciphertext with a key can the erase instruction plaintext be temporarily obtained. Even if the program runs away, the data on the SIM card cannot be erased due to the lack of the erase instruction plaintext. From a temporal perspective, a use-and-delete strategy is adopted for the key and the erase instruction plaintext to avoid the long-term existence of the key and the erase instruction plaintext. The erase operation of the SIM card is protected from the perspectives of space and time, making the erase of the SIM card more reliable and improving the security of the SIM card data.

[0029] It is understandable that the method for preventing accidental erasure of a SIM card provided by the present invention is applied to a SIM card, that is, implemented in a SIM card. The applied SIM card may be a Native SIM card, which uses native COS and is solidified at the time of leaving the factory. It cannot be expanded through subsequent development interfaces and does not have open secondary development capabilities, and has high security and stability.

[0030] When the COS of the SIM card responds to the erase command of the terminal to execute the erase program, it will execute in sequence according to the stored program instructions. By encrypting the erase instruction plain text, the erase instruction cipher text is stored in the SIM card, and the erase program is directly executed. In the absence of the key, the erase instruction cipher text cannot be correctly decrypted to obtain the erase instruction plain text, and the data of the SIM card cannot be erased. Therefore, in the absence of the erase command of the mobile phone or other terminal, the COS program will run away. Even if the erase program is executed in sequence and completely, due to the lack of the key, there will be no problem of mistakenly erasing data.

[0031] It is understandable that the erase instruction and the erase instruction plaintext are essentially the same. The erase instruction plaintext is used to facilitate the distinction between the erase instruction ciphertext formed by encryption and to facilitate the understanding of the scheme. The erase instruction ciphertext cannot be executed directly, and the erase instruction ciphertext formed by encryption should not belong to the instructions in the COS instruction set. Only by decrypting the erase instruction plaintext and executing the erase instruction plaintext can data be erased.

[0032] It should be noted that the process of encrypting the erase instruction plain text to form the erase instruction cipher text is not executed in the SIM card. Usually, the erase instruction cipher text is encrypted by other devices and then burned into the SIM card.

[0033] refer to Figures 1 to 3 In some embodiments of the method for preventing accidental erasure of a SIM card of the present invention, the S100 includes: In response to an erase command, obtaining a command code according to a frame format of the erase command; The command code is used as the key and stored in a second preset address.

[0034] In response to the erase command of the terminal, based on the frame format of the erase command, a command code is obtained from the erase command as a key, and the command code, that is, the key is stored at a second preset address. In this way, the key is obtained from the erase command without the terminal sending additional key data, and the terminal side does not need to change the process of erasing the SIM card, which is conducive to improving execution efficiency and improving compatibility with terminals.

[0035] The erase and write commands sent by the terminal to the SIM card usually meet the specific communication protocol and have the corresponding command frame format, such as APDU (Application Protocol Data Unit) command, refer to Figure 3 , the corresponding command frame header includes 1 byte of CLA, 1 byte of INS (command code), 1 byte of P1 and 1 byte of P2. Based on the frame format of the erase command, the unchanged command parameters, such as the command code INS corresponding to the erase operation, are obtained as the key, without the need for the terminal to transmit additional key data, thereby improving execution efficiency. It is understandable that, depending on the specific implementation, other unchanged command parameters can be selected as the key according to the frame format of the erase command.

[0036] It is understandable that the command code is stored at the second preset address, and subsequently S400 deletes the command code, ie, the key, from the second preset address.

[0037] In some embodiments of the present invention, the key may also be sent by the terminal in addition to sending the erase command.

[0038] The first preset address and the second preset address are storage addresses in the SIM card, which can be in the format of absolute address, relative address, etc. The first preset address corresponds to the storage of the erase instruction ciphertext. Since the erase instruction ciphertext is formed by encrypting the erase instruction plaintext in advance, the erase instruction ciphertext needs to be stored for a long time for easy reading and decryption. Therefore, the first preset address is the memory address; the second preset address is used to temporarily store the key, and the second preset address can be a memory address or a memory address.

[0039] In some embodiments of the method for preventing accidental erasure of a SIM card of the present invention, the step S300 includes: According to the key, based on a symmetric encryption algorithm, the erase instruction ciphertext is processed to obtain the erase instruction plaintext; Wherein, the erase instruction ciphertext is generated based on the same symmetric encryption algorithm.

[0040] The erase instruction ciphertext is generated by encrypting the erase instruction with a symmetric encryption algorithm. In the COS program of the SIM card, the erase instruction ciphertext is decrypted with the same symmetric encryption algorithm to obtain the erase instruction ciphertext. The symmetric encryption algorithm has the advantages of fast operation speed, simple processing and strong versatility, which is conducive to improving the efficiency of decrypting the erase instruction ciphertext.

[0041] It should be noted that the purpose of encrypting the plaintext of the erase instruction in the present invention is mainly to hide the erase instruction rather than to improve the data security of the erase instruction itself. Therefore, an efficient and concise encryption algorithm, such as a symmetric encryption algorithm, is adopted to improve the program execution efficiency while meeting the requirements.

[0042] In some embodiments of the method for preventing accidental erasure of a SIM card of the present invention, the step S300 includes: Performing XOR processing on the key and the erase instruction ciphertext to obtain the erase instruction plaintext; The erase instruction ciphertext is generated by performing XOR processing on the key and the erase instruction plaintext.

[0043] The key is used to perform XOR processing on the erase instruction plaintext to generate the erase instruction ciphertext, and the same key is used to perform XOR processing on the erase instruction ciphertext to obtain the erase instruction plaintext. Using XOR processing as the encryption and decryption algorithm is conducive to simplifying the program executed by the SIM card COS, making the program processing efficient and concise.

[0044] refer to Figure 2 In some embodiments of the method for preventing accidental erasure of a SIM card of the present invention, the S100 includes: In response to the erase command, checking the operating parameters; When it is determined that the operating parameter meets the preset condition, obtaining the key from the erase command and storing the key at a second preset address; When it is determined that the operating parameters do not meet the preset conditions, the erase process is stopped and a preset software trap is triggered.

[0045] After responding to the erase command, first check whether the program's operating parameters meet the preset conditions. Meeting the preset conditions means that the erase operation can be reliably executed. Therefore, the key is obtained from the erase command and stored in the second preset address, so that the key can be used to decrypt the erase instruction ciphertext in the future, and the erase instruction plaintext is obtained to implement the erase operation. On the contrary, when the operating parameters do not meet the preset conditions, it means that there is a risk in the erase operation, and the data cannot be erased accurately and reliably, so the erase process is stopped and the software trap is triggered. In this way, after responding to the erase command, it is determined whether the operating parameters meet the preset conditions, thereby ensuring the reliable execution of the erase operation, and further improving the reliability and security of SIM card erasure.

[0046] Software traps are built-in security and exception handling mechanisms that protect the data and functions in the SIM card from being illegally accessed or destroyed, ensuring that timely measures can be taken to maintain the security and stability of the COS program when encountering abnormal operations.

[0047] In some embodiments of the present invention, the preset condition may include at least one of an erase address condition, an erase state condition, and an erase count condition, and the operating parameters include a target address required to be erased by the erase command, a current erase state, a current erase count, and the like. The erase address condition is specifically: the target address required to be erased by the erase command in the operating parameters is located in the preset allowed erase address; the erase address condition makes it impossible to perform an erase operation on data outside the preset allowed erase address, thereby preventing illegal erase operations from modifying important data in the SIM card. The erase state condition is specifically: the current erase state is in the allowed state; the erase state condition makes it possible to perform an erase operation only in the erase allowed state, thereby avoiding accidental erasure of data on the SIM card. The erase count condition is specifically: the current erase count is less than or equal to the expected erase count; the erase count condition makes it possible to erase the data in the SIM card within the expected erase count, thereby avoiding accidental additional erase operations. Meeting the erase address condition, the erase state condition, and the erase count condition can make the erase operation more reliable.

[0048] In some embodiments of the present invention, when it is determined that the operating parameters meet the preset conditions, the key is obtained from the erase command and the key is stored in a second preset address. Specifically, the command code can be obtained according to the frame format of the erase command, the command code is used as the key, and the command code is stored in the second preset address.

[0049] A method for preventing accidental erasure and burning of a SIM card provided by the present invention is introduced below. The method for preventing accidental erasure and burning of a SIM card described below can be referred to in correspondence with the above-mentioned method for preventing accidental erasure and burning of a SIM card.

[0050] The present invention also provides a method for preventing accidental erasure and burning of a SIM card, comprising: Get keys and program data; Use the key to encrypt the erase instruction plaintext to obtain the erase instruction ciphertext; Burning the erase instruction ciphertext and the program data to the SIM card; Wherein, when the program data is executed, the above-mentioned method for preventing accidental erasure of a SIM card can be implemented.

[0051] Obtain a key to encrypt the erase instruction plaintext to form an erase instruction ciphertext, and then burn the erase instruction ciphertext and program data into the SIM card. When the SIM card receives an erase command later, the SIM card COS program responds to the erase instruction to obtain the key and store the key, obtains the erase instruction ciphertext from the first preset address, uses the key to decrypt the erase instruction ciphertext, obtains the erase instruction plaintext, and then executes the erase instruction plaintext to perform an erase operation. After decrypting and obtaining the erase instruction plaintext, the SIM card COS program deletes the stored key, and after executing the erase instruction plaintext, deletes the erase instruction plaintext, that is, the key and the erase instruction plaintext adopt a use-and-delete strategy, so that the key and the erase instruction plaintext will only exist temporarily if they are executed completely in the correct order, avoiding the long-term existence of the key and the erase instruction plaintext.

[0052] In this way, the erase instruction is hidden in the SIM card from a spatial perspective. Only by decrypting the erase instruction ciphertext with a key can the erase instruction plaintext be temporarily obtained. Even if the program runs away, the data on the SIM card cannot be erased due to the lack of the erase instruction plaintext. From a temporal perspective, a use-and-delete strategy is adopted for the key and the erase instruction plaintext to avoid the long-term existence of the key and the erase instruction plaintext. The erase operation of the SIM card is protected from the perspectives of space and time, making the erase of the SIM card more reliable and improving the security of the SIM card data.

[0053] It is understandable that the program data burned into the SIM card includes not only part of the data for implementing the above-mentioned method for preventing accidental erasure of the SIM card, but also other data including COS and related business programs. On the basis of realizing the basic functions of the SIM card, the erasure function of the SIM card is improved. By implementing the method for preventing accidental erasure of the SIM card provided by the present invention, even if the program runs away, the SIM card can be protected from accidental erasure, so as to make the erasure of the SIM card more reliable and improve the security of the SIM card data.

[0054] In some embodiments of the present invention, the SIM card includes a FLASH memory, and the command ciphertext and program data are burned into the FLASH, wherein the command ciphertext is located at a first preset address, and the program data is located at a set burning address.

[0055] The invention provides a method for preventing accidental erasure and burning of a SIM card, which can be applied to devices or systems such as computers, single-chip computer systems, and SIM card burning devices.

[0056] In some embodiments of a method for preventing accidental erasure and burning of a SIM card of the present invention, part of the data in the program data for implementing the method for preventing accidental erasure and burning of a SIM card is in assembly format.

[0057] The program data burned into the SIM card includes not only partial data for implementing the above-mentioned method for preventing accidental erasure of a SIM card, but also other data including COS and related business programs, wherein the partial data for implementing the above-mentioned method for preventing accidental erasure of a SIM card is in assembly format, that is, the above-mentioned method for preventing accidental erasure of a SIM card is implemented through assembly, and the assembly format data can compress the storage space occupied by the corresponding instruction data, and at the same time can streamline the number of instructions, shorten the execution time, help reduce the storage space occupied and enable the program to execute quickly to improve the operating efficiency.

[0058] A SIM card provided by the present invention is introduced below. The SIM card described below can correspond to the above-mentioned method for preventing accidental erasure of a SIM card.

[0059] The present invention also provides a SIM card, comprising a microprocessor, a FLASH memory and a memory, wherein the FLASH memory stores program data, and when the program data is executed by the microprocessor, the above-mentioned method for preventing accidental erasure of a SIM card is implemented.

[0060] Terminals such as mobile phones and tablet computers that use SIM cards send erase commands to the SIM cards when they need to erase the data on the SIM cards. The COS program of the SIM card responds to the erase command, obtains and stores the key, obtains the erase command ciphertext from the first preset address, uses the key to decrypt the erase command ciphertext, obtains the erase command plaintext, and then executes the erase command plaintext to perform the erase operation. After decrypting and obtaining the erase command plaintext, the stored key will be deleted. After the erase command plaintext is executed, the erase command plaintext will also be deleted, that is, the key and the erase command plaintext adopt a use-and-delete strategy, so that the key and the erase command plaintext will only exist briefly if they are executed completely in the correct order, avoiding the long-term existence of the key and the erase command plaintext.

[0061] The ciphertext of the erase instruction in the SIM card cannot be executed directly, that is, there is no program instruction in the SIM card that can be directly executed to implement the erase operation. It is necessary to obtain the key and decrypt it, and then obtain the plaintext of the erase instruction to implement the erase operation, so as to hide the erase instruction. Even if the program runs away, the data will not be erased because there is no plaintext of the erase instruction.

[0062] In this way, the erase instruction is hidden from a spatial perspective. Only by decrypting the erase instruction ciphertext with a key can the erase instruction plaintext be temporarily obtained. Even if the program runs away, the data on the SIM card cannot be erased due to the lack of the erase instruction plaintext. From a temporal perspective, a use-and-delete strategy is adopted for the key and the erase instruction plaintext to avoid the long-term existence of the key and the erase instruction plaintext. The erase operation of the SIM card is protected from the perspectives of space and time, making the erase of the SIM card more reliable and improving the security of the SIM card data.

[0063] Figure 4 An example of a physical structure diagram of an electronic device is shown in FIG. Figure 4 As shown, the electronic device may include: a processor 810, a communication interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication interface 820 and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logic instructions in the memory 830 to execute the above-mentioned method for preventing accidental erasure and burning of a SIM card.

[0064] The electronic device provided by the present invention may specifically be a computer, a SIM card burning device, etc., so as to be able to perform a burning operation on a SIM card.

[0065] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0066] On the other hand, the present invention also provides a computer program product, which includes a computer program. The computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute a SIM card prevention method for accidental erasure and burning provided by the above methods.

[0067] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, a method for preventing accidental erasure and burning of a SIM card provided by the above methods is implemented.

[0068] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0069] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0070] In the description of the present invention, it should be understood that 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 technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0071] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. 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 invention. In this specification, the schematic representations of the above terms do 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. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.

[0072] All actions to obtain signals, information or data in this application are carried out in compliance with the relevant data protection laws and policies of the location and with the authorization given by the owner of the corresponding device.

[0073] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for preventing accidental erasure of a SIM card, characterized in that: include: In response to an erase command, obtaining a key and storing the key; Obtaining a ciphertext of an erase instruction from a first preset address; Decrypt the erase instruction ciphertext according to the key to obtain the erase instruction plaintext; deleting the key; Execute the erase instruction plaintext; Determine that the erase instruction plaintext has been executed, and delete the erase instruction plaintext.

2. A method for preventing accidental erasure of a SIM card according to claim 1, characterized in that: The step of obtaining a key and storing the key in response to an erase command comprises: In response to an erase command, obtaining a command code according to a frame format of the erase command; The command code is used as the key and stored in a second preset address.

3. A method for preventing accidental erasure of a SIM card according to claim 1, characterized in that: The decrypting the erase instruction ciphertext according to the key to obtain the erase instruction plaintext includes: According to the key, based on a symmetric encryption algorithm, the erase instruction ciphertext is processed to obtain the erase instruction plaintext; Wherein, the erase instruction ciphertext is generated based on the same symmetric encryption algorithm.

4. A method for preventing accidental erasure of a SIM card according to claim 1, characterized in that: The decrypting the erase instruction ciphertext according to the key to obtain the erase instruction plaintext includes: Performing XOR processing on the key and the erase instruction ciphertext to obtain the erase instruction plaintext; The erase instruction ciphertext is generated by performing XOR processing on the key and the erase instruction plaintext.

5. A method for preventing accidental erasure of a SIM card according to claim 1, characterized in that: The step of obtaining a key and storing the key in response to an erase command comprises: In response to the erase command, checking the operating parameters; When it is determined that the operating parameter meets the preset condition, obtaining the key from the erase command and storing the key at a second preset address; When it is determined that the operating parameters do not meet the preset conditions, the erase process is stopped and a preset software trap is triggered.

6. A method for preventing accidental erasure and burning of a SIM card, characterized in that: include: Get keys and program data; Use the key to encrypt the erase instruction plaintext to obtain the erase instruction ciphertext; Burning the erase instruction ciphertext and the program data to the SIM card; Wherein, when the program data is executed, it is possible to implement a method for preventing accidental erasure of a SIM card as claimed in any one of claims 1 to 5.

7. A method for preventing accidental erasure and burning of a SIM card according to claim 6, characterized in that: Part of the program data that implements the method for preventing accidental erasure of a SIM card is in assembly format.

8. A SIM card, comprising a microprocessor, a FLASH memory and a memory, characterized in that: The FLASH memory stores program data, and when the program data is executed by the microprocessor, a method for preventing accidental erasure of a SIM card as claimed in any one of claims 1 to 5 is implemented.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for preventing accidental erasure and burning of a SIM card as claimed in claim 6 or 7 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by the processor, a method for preventing accidental erasure and burning of a SIM card as claimed in claim 6 or 7 is implemented.

11. A computer program product, comprising a computer program, characterized in that When the computer program is executed by the processor, a method for preventing accidental erasure and burning of a SIM card as claimed in claim 6 or 7 is implemented.