Programmable chip program detection, storage method and programmable chip

CN112597450BActive Publication Date: 2025-01-14AUTEL INTELLIGENT TECHNOLOGY CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011525708.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-12-22
Publication Date
2025-01-14
Estimated Expiration
2040-12-22

AI Technical Summary

Technical Problem

The firmware in the program memory of existing programmable chips cannot be encrypted and is easily modified or read illegally, resulting in impairment of program security.

Method used

By generating and storing two-layer verification values, the serial number and program code are encrypted and verified using encryption algorithms and verification algorithms to ensure the security of program storage.

Benefits of technology

Effectively prevent programs from being illegally modified or read, ensure the security of program storage, and ensure program integrity through multi-dimensional verification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112597450B_ABST
    Figure CN112597450B_ABST
Patent Text Reader

Abstract

The embodiments of the present invention relate to the technical field of programmable chip detection, and specifically to a programmable chip program detection, storage method and a programmable chip. The storage method generates a first check value according to the serial number of the programmable chip; stores the first check value in the first program storage area of ​​the programmable chip; generates a third check value according to the program code stored in the program storage area of ​​the programmable chip and the first check value; stores the third check value in the second program storage area of ​​the programmable chip, thereby solving the security problem of program storage of programmable chips.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of programmable chip detection, and in particular to a programmable chip program detection and storage method and a programmable chip. Background Art

[0002] A programmable chip, also called a programmable controller, is an electronic device designed for digital computing operations in industrial environments. It uses a programmable memory to store instructions for performing logical operations, sequential operations, timing, counting, and arithmetic operations, and can control various types of machinery or production processes through digital or analog input and output.

[0003] The inventor of the present application found in his research that for a programmable chip, the data in the program storage can be copied to the program storage of another chip, and the function of the original chip can be copied. The firmware in the program storage is composed of a series of instructions that need to be executed in the end, and it cannot be encrypted. Generally, the chip has a protection device to prevent the external reading of the program storage, but the firmware can be taken out by some special methods, which will cause the program stored in the programmable chip to be illegally modified or read. Summary of the invention

[0004] In view of the above problems, an embodiment of the present invention provides a program detection and storage method for a programmable chip and a programmable chip, which are used to solve the above problems existing in the prior art.

[0005] The program storage method of a programmable chip provided in an embodiment of the present application includes:

[0006] Generate a first check value according to the serial number of the programmable chip;

[0007] Storing the first check value in a first program storage area of ​​the programmable chip;

[0008] Generate a third check value according to the program code stored in the program storage area of ​​the programmable chip and the first check value;

[0009] The third verification value is stored in the second program storage area of ​​the programmable chip.

[0010] Further, generating a first check value according to the serial number of the programmable chip includes:

[0011] A preset encryption algorithm is used to encrypt the serial number of the programmable chip to generate a first verification value.

[0012] Furthermore, storing the first check value in the first program storage area of ​​the programmable chip includes:

[0013] A first storage address is generated according to the preset encryption algorithm and the first verification value, and the first verification value is stored in a first program storage area according to the first storage address.

[0014] Further, generating a third check value according to the program code stored in the program storage area of ​​the programmable chip and the first check value includes:

[0015] Dividing the program code stored in the program storage area of ​​the programmable chip into N segments, where N is a positive integer greater than 1;

[0016] The N segments of program code and the first verification value are verified respectively using a preset verification algorithm to generate a third verification value.

[0017] Further, storing the third check value in the second program storage area of ​​the programmable chip includes:

[0018] A second storage address is generated according to the preset verification algorithm and the third verification value, and the third verification value is stored in the second program storage area according to the second storage address.

[0019] The present application also provides a programmable chip program detection method, including:

[0020] Acquire a pre-stored first verification value of the programmable chip from a program storage area of ​​the programmable chip;

[0021] Matching the serial number of the programmable chip with the pre-stored first check value of the programmable chip, and if they match, generating a second check value according to the pre-stored first check value of the programmable chip and the program code stored in the program storage area of ​​the programmable chip;

[0022] Acquire a pre-stored third verification value from the program storage area;

[0023] The pre-stored third verification value is matched with the second verification value. If they match, the programmable chip detection is normal.

[0024] Before matching the serial number of the programmable chip with the pre-stored first verification value of the programmable chip, the method further includes:

[0025] The serial number of the programmable chip to be detected is obtained from a preset programmable chip database.

[0026] Furthermore, the first verification value is generated by encrypting the serial number of the programmable chip using a preset encryption algorithm;

[0027] The matching of the serial number of the programmable chip with the pre-stored first verification value of the programmable chip includes:

[0028] Using a preset encryption algorithm to encrypt the serial number of the programmable chip to generate a check value;

[0029] The check value is compared with the first check value, and if they are the same, they match.

[0030] Further, the generating a second check value according to the pre-stored first check value of the programmable chip and the program code stored in the program storage area of ​​the programmable chip includes:

[0031] Dividing the program code stored in the program storage area of ​​the programmable chip into N segments, where N is a positive integer greater than 1;

[0032] The N segments of program code and the first verification value are verified respectively using a preset verification algorithm to generate a second verification value.

[0033] The embodiment of the present application further proposes a programmable chip, which uses the programmable chip program storage method in the above embodiment to store programs.

[0034] The embodiment of the present application generates a first verification code according to the serial number of the programmable chip, and generates a third verification code according to the stored program itself and the first verification code. Through two layers of encryption and verification, the security of the program storage of the programmable chip is guaranteed, so that when the program of the programmable chip is read, the program can be verified through multiple dimensions to ensure that the program has not been illegally modified or operated.

[0035] The above description is only an overview of the technical solution of the embodiment of the present invention. In order to more clearly understand the technical means of the embodiment of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] The accompanying drawings are only used to illustrate the embodiments and are not to be considered as limiting the present invention. In addition, the same reference symbols are used to represent the same components throughout the accompanying drawings. In the accompanying drawings:

[0037] Figure 1 A schematic diagram of the architecture of a programmable chip is shown;

[0038] Figure 2 A structural diagram of a program memory of a programmable chip provided by an embodiment of the present invention is shown;

[0039] Figure 3A flow chart of a program storage method for a programmable chip provided by an embodiment of the present invention is shown;

[0040] Figure 4 A flow chart of a programmable chip program detection method provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0041] Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein.

[0042] The present application embodiment relates to a programmable chip structure such as Figure 1 As shown, the programmable chip includes a central processing unit and a memory. The central processing unit includes an operation unit and a control unit, which respectively perform different functions. The memory includes a program memory and a data memory. The program memory is used to store user program firmware, which is equivalent to the hard disk of a computer. The data still exists after the program memory loses power; the data memory is used to store data generated when the program is running. All data in the data memory is lost after power is lost, which is equivalent to the running memory of the computer. The central processing unit sends instructions to the program memory, and the program memory returns the program address to the central processing unit. The central processing unit reads the executable program according to the program address and calls the data memory; the data memory sends address information to the central processing unit for the central processing unit to read or write data.

[0043] The programmable chip architecture provided by the embodiment of the present application is Figure 1 The present application embodiment improves the program memory in the programmable chip, and the improved storage structure is as follows Figure 2 As shown, the program memory includes multiple partitions, which are used to store program codes, chip serial numbers and program verification codes respectively.

[0044] Based on the above program memory, an embodiment of the present application proposes a method for storing a program of a programmable chip, which is used when burning a program when producing a programmable chip. The method includes:

[0045] Step 301: Generate a first check value according to the serial number of the programmable chip;

[0046] The first verification value may be the serial number of the programmable chip, or may be a verification value generated according to the serial number of the programmable chip.

[0047] Before writing the program, the system first obtains the serial number of the programmable chip from a preset programmable chip database, and uses a preset encryption algorithm to encrypt the serial number of the programmable chip to generate a first verification value. The encryption algorithm can be a commonly used encryption algorithm or a user-defined encryption algorithm. The purpose is to ensure the security of the serial number and prevent intruders from modifying the serial number during use.

[0048] Of course, for the sake of simplicity, the serial number may not be encrypted and the serial number may be directly used as the first verification value.

[0049] Step 302: storing the first check value in a first program storage area of ​​the programmable chip;

[0050] After the first check value is generated according to the serial number of the programmable chip, the first check value is stored in the first program storage area of ​​the programmable chip, wherein the first storage area is a storage area pre-delimited in the program storage area of ​​the programmable chip.

[0051] Of course, in order to prevent the storage address of the first verification value from being exposed during the use of the programmable chip, resulting in the first verification value being illegally read out, an embodiment of the present invention can also generate a first storage address according to a preset encryption algorithm and the first verification value, and store the first verification value in the first program storage area according to the first storage address.

[0052] Step 303: Generate a third check value according to the program code stored in the program storage area of ​​the programmable chip and the first check value;

[0053] After the first verification value is stored in the first program storage area, the system uses a preset verification algorithm to further generate a third verification value according to the program code stored in the program storage area and the first verification value.

[0054] Considering the amount of code of the program code stored in the program storage area, if the amount of code is large, the duration and complexity of the verification will increase. The present application further generates a third verification value based on the program code and the first verification value. First, the program code stored in the program storage area of ​​the programmable chip is divided into N segments, where N is a positive integer greater than 1, and a preset verification algorithm is used to verify the N segments of program code and the first verification value to generate a third verification value. In this way, the security of the data is further guaranteed.

[0055] Step 304: storing the third check value in the second program storage area of ​​the programmable chip;

[0056] After the third verification value is generated, the third verification value is stored in the second program storage area, and the second program storage area may be a preset program storage area.

[0057] Of course, for security reasons, to prevent the third check value from being illegally read, a second storage address can be generated according to the preset check algorithm and the third check value, and the third check value can be stored in the second program storage area according to the second storage address.

[0058] From the above, it can be seen that the embodiment of the present application generates a first verification code according to the serial number of the programmable chip, and generates a third verification code according to the stored program itself and the first verification code. Through two layers of encryption and verification, the security of the program storage of the programmable chip is guaranteed, so that when the program of the programmable chip is read, the program can be verified through multiple dimensions to ensure that the program has not been illegally modified or operated.

[0059] Corresponding to the program storage method of the programmable chip described above, the embodiment of the present application further proposes a program detection method for a programmable chip, which is used to detect whether the program stored in the programmable chip has been illegally modified. Figure 4 As shown, the method includes:

[0060] Step 401: Acquire a pre-stored first verification value of the programmable chip from a program storage area of ​​the programmable chip;

[0061] Corresponding to the program storage method of the above-mentioned programmable chip, if the first verification value is the serial number of the programmable chip, the serial number of the programmable chip to be tested can be directly obtained from the preset programmable chip database. The preset programmable chip database is a database provided by the programmable chip supplier, which records the information of the programmable chip, including serial number, model, size, production date and other information.

[0062] Corresponding to the program storage method of the above-mentioned programmable chip, if the first verification value is a value generated according to an encryption algorithm, then during detection, the same encryption algorithm is also used to encrypt the serial number of the programmable chip to generate the first verification value.

[0063] Step 402: Matching the serial number of the programmable chip with the pre-stored first verification value of the programmable chip;

[0064] After encrypting the serial number of the programmable chip using a preset encryption algorithm, a check value is generated, and the check value is compared with a pre-stored first check value. If they match, it means that the program has not been illegally modified, and the process goes to step 403. If they do not match, the process goes to step 404.

[0065] Step 403: Generate a second check value according to the pre-stored first check value of the programmable chip and the program code stored in the program storage area of ​​the programmable chip;

[0066] If the generated check value is consistent with the first check value, further verification is performed to generate a second check value based on the first check value and the program code stored in the program storage area of ​​the programmable chip.

[0067] The method for generating the second verification value is consistent with that for program storage, that is, the program code stored in the program storage area of ​​the programmable chip is divided into N segments, where N is a positive integer greater than 1; a preset verification algorithm is used to verify the N segments of program code and the first verification value respectively to generate a second verification value.

[0068] Step 404: The program is used illegally;

[0069] If the verification code generated during the detection does not match the first verification code stored in the programmable chip, it means that the programmable chip has been illegally read and the program has been illegally used.

[0070] Step 405: Obtaining a pre-stored third verification value from the program storage area;

[0071] In step 403, after the second verification value is successfully generated, a pre-stored third verification value is obtained from the program storage area.

[0072] Of course, the process of obtaining the third verification value is similar to the process of storing the third verification value. When the storage address of the third verification value is a preset address, the third verification value is directly obtained according to the preset address; when the address of the third verification value is generated according to the verification algorithm, before obtaining the third verification value, the storage address of the third verification value is first generated according to the verification algorithm and the second verification value, and then the third verification value is obtained according to the address.

[0073] Step 406: Match the pre-stored third verification value with the second verification value

[0074] The generated second verification value is matched with the pre-stored third verification value. If they match, go to step 407; otherwise, go to step 408.

[0075] Step 407: The programmable chip detects that it is normal

[0076] After two verifications in step 403 and step 406, it is proved that the program stored in the programmable chip has not been illegally accessed or modified, and the detection is normal.

[0077] Step 408: The program is modified.

[0078] If the verification is inconsistent, it means that the program stored in the programmable chip has been modified.

[0079] When it is detected that the program of the programmable chip is illegally accessed or modified, a destruction program may be started, for example, erasing the stored program at one time, or starting an alarm program, etc. No further details will be given here.

[0080] It can be seen from the above that the program detection method for a programmable chip provided in the embodiment of the present application can effectively detect whether a program has been illegally copied or used, prevent the stored program from being cracked, and solve the security problem of the program stored in the programmable chip.

[0081] Based on the above-mentioned programmable chip program storage method, an embodiment of the present invention proposes a programmable chip, which includes a central processing unit, a data storage device and a program storage device, wherein the program storage device uses the above-mentioned programmable chip program storage method to store programs. In this way, the security of program storage can be guaranteed, and the details will not be repeated here.

[0082] An embodiment of the present invention further provides a detection program for a programmable chip, and the detection program can be called to execute the programmable chip detection method in any of the above embodiments to verify the security of the program stored in the programmable chip.

[0083] An embodiment of the present invention provides a computer program product, which includes a computer program stored on a computer-readable storage medium, and the computer program includes program instructions. When the program instructions are run on a computer, the programmable chip executes the detection program of the programmable chip in any of the above method embodiments.

[0084] The algorithm or display provided herein is not inherently related to any particular computer, virtual system or other equipment. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious to construct the structure required for this type of system. In addition, the embodiment of the present invention is not directed to any specific programming language yet. It should be understood that various programming languages ​​can be utilized to realize the content of the present invention described herein, and the description made to specific languages ​​above is for disclosing the best mode of the present invention.

[0085] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0086] Similarly, it should be understood that in order to streamline the present invention and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this method of disclosure should not be interpreted as reflecting an intention that the claimed invention requires more features than those expressly recited in each claim.

[0087] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0088] It should be noted that the above embodiments illustrate the present invention rather than limit it, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim enumerating a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be understood as limitations on the order of execution.

Claims

1. A programmable chip program storage method, characterized in that: include: Generating a first check value according to the serial number of the programmable chip, comprising: encrypting the serial number of the programmable chip using a preset encryption algorithm to generate the first check value; Storing the first check value in a first program storage area of ​​the programmable chip includes: generating a first storage address according to the preset encryption algorithm and the first check value, and storing the first check value in the first program storage area according to the first storage address; Generating a third check value according to the program code stored in the program storage area of ​​the programmable chip and the first check value, comprising: dividing the program code stored in the program storage area of ​​the programmable chip into N segments, wherein N is a positive integer greater than 1; using a preset check algorithm to check the N segments of program code and the first check value respectively to generate a third check value; generating a second storage address according to the preset check algorithm and the third check value, and storing the third check value in a second program storage area according to the second storage address; The third verification value is stored in the second program storage area of ​​the programmable chip.

2. The programmable chip program storage method according to claim 1, characterized in that: The step of storing the third check value in the second program storage area of ​​the programmable chip comprises: A second storage address is generated according to the preset verification algorithm and the third verification value, and the third verification value is stored in the second program storage area according to the second storage address.

3. A programmable chip program detection method, characterized in that: include: Acquire a pre-stored first check value of the programmable chip from a program storage area of ​​the programmable chip, wherein the first check value is generated by encrypting the serial number of the programmable chip using a preset encryption algorithm, generate a first storage address according to the preset encryption algorithm and the first check value, and store the first check value according to the first storage address; Matching the serial number of the programmable chip with the pre-stored first check value of the programmable chip, and if they match, generating a second check value according to the pre-stored first check value of the programmable chip and the program code stored in the program storage area of ​​the programmable chip; A third check value pre-stored in the program storage area is obtained; wherein the third check value is generated by: dividing the program code stored in the program storage area of ​​the programmable chip into N segments, where N is a positive integer greater than 1; using a preset check algorithm to check the N segments of program code and the first check value respectively to generate a third check value; generating a second storage address according to the preset check algorithm and the third check value, and storing the third check value in the second program storage area according to the second storage address; The pre-stored third verification value is matched with the second verification value. If they match, the programmable chip detection is normal.

4. The programmable chip program detection method according to claim 3, characterized in that: Before matching the serial number of the programmable chip with the pre-stored first verification value of the programmable chip, the method further includes: The serial number of the programmable chip to be detected is obtained from a preset programmable chip database.

5. The programmable chip program detection method according to claim 4, characterized in that: The matching of the serial number of the programmable chip with the pre-stored first verification value of the programmable chip includes: Using a preset encryption algorithm to encrypt the serial number of the programmable chip to generate a check value; The check value is compared with the first check value, and if they are the same, they match.

6. The programmable chip program detection method according to claim 3, characterized in that: The generating a second check value according to the pre-stored first check value of the programmable chip and the program code stored in the program storage area of ​​the programmable chip comprises: Dividing the program code stored in the program storage area of ​​the programmable chip into N segments, where N is a positive integer greater than 1; The N segments of program code and the first verification value are verified respectively using a preset verification algorithm to generate a second verification value.

7. A programmable chip, characterized in that: The programmable chip stores programs using the programmable chip program storage method as described in any one of claims 1-2.

Citation Information

Patent Citations

  • Encryption method and apparatus for embedded operating system

    CN105069350A

  • Consumable chip verification method, consumable chip and consumable container

    CN108734253A