Method for preventing single-chip microcomputer program from being cracked, single-chip microcomputer and readable storage program

Through the encrypted communication and hash value comparison mechanism between the microcontroller and the upper computer, the problem of easy cracking of the microcontroller program is solved, and more advanced security and intellectual property protection is achieved to ensure that the program cannot run after cracking.

CN118965301APending Publication Date: 2024-11-15SHENZHEN MEIGEL BIOMEDICAL GRP CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202411039751.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-31
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

Existing microcontroller programs are easily reverse engineered, resulting in weakening of competitive advantages and damage to technical achievements, and more complex encryption methods are needed to enhance security and protect intellectual property rights.

Method used

Through communication between the host computer and the microcontroller, the hash value is generated and compared using encryption algorithms (such as AES) to ensure the legality and integrity of the microcontroller program. The upper computer sends a read command and encrypts it. The microcontroller regenerates the hash value when it starts. If it does not match the stored value, it will stop running.

Benefits of technology

Effectively prevent unauthorized programs from running and using them, protect the security and intellectual property rights of microcontroller programs, and ensure that the program cannot run normally after cracking.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118965301A_ABST
    Figure CN118965301A_ABST
Patent Text Reader

Abstract

The invention discloses a method for preventing a single-chip microcomputer program from being cracked, a single-chip microcomputer and a readable storage program, and relates to the technical field of single-chip microcomputer application. The method comprises the steps that an upper computer sends a program reading command to a single-chip microcomputer; the single-chip microcomputer sends a program code of a pre-set byte in a single-chip microcomputer program, the current time of the single-chip microcomputer and specific equipment information of the single-chip microcomputer to the upper computer; the upper computer combines and encrypts a program code of a pre-set byte in a single-chip microcomputer program, the current time of the single-chip microcomputer and specific equipment information of the single-chip microcomputer to generate a first hash value; the single-chip microcomputer obtains transmission data containing the first hash value; when the single-chip microcomputer is powered on to work, the single-chip microcomputer combines and encrypts a program code of a pre-set byte in a single-chip microcomputer program, the current time of the single-chip microcomputer and specific equipment information of the single-chip microcomputer to generate a second hash value; the single-chip microcomputer processes the first Hash value and the second Hash value, and if the first Hash value is consistent with the second Hash value, the program of the single-chip microcomputer operates normally.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of single-chip microcomputer application, and in particular to a method for preventing a single-chip microcomputer program from being cracked, a single-chip microcomputer, and a readable storage program. Background Art

[0002] During the development of the MCU program, the company's software engineers devoted a lot of time and energy to carefully design and develop a high-quality product program. However, when these product programs were put on the market, despite the use of simple code encryption measures, they were easily cracked by competitors through reverse engineering and other means. This situation not only weakened the company's competitive advantage, but also damaged the hard work and technological achievements of the engineers. In order to protect intellectual property rights and technical secrets, the company needs to consider more complex and advanced encryption methods to enhance the security of the program and prevent unauthorized copying and use. Summary of the invention

[0003] The main technical problem solved by the present invention is to provide a method and a single-chip computer capable of protecting the single-chip computer program and preventing the single-chip computer program from being cracked.

[0004] According to the first aspect, an embodiment provides a method for preventing a single-chip computer program from being cracked, which is used for a single-chip computer and a host computer, and includes:

[0005] The host computer sends a program read command to the microcontroller;

[0006] The single-chip computer parses the read command to send the program code of the first set byte in the single-chip computer program, the current time of the single-chip computer and the device-specific information of the single-chip computer to the host computer;

[0007] The host computer combines and encrypts the program code of the pre-set bytes, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer to generate a first hash value;

[0008] The single chip microcomputer obtains transmission data including the first hash value, and stores the transmission data;

[0009] When the single-chip microcomputer is powered on, the single-chip microcomputer reads the program code of the first set bytes in the single-chip microcomputer program, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer, and combines and encrypts the program code of the first set bytes in the single-chip microcomputer program, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer to generate a second hash value; the single-chip microcomputer parses the transmitted data to determine the first hash value, and compares the first hash value with the second hash value. If the first hash value and the second hash value are consistent, the single-chip microcomputer program runs normally.

[0010] In one embodiment, when the host computer sends a program read command to the single-chip microcomputer, the read command is encrypted, including:

[0011] The host computer organizes the read command into ciphertext blocks;

[0012] The host computer encrypts the ciphertext block using a preset key and initialization vector.

[0013] In one embodiment, the host computer combines and encrypts the program code of the first set bytes in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip to generate a first hash value, including:

[0014] The host computer combines the program code of the first set bytes in the single-chip program, the current time of the single-chip and the device-specific information of the single-chip into a first byte sequence, and encrypts the first byte sequence.

[0015] In one embodiment, encrypting the first byte sequence includes:

[0016] The host computer fills the first byte sequence into a first encrypted data block with set bits, obtains an initialization key with 4 set bits, and encrypts the first encrypted data block using the initialization key to generate a first hash value.

[0017] In one embodiment, the single-chip microcomputer reads the program code of the first set byte in the single-chip microcomputer program, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer, and combines and encrypts the program code of the first set byte in the single-chip microcomputer program, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer to generate a second hash value, including:

[0018] The single-chip computer combines the program code of the first set bytes in the single-chip computer program, the current time of the single-chip computer and the device-specific information of the single-chip computer into a second byte sequence, and encrypts the second byte sequence.

[0019] In one embodiment, encrypting the second byte sequence includes:

[0020] The single chip microcomputer fills the second byte sequence with the set bits of the second encrypted data block, obtains an initialization key with 4 set bits, and encrypts the second encrypted data block using the initialization key to generate a second hash value.

[0021] In one embodiment, the single chip microcomputer parses the transmission data to determine the first hash value, including:

[0022] The end of the byte of the transmission data is a first check code;

[0023] The single-chip microcomputer recalculates the transmission data with the first check code removed to determine a second check code; when the first check code and the second check code are the same, the single-chip microcomputer parses the transmission data to determine a first hash value.

[0024] According to the second aspect, an embodiment provides a single chip microcomputer, including:

[0025] Send the program code of the first set byte in the MCU program, the current time of the MCU and the device-specific information of the MCU to the host computer;

[0026] Acquire transmission data including the first hash value, and store the transmission data;

[0027] When powered on,

[0028] Reading the program code of the first set bytes in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip, and merging and encrypting the program code of the first set bytes in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip to generate a second hash value;

[0029] The transmission data is parsed to determine a first hash value, and the first hash value is compared with the second hash value. If the first hash value and the second hash value are consistent, normal operation is performed.

[0030] In one embodiment, the reading of the program code of the first set byte in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip, and merging and encrypting the program code of the first set byte in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip to generate a second hash value includes:

[0031] Combining the program code of the first set bytes in the single-chip computer program, the current time of the single-chip computer and the device-specific information of the single-chip computer into a second byte sequence;

[0032] Filling the second byte sequence with a second encrypted data block with set bits;

[0033] An initialization key with 4 set bits is obtained, and the second encrypted data block is encrypting by using the initialization key to generate a second hash value.

[0034] According to the third aspect, an embodiment provides a computer-readable storage medium, on which a program is stored. The program can be executed by a processor to implement the method described in any one of the above embodiments.

[0035] According to a method for preventing a single-chip computer program from being cracked, a single-chip computer, and a readable storage program of the above-mentioned embodiment, in the method, a host computer sends a program read command to the single-chip computer, and the single-chip computer parses the read command, so that the single-chip computer sends the program code of the first set byte in the single-chip computer program, the current time of the single-chip computer, and the device-specific information of the single-chip computer to the host computer, and the host computer merges and encrypts the program code of the first set byte in the single-chip computer program, the current time of the single-chip computer, and the device-specific information of the single-chip computer, thereby generating a first hash value. The single-chip computer stores the transmission data containing the first hash value, and when powered on, the single-chip computer reads the program code of the first set byte in its own single-chip computer program, the current time of the single-chip computer, and the device-specific information of the single-chip computer, and merges and encrypts them to generate a second hash value. When the first hash value and the second hash value are the same, the program in the single-chip computer runs normally. The present application compares the first hash value generated by the host computer with the second hash value generated by itself when it is powered on, thereby ensuring the security of the microcontroller when running the program. After the microcontroller program is cracked, the second hash value will change, and the first hash value and the second hash value will be different, so that the program stops running, thereby ensuring that the microcontroller program is cracked. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 A general flow chart of a method for preventing a single-chip computer program from being cracked in an embodiment;

[0037] Figure 2 Flow chart of step S110 in a method for preventing a single-chip computer program from being cracked in an embodiment;

[0038] Figure 3 Flow chart of step S120 in a method for preventing a single-chip computer program from being cracked in an embodiment;

[0039] Figure 4 The figure is a flow chart of the execution steps of the single chip microcomputer in another embodiment. DETAILED DESCRIPTION

[0040] The present invention is further described in detail below by specific embodiments in conjunction with the accompanying drawings. Wherein similar elements in different embodiments adopt associated similar element numbers. In the following embodiments, many detailed descriptions are for making the present application better understood. However, those skilled in the art can easily recognize that some features can be omitted in different situations, or can be replaced by other elements, materials, methods. In some cases, some operations related to the present application are not shown or described in the specification, this is to avoid the core part of the present application being overwhelmed by too much description, and for those skilled in the art, it is not necessary to describe these related operations in detail, and they can fully understand the related operations according to the description in the specification and the general technical knowledge in the art.

[0041] In addition, the features, operations or characteristics described in the specification can be combined in any appropriate manner to form various implementations. At the same time, the steps or actions in the method description can also be interchanged or adjusted in a manner that is obvious to those skilled in the art. Therefore, the various sequences in the specification and the drawings are only for the purpose of clearly describing a certain embodiment and are not meant to be a required sequence, unless otherwise specified that a certain sequence must be followed.

[0042] The serial numbers of the components in this document, such as "first", "second", etc., are only used to distinguish the objects described and do not have any order or technical meaning. The "connection" and "coupling" mentioned in this application, unless otherwise specified, include direct and indirect connections (couplings).

[0043] Please refer to Figure 1 ,A method for preventing the program of a single-chip computer from being cracked, after the program has been burned and stored in the flash memory of the single-chip computer, data or instructions are sent to the single-chip computer through a host computer, including the following steps.

[0044] Step S110: the host computer sends the first hash value to the single-chip microcomputer.

[0045] Please refer to Figure 2 In one embodiment, when executing step S110, the host computer sends the first hash value to the single-chip microcomputer, the following steps are also included.

[0046] Step S111: the host computer sends a program read command to the single-chip microcomputer.

[0047] In one embodiment, when the host computer sends a program read command to the single-chip microcomputer, the read command is encrypted using AES, thereby ensuring the security of serial port communication between the host computer and the single-chip microcomputer.

[0048] In one embodiment, AES (Advanced Encryption Standard) is a symmetric encryption algorithm. AES uses the same key for encryption and decryption. When using the AES encryption algorithm, the key and initialization vector have been pre-set. The key of AES can be 128 bits, 192 bits or 256 bits long. The initialization vector is a random number used to increase the security of encryption and prevent the same data block from generating the same encrypted text in different sessions. The initialization vector needs to be consistent in each encryption session and has been pre-defined at the beginning of the communication.

[0049] In one embodiment, when the read command is encrypted using AES, the read command is organized into ciphertext blocks, wherein the data length of the ciphertext block is a multiple of the AES block size (usually 16 bytes). The formatted ciphertext block is encrypted using a preset key and initialization vector, and the encrypted ciphertext block is sent to the single-chip microcomputer.

[0050] Step S112: the single chip microcomputer obtains and parses the read command.

[0051] In one embodiment, after receiving the encrypted ciphertext block through the serial port, the single-chip microcomputer uses the same key and initialization vector to decrypt the encrypted ciphertext block to obtain a read command. According to the read command, the single-chip microcomputer reads the program code of the first set bytes in the single-chip microcomputer program stored in the single-chip microcomputer Flash, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer.

[0052] In one embodiment, the program code of the first set bytes in the single-chip microcomputer program is the program code of the first 1K bytes in the single-chip microcomputer program stored in the single-chip microcomputer Flash memory. Flash memory is a non-volatile memory that can save data in the event of a power outage and is often used to store program code and important data. When the host computer sends a read command, the single-chip microcomputer responds to the command and reads the first 1K bytes of data in the Flash memory. The program of the single-chip microcomputer usually starts executing from address 0 of the Flash memory, and the first 1K bytes of data contain the initial part of the program. These data may include key contents such as reset vector, interrupt vector table and initialization code.

[0053] In one embodiment, the device-specific information may be a serial number of the single-chip microcomputer, a MAC address of a network interface of the single-chip microcomputer, or a chip ID of a control chip inside the single-chip microcomputer.

[0054] Step S113: the host computer combines and encrypts the program code of the first set bytes in the single-chip program, the current time of the single-chip and the device-specific information of the single-chip to generate a first hash value.

[0055] In one embodiment, the host computer obtains the current time of the microcontroller and the device-specific information of the microcontroller, and converts the current time of the microcontroller into byte form. In addition, the host computer combines the first 1K bytes of program code in the microcontroller program, the current time of the microcontroller, and the device-specific information of the microcontroller in sequence into a first byte sequence, wherein the first byte sequence is a byte sequence.

[0056] In one embodiment, the host computer prepares four 32-bit initialization keys and converts each initialization key into a byte form. In the MD5 algorithm, the first byte sequence is filled into a 512-bit (64-byte) first encrypted data block. The MD5 algorithm sets the four initialization keys to specific fixed values, and uses the initialization keys to encrypt the first encrypted data block, that is, to perform bit operations, nonlinear functions, and cyclic shifts on the first encrypted data block. After processing the first encrypted data block, the final result is a 128-bit (16-byte) first hash value, which is usually expressed in the form of a hexadecimal string.

[0057] Step S120: the single chip microcomputer obtains the first hash value and generates a second hash value, and the single chip microcomputer compares the first hash value and the second hash value.

[0058] Please refer to Figure 3 In one embodiment, when executing step S120, the single chip microcomputer obtains the first hash value and generates the second hash value. When the single chip microcomputer compares the first hash value and the second hash value, the following steps are also included.

[0059] Step S121: the single chip computer obtains transmission data including the first hash value, and stores the transmission data.

[0060] In one embodiment, the single chip microcomputer obtains the transmission data including the first hash value, and saves the transmission data to a defined Flash address after verification.

[0061] Step S122: the single-chip microcomputer reads the program code of the first set bytes in the single-chip microcomputer program, the current time of the single-chip microcomputer and the device-specific information of the single-chip microcomputer, and performs combined encryption to generate a second hash value.

[0062] In one embodiment, after the single-chip microcomputer is powered on and initialized, the single-chip microcomputer reads the program code of the first set byte in the single-chip microcomputer program, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer.

[0063] In one embodiment, the program code of the first set bytes in the single-chip microcomputer program is the program code of the first 1K bytes in the single-chip microcomputer program stored in the single-chip microcomputer Flash memory. Flash memory is a non-volatile memory that can save data in the event of a power outage and is often used to store program code and important data. When the host computer sends a read command, the single-chip microcomputer responds to the command and reads the first 1K bytes of data in the Flash memory. The program of the single-chip microcomputer usually starts executing from address 0 of the Flash memory, and the first 1K bytes of data contain the initial part of the program. These data may include key contents such as reset vector, interrupt vector table and initialization code.

[0064] In one embodiment, the device-specific information may be a serial number of the single-chip microcomputer, a MAC address of a network interface of the single-chip microcomputer, or a chip ID of a control chip inside the single-chip microcomputer.

[0065] In one embodiment, the microcontroller obtains the current time of the microcontroller and the device-specific information of the microcontroller, and converts the current time of the microcontroller into byte form. In addition, the microcontroller combines the first 1K bytes of program code in the microcontroller program, the current time of the microcontroller, and the device-specific information of the microcontroller in sequence into a second byte sequence, wherein the second byte sequence is a byte sequence.

[0066] In one embodiment, the single chip microcomputer uses the same four 32-bit initialization keys, and converts each initialization key into a byte form. In the MD5 algorithm, the second byte sequence is filled into a 512-bit (64-byte) second encrypted data block. The MD5 algorithm sets the four initialization keys to specific fixed values, and uses the initialization keys to encrypt the second encrypted data block, that is, to perform bit operations, nonlinear functions, and cyclic shifts on the second encrypted data block. After processing the second encrypted data block, the final result is a 128-bit (16-byte) second hash value, which is usually expressed in the form of a hexadecimal string.

[0067] In one embodiment, the single-chip microcomputer parses the transmission data including the first hash value to determine the first hash value. When the host computer sends the first hash value to the single-chip microcomputer, the hash value is sent to the single-chip microcomputer as the first part of the transmission data, wherein the transmission data also includes a first check code, that is, a CRC check code, and the first check code is set at the end of the transmission data. Therefore, the single-chip microcomputer uses a cyclic redundancy check algorithm to recalculate the transmission data with the first check code removed to obtain a second check code, and the single-chip microcomputer compares the first check code with the second check code. If the first check code and the second check code match, it means that the transmission data has not changed or been damaged during the transmission process, then the second hash value generated by the single-chip microcomputer and the first hash value stored by the single-chip microcomputer can be compared to verify the integrity of the data, thereby ensuring whether the data is complete and correct.

[0068] In one embodiment, after the single chip microcomputer generates the first hash value, the first hash value and the second hash value are compared. If the comparison is consistent, the program proceeds normally. If not, the program stops running.

[0069] Please refer to Figure 4 , another embodiment provides a single chip microcomputer, which performs the following steps to protect the safe operation of the program.

[0070] Step S10: Sending the program code of the first set byte in the single-chip program, the current time of the single-chip and the device-specific information of the single-chip to the host computer.

[0071] In one embodiment, after the single-chip microcomputer obtains the read command from the host computer, the single-chip microcomputer reads the program code of the first set bytes in the single-chip microcomputer program stored in the single-chip microcomputer Flash, the current time of the single-chip microcomputer and the device-specific information of the single-chip microcomputer according to the read command.

[0072] In one embodiment, the program code of the first set bytes in the single-chip microcomputer program is the program code of the first 1K bytes in the single-chip microcomputer program stored in the single-chip microcomputer Flash memory. Flash memory is a non-volatile memory that can save data in the event of a power outage and is often used to store program code and important data. When the host computer sends a read command, the single-chip microcomputer responds to the command and reads the first 1K bytes of data in the Flash memory. The program of the single-chip microcomputer usually starts executing from address 0 of the Flash memory, and the first 1K bytes of data contain the initial part of the program. These data may include key contents such as reset vector, interrupt vector table and initialization code.

[0073] In one embodiment, the device-specific information may be a serial number of the single-chip microcomputer, a MAC address of a network interface of the single-chip microcomputer, or a chip ID of a control chip inside the single-chip microcomputer.

[0074] Step S20: Acquire transmission data including the first hash value, and store the transmission data.

[0075] In one embodiment, the single chip microcomputer obtains the transmission data including the first hash value, and saves the transmission data to a defined Flash address after verification.

[0076] Step S30: Read the program code of the first set byte in the single-chip program, the current time of the single-chip and the device-specific information of the single-chip, and combine and encrypt them to generate a second hash value.

[0077] In one embodiment, after the single-chip microcomputer is powered on and initialized, the single-chip microcomputer reads the program code of the first set byte in the single-chip microcomputer program, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer.

[0078] In one embodiment, the program code of the first set bytes in the single-chip microcomputer program is the program code of the first 1K bytes in the single-chip microcomputer program stored in the single-chip microcomputer Flash memory. Flash memory is a non-volatile memory that can save data in the event of a power outage and is often used to store program code and important data. When the host computer sends a read command, the single-chip microcomputer responds to the command and reads the first 1K bytes of data in the Flash memory. The program of the single-chip microcomputer usually starts executing from address 0 of the Flash memory, and the first 1K bytes of data contain the initial part of the program. These data may include key contents such as reset vector, interrupt vector table and initialization code.

[0079] In one embodiment, the device-specific information may be a serial number of the single-chip microcomputer, a MAC address of a network interface of the single-chip microcomputer, or a chip ID of a control chip inside the single-chip microcomputer.

[0080] In one embodiment, the microcontroller obtains the current time of the microcontroller and the device-specific information of the microcontroller, and converts the current time of the microcontroller into byte form. In addition, the microcontroller combines the first 1K bytes of program code in the microcontroller program, the current time of the microcontroller, and the device-specific information of the microcontroller in sequence into a second byte sequence, wherein the second byte sequence is a byte sequence.

[0081] In one embodiment, the single chip microcomputer uses the same four 32-bit initialization keys, and converts each initialization key into a byte form. In the MD5 algorithm, the second byte sequence is filled into a 512-bit (64-byte) second encrypted data block. The MD5 algorithm sets the four initialization keys to specific fixed values, and uses the initialization keys to encrypt the second encrypted data block, that is, to perform bit operations, nonlinear functions, and cyclic shifts on the second encrypted data block. After processing the second encrypted data block, the final result is a 128-bit (16-byte) second hash value, which is usually expressed in the form of a hexadecimal string.

[0082] In one embodiment, the single-chip microcomputer parses the transmission data including the first hash value to determine the first hash value. When the host computer sends the first hash value to the single-chip microcomputer, the hash value is sent to the single-chip microcomputer as the first part of the transmission data, wherein the transmission data also includes a first check code, that is, a CRC check code, and the first check code is set at the end of the transmission data. Therefore, the single-chip microcomputer uses a cyclic redundancy check algorithm to recalculate the transmission data with the first check code removed to obtain a second check code, and the single-chip microcomputer compares the first check code with the second check code. If the first check code and the second check code match, it means that the transmission data has not changed or been damaged during the transmission process, then the second hash value generated by the single-chip microcomputer and the first hash value stored by the single-chip microcomputer can be compared to verify the integrity of the data, thereby ensuring whether the data is complete and correct.

[0083] In one embodiment, after the single chip microcomputer generates the first hash value, the first hash value and the second hash value are compared. If the comparison is consistent, the program proceeds normally. If not, the program stops running.

[0084] Those skilled in the art will appreciate that all or part of the functions of the various methods in the above-mentioned embodiments can be implemented by hardware or by computer programs. When all or part of the functions in the above-mentioned embodiments are implemented by computer programs, the program can be stored in a computer-readable storage medium, and the storage medium can include: read-only memory, random access memory, disk, optical disk, hard disk, etc., and the program is executed by a computer to implement the above-mentioned functions. For example, the program is stored in the memory of the device, and when the program in the memory is executed by the processor, all or part of the above-mentioned functions can be implemented. In addition, when all or part of the functions in the above-mentioned embodiments are implemented by computer programs, the program can also be stored in a storage medium such as a server, another computer, disk, optical disk, flash disk or mobile hard disk, and can be downloaded or copied and saved in the memory of the local device, or the system of the local device is updated, and when the program in the memory is executed by the processor, all or part of the functions in the above-mentioned embodiments can be implemented.

[0085] The above specific examples are used to illustrate the present invention, which is only used to help understand the present invention and is not intended to limit the present invention. For those skilled in the art, according to the concept of the present invention, some simple deductions, modifications or substitutions can be made.

Claims

1. A method for preventing a single-chip computer program from being cracked, characterized in that: For MCU and host computer, including: The host computer sends a program read command to the microcontroller; The single-chip computer parses the read command to send the program code of the first set byte in the single-chip computer program, the current time of the single-chip computer and the device-specific information of the single-chip computer to the host computer; The host computer combines and encrypts the program code of the first set bytes in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip to generate a first hash value; The single chip microcomputer obtains transmission data including the first hash value, and stores the transmission data; When the single-chip microcomputer is powered on, the single-chip microcomputer reads the program code of the first set bytes in the single-chip microcomputer program, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer, and combines and encrypts the program code of the first set bytes in the single-chip microcomputer program, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer to generate a second hash value; the single-chip microcomputer parses the transmitted data to determine the first hash value, and compares the first hash value with the second hash value. If the first hash value and the second hash value are consistent, the single-chip microcomputer program runs normally.

2. The method for preventing a single chip computer program from being cracked as claimed in claim 1, characterized in that: When the host computer sends a program read command to the single-chip microcomputer, the read command is encrypted, including: The host computer organizes the read command into ciphertext blocks; The host computer encrypts the ciphertext block using a preset key and initialization vector.

3. The method for preventing a single chip computer program from being cracked as claimed in claim 1, characterized in that: The host computer combines and encrypts the program code of the first set bytes in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip to generate a first hash value, including: The host computer combines the program code of the first set bytes in the single-chip program, the current time of the single-chip and the device-specific information of the single-chip into a first byte sequence, and encrypts the first byte sequence.

4. The method for preventing a single chip computer program from being cracked as claimed in claim 3, characterized in that: The encrypting the first byte sequence comprises: The host computer fills the first byte sequence into a first encrypted data block with set bits, obtains an initialization key with 4 set bits, and encrypts the first encrypted data block using the initialization key to generate a first hash value.

5. The method for preventing a single chip computer program from being cracked as claimed in claim 1, characterized in that: The single-chip microcomputer reads the program code of the first set bytes in the single-chip microcomputer program, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer, and combines and encrypts the program code of the first set bytes in the single-chip microcomputer program, the current time of the single-chip microcomputer, and the device-specific information of the single-chip microcomputer to generate a second hash value, including: The single-chip computer combines the program code of the first set bytes in the single-chip computer program, the current time of the single-chip computer and the device-specific information of the single-chip computer into a second byte sequence, and encrypts the second byte sequence.

6. The method for preventing a single chip computer program from being cracked as claimed in claim 5, characterized in that: The encrypting the second byte sequence comprises: The single chip microcomputer fills the second byte sequence with the set bits of the second encrypted data block, obtains an initialization key with 4 set bits, and encrypts the second encrypted data block using the initialization key to generate a second hash value.

7. The method for preventing a single chip computer program from being cracked as claimed in claim 1, characterized in that: The single chip computer parses the transmission data to determine a first hash value, including: The end of the byte of the transmission data is a first check code; The single-chip microcomputer recalculates the transmission data with the first check code removed to determine a second check code; when the first check code and the second check code are the same, the single-chip microcomputer parses the transmission data to determine a first hash value.

8. A single chip microcomputer, characterized in that: include: Send the program code of the first set byte in the MCU program, the current time of the MCU and the device-specific information of the MCU to the host computer; Acquire transmission data including the first hash value, and store the transmission data; When powered on, Reading the program code of the first set bytes in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip, and merging and encrypting the program code of the first set bytes in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip to generate a second hash value; The transmission data is parsed to determine a first hash value, and the first hash value is compared with the second hash value. If the first hash value and the second hash value are consistent, normal operation is performed.

9. The single chip microcomputer according to claim 8, characterized in that: The step of reading the program code of the first set byte in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip, and merging and encrypting the program code of the first set byte in the single-chip program, the current time of the single-chip, and the device-specific information of the single-chip to generate a second hash value includes: Combining the program code of the first set bytes in the single-chip computer program, the current time of the single-chip computer and the device-specific information of the single-chip computer into a second byte sequence; Filling the second byte sequence with a second encrypted data block with set bits; An initialization key with 4 set bits is obtained, and the second encrypted data block is encrypting by using the initialization key to generate a second hash value.

10. A computer-readable storage medium, characterized in that: The medium stores a program, which can be executed by a processor to implement the method according to any one of claims 1 to 7.

Citation Information

Cited By

  • Metering instrument software encryption method and system

    CN119720133A