Metering equipment point-to-point security upgrading method for electric energy meter and acquisition terminal
By upgrading the point -to -point pairing point of the power metering equipment, the random number authentication and double -layer nested encryption technology are used to solve the problem of the traditional upgrade method of completeness and insufficient confidentiality, and the safe and reliable program upgrade.
Patent Information
- Application Number
- CN202411374994.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-29
- Publication Date
- 2025-01-24
AI Technical Summary
When upgrading power metering equipment, traditional methods cannot effectively verify the integrity and confidentiality of binary files, and there is a risk of file tampering and device attacks.
Adopt a point-to-point security upgrade method, determine the message key through random number identity authentication, and use more than two layers of nested encryption to transmit program files and verification information to ensure the validity, integrity and confidentiality of file transmission.
The effectiveness, integrity and confidentiality of the transmission of program files are achieved, prevent illegal access and file tampering, and enhance the security of the equipment.
Smart Images

Figure CN119363392A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to a program upgrading method, in particular to a point-to-point program upgrading method for an electric energy meter and a collection terminal. Background Art
[0002] When upgrading embedded device programs, the usual practice is to use a compiler to convert the latest program into a binary file. The host computer then reads the binary file, assembles a message according to a custom protocol, and sends it to the embedded device to be upgraded. After receiving the message, the device will parse it, obtain the binary file content, and perform the upgrade operation. Generally, the binary file is transmitted in plain text during the upgrade process.
[0003] This conventional approach is feasible when upgrading some non-critical equipment. However, for equipment involving national infrastructure, such as power metering equipment such as energy meters and power consumption information collection terminals, the traditional upgrade method has the following defects:
[0004] 1. The validity and integrity of the binary file cannot be effectively verified. If the file is tampered with or some bytes are deleted, the upgraded program may not run normally or even completely fail to run, affecting the normal operation of the power grid.
[0005] 2. The delivery and transmission process of binary files lacks confidentiality and can be easily decompiled and analyzed by others, which in turn causes the operating status of the device to be analyzed, posing a risk of attack. Summary of the invention
[0006] The present invention proposes a point-to-point secure upgrade method for metering equipment of electric energy meters and data collection terminals, the purpose of which is to ensure the validity, integrity and confidentiality of file transmission during the upgrade.
[0007] The technical solution of the present invention is as follows:
[0008] A point-to-point secure upgrade method for metering equipment used in electric energy meters and data collection terminals. Before an upgrade host computer sends a program file to a device end, the device end is first authenticated by means of random number transmission. During the identity authentication process, both parties determine a message key for encrypting and sending the program file according to an intermediate variable generated by the transmitted random number. Then, the upgrade host computer and the device end perform encrypted transmission and decryption of the program file according to the determined message key. The encrypted transmission content includes the program file and verification information corresponding to the program file.
[0009] As a further improvement of the point-to-point secure upgrade method for metering equipment used for electric energy meters and collection terminals: when upgrading the upper computer to encrypt and transmit program files to the device end, a double-layer or more nested encryption method is used, wherein one layer of encryption uses the message key;
[0010] The message key includes an odd-numbered packet key and an even-numbered packet key.
[0011] As a further improvement of the point-to-point secure upgrade method for metering equipment used for electric energy meters and collection terminals: when the upgrade host computer encrypts and transmits the program file to the device end, the binary file plaintext of the program file is first encrypted using the program encryption key obtained from the management system to obtain the binary file ciphertext, and then the binary file ciphertext and the verification information of the binary file plaintext and the verification information of the binary file ciphertext are spliced into an upgrade package; then the upgrade package is divided into packages, the odd packages are encrypted using the odd package key, and the even packages are encrypted using the even package key, and then the encrypted package files are sent to the device end.
[0012] As a further improvement of the point-to-point security upgrade method for metering equipment used for electric energy meters and collection terminals, the identity authentication process is as follows: the upgrade host computer obtains the identity authentication key generated according to the hardware identification information of the device end from the management system, and the identity authentication key is consistent with the identity authentication key pre-stored in the device end; then the upgrade host computer generates a random number Rand2, and uses the identity authentication key to encrypt Rand2 to obtain Rand2' and sends it to the device;
[0013] After receiving Rand2', the device uses the local authentication key to decrypt Rand2 and generate a random number Rand3. It then concatenates Rand2 and Rand3 into Rand2_Rand3, and then uses the local authentication key to encrypt Rand2_Rand3 to obtain Rand2_Rand3' and returns it to the upgrade host computer.
[0014] After receiving the data, the upgraded host computer uses the identity authentication key to decrypt the data to obtain Rand2_Rand3, and then verifies whether the part of Rand2_Rand3 corresponding to Rand2 is the same as Rand2. If they are not the same, the authentication fails. If they are the same, Rand3 in Rand2_Rand3 is extracted and encrypted with the identity authentication key to obtain Rand3' and send it to the device.
[0015] The device decrypts the received Rand3' to obtain Rand3_1, and determines whether Rand3_1 is the same as the previously generated Rand3. If they are not the same, it is considered as authentication failure. If they are the same, it is considered as authentication success and the upgrade host is notified. At the same time, the first half of the hash value of Rand2_Rand3 is used as the even package key, and the second half as the odd package key;
[0016] After the upgraded host computer learns that the identity authentication is successful, it also uses the first half of the hash value of Rand2_Rand3 as the even-numbered package key and the second half as the odd-numbered package key;
[0017] At this point, the identity authentication process is completed, and the upgraded host computer and the device end simultaneously obtain the same odd package key and the same even package key based on the random numbers Rand2 and Rand3.
[0018] As a further improvement of the point-to-point secure upgrade method for metering equipment used for electric energy meters and collection terminals: the device end encrypts and saves the program encryption key and the identity authentication key required in the identity authentication process through a local protection key.
[0019] As a further improvement of the point-to-point security upgrade method for metering equipment used for electric energy meters and collection terminals: the local protection key includes a key protection key and a protection key initialization vector, and the two are generated as follows: the first half of the hash value of the hardware identification information on the device side is used as the key protection key, and the second half is used as the protection key initialization vector.
[0020] As a further improvement of the point-to-point secure upgrade method for metering equipment used for electric energy meters and collection terminals: after receiving the package file, the device end uses the odd package key and the even package key to decrypt the corresponding package files respectively, and then splices to obtain the binary file ciphertext, the verification information of the binary file plaintext, and the verification information of the binary file ciphertext; after verifying the binary file ciphertext using the verification information of the binary file ciphertext, the binary file ciphertext is decrypted using the program encryption key stored in the device end to obtain the binary file plaintext, and then the binary file plaintext is verified using the verification information of the binary file plaintext;
[0021] The verification information is a hash value.
[0022] As a further improvement of the point-to-point security upgrade method for metering equipment used for electric energy meters and collection terminals: during the identity authentication process, the upgrade host computer and the device end hold the same identity authentication key that matches the device; the identity authentication key is obtained by encrypting the hardware identification information of the device using the identity authentication root key.
[0023] As a further improvement of the point-to-point secure upgrade method for metering devices used for electric energy meters and collection terminals: before the upgrade, the management system transmits the program encryption key and the identity authentication root key used to generate the identity authentication key on the device side to the device side through temporary key encryption.
[0024] As a further improvement of the point-to-point security upgrade method for metering equipment used for electric energy meters and collection terminals: the temporary key is generated simultaneously on the device side and the management system, and the generation process is: the device side reads its own hardware identification information SN and generates a random number Rand1, and sends the hardware identification information SN and the random number Rand1 to the management system at the same time; the management system and the device side simultaneously perform the following operations: the hardware identification information SN and the random number Rand1 are spliced into SN_Rand1, and then SN_Rand1 is copied 5 times and then spliced into 5 different character strings respectively to obtain 5 intermediate character strings, and then the hash value of each intermediate character string is calculated, and the first half and the second half of each hash value are respectively used as the candidate key, and a total of 10 candidate keys are obtained and sorted, and then the random number Rand1 is modulo 10, and the remainder is used as the sequence number to select the temporary key from the 10 candidate keys;
[0025] When a temporary key is used to transmit the program encryption key and the identity authentication root key, the verification value of the program encryption key and the identity authentication root key is also included. The verification value refers to the result of encrypting the first half and the second half of the hash value of the encrypted object using the temporary key. After the device receives the program encryption key and the identity authentication root key, it calculates the verification value for each encrypted object in the same way, and compares it with the received verification value to determine whether the received information is valid.
[0026] Compared with the prior art, the present invention has the following positive effects:
[0027] 1. The present invention performs identity authentication before upgrading, and uses the random number transmitted during the identity authentication process to determine the message key, which not only ensures the correctness of the identity and prevents illegal access, but also enhances the confidentiality of the message key. The message key obtained in this way is random, which ensures the security of subsequent transmission.
[0028] 2. The encrypted transmission content during the upgrade also includes verification information. The device can verify the validity and integrity of the obtained binary file based on the verification information.
[0029] 3. The message key is divided into odd-numbered package keys and even-numbered package keys, which increases the difficulty of message cracking.
[0030] 4. The transmission encryption of the upgrade package is nested encryption, which includes both random message keys and agreed program encryption keys, further increasing the difficulty of message cracking.
[0031] 5. The program encryption key and identity authentication root key are sent to the device through the encryption of the temporary key. The temporary key is generated based on the hardware identification information and random number of the device, and both parties can generate it synchronously to avoid the leakage of important keys.
[0032] 6. The device uses local protection keys to decrypt important keys, further reducing the possibility of key leakage. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 A flow chart for generating a key protection key and a protection key initialization vector;
[0034] Figure 2 A flowchart for generating a temporary key;
[0035] Figure 3 A flowchart for encrypting and transmitting a program encryption key and an identity authentication root key to a device using a temporary key;
[0036] Figure 4 A flowchart for calculating a program key, a program key initialization vector, and an authentication root key check value;
[0037] Figure 5 A flowchart for generating an authentication key;
[0038] Figure 6 Flowchart for storing program encryption keys and authentication keys for device-side encryption;
[0039] Figure 7 This is the production flow chart of the upgrade package;
[0040] Figure 8 Flowchart for obtaining the identity authentication key for upgrading the host computer;
[0041] Fig. 9 This is a flowchart for identity authentication;
[0042] Fig.10 Send a flowchart for the upgrade package;
[0043] Fig.11 Flowchart for decrypting binary file ciphertext. DETAILED DESCRIPTION
[0044] The technical solution of the present invention is described in detail below in conjunction with the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments.
[0045] The management system in the present embodiment can be a host computer (such as the host computer with the root key installed below), or it can be composed of multiple host computers or servers. The encryption methods in the present embodiment are all the national secret SM4 algorithm unless otherwise specified, and other encryption algorithms can also be used during specific implementation. In the present embodiment, some steps adopt the SM4_CBC encryption method, and some steps adopt the SM4_ECB encryption method, but they can be arbitrarily selected according to the situation during specific implementation, and other encryption methods can be selected.
[0046] A point-to-point secure upgrade method for metering equipment used in electric energy meters and collection terminals, the core of which is that before the upgrade host computer sends the program file to the device end, the device end is authenticated by means of the transmission of random numbers, and both parties determine the message key when the program file is encrypted and sent according to the intermediate variable generated by the transmitted random number during the identity authentication process, and then the upgrade host computer and the device end perform encryption transmission and decryption of the program file according to the determined message key. The encrypted transmission content includes the program file and the verification information corresponding to the program file.
[0047] The implementation process of this method can be specifically divided into a preparation phase, an upgrade package production phase, an identity authentication phase, and a transmission phase.
[0048] Preparation stage:
[0049] 1. The management system generates a program encryption key (including a program key and a program key initialization vector in this embodiment) and an identity authentication root key.
[0050] 2. The device generates a local protection key, which is used to encrypt the locally stored program encryption key and the authentication key required in the authentication process.
[0051] like Figure 1 In this embodiment, the local protection key includes a key protection key and a protection key initialization vector, and the local encryption adopts the SM4_CBC encryption method. The two are generated by using the first half of the 32-byte hash value of the device-side hardware identification information (preferably the chip serial number SN) generated by the SM3 algorithm as the key protection key, and the second half as the protection key initialization vector.
[0052] 3. The management system encrypts the program encryption key and the identity authentication root key with a temporary key and transmits them to the device.
[0053] Specifically, Figure 2 , the temporary key is generated simultaneously on the device side and the management system, and the generation process is as follows: the device side reads its own hardware identification information SN and generates a random number Rand1, and sends the hardware identification information SN and the random number Rand1 to the management system at the same time; the management system and the device side simultaneously perform the following operations: the hardware identification information SN and the random number Rand1 are spliced into SN_Rand1, and then SN_Rand1 is copied 5 times and then spliced into 5 different character strings (in this embodiment, the ASCII values of 5 letters A-E) to obtain 5 intermediate character strings, and then the hash value of each intermediate character string is calculated, and the first half and the second half of each hash value are used as the candidate key, respectively, and a total of 10 candidate keys are obtained and sorted, and then the random number Rand1 is modulo 10, and the remainder A is used as the sequence number (i.e., index) to select the temporary key from the 10 candidate keys.
[0054] like Figure 3 The key download host computer uses the temporary key to encrypt the program encryption key (specifically including two encryption objects, the program key and the program key initialization vector) and the identity authentication root key, and the encryption method is SM4_ECB method.
[0055] When using a temporary key to transmit the program encryption key and the identity authentication root key, the check value of the program encryption key and the identity authentication root key is also included. Figure 4 The check value refers to the result of encrypting the XOR value of the first 16 bytes and the last 16 bytes of the 32-byte hash value of the encryption object using a temporary key.
[0056] The data is transmitted to the device after encryption.
[0057] After receiving the ciphertext of the program encryption key and the identity authentication root key, the device first decrypts it with a local temporary key, then calculates the check value for each encrypted object in the same way, and compares it with the received check value to determine whether the received information is valid.
[0058] 4. The device obtains the authentication key based on the authentication root key: Figure 5 The identity authentication key is obtained by encrypting the hardware identification information of the device using the identity authentication root key.
[0059] 5. The device uses the local protection key to encrypt and save the program encryption key and identity authentication key. Figure 6 , the encryption method is SM4_CBC encryption method.
[0060] Upgrade package production stage:
[0061] When you need to upgrade, press Figure 7 Method to make upgrade package: When the upgrade host computer encrypts and transmits program files to the device end, double or more nested encryption is used. In the production stage, only one layer, the inner layer, is encrypted using the program encryption key. The upgrade host computer first uses the program encryption key (program key and program key initialization vector) obtained from the management system to encrypt the binary file plaintext of the program file to obtain the binary file ciphertext (using SM4_CBC packet encryption, the package length is 1024 bytes, and invalid data needs to be filled when it is less than 1024 bytes. The data length after filling must be an integer multiple of 16), and then the binary file ciphertext is spliced with the binary file length, the verification information of the binary file plaintext, and the verification information of the binary file ciphertext into an upgrade package.
[0062] Identity authentication stage:
[0063] Before upgrading, you need to authenticate the device:
[0064] like Figure 8 , the upgrade host computer obtains the identity authentication key generated according to the hardware identification information (chip serial number SN) of the device end from the management system, and the identity authentication key is consistent with the identity authentication key pre-stored in the device end.
[0065] Then as Fig. 9 , upgrade the host computer to generate an 8-byte random number Rand2, encrypt Rand2 with the identity authentication key to obtain Rand2' and send it to the device.
[0066] After receiving Rand2', the device uses the local authentication key to decrypt Rand2 and generates an 8-byte random number Rand3. It then concatenates Rand2 and Rand3 into Rand2_Rand3, and then uses the local authentication key to encrypt Rand2_Rand3 to obtain Rand2_Rand3' and returns it to the upgrade host computer.
[0067] After receiving the upgraded host computer, it uses the identity authentication key to decrypt to obtain Rand2_Rand3, and then verifies whether the first 8 bytes in Rand2_Rand3 are the same as Rand2. If they are not the same, it is judged as authentication failure. If they are the same, the last 8 bytes of Rand3 in Rand2_Rand3 are extracted and then encrypted with the identity authentication key to obtain Rand3' and send it to the device.
[0068] The device decrypts the received Rand3' to obtain Rand3_1, and determines whether Rand3_1 is the same as the previously generated Rand3. If they are different, it is considered as authentication failure. If they are the same, it is considered as authentication success and the upgrade host is notified. At the same time, the first 16 bytes of the 32-byte hash value of Rand2_Rand3 generated by the SM3 algorithm are used as the even package key, and the last 16 bytes are used as the odd package key.
[0069] After the upgraded host computer learns that the identity authentication is successful, it also uses the first 16 bytes of the hash value of Rand2_Rand3 as the even package key and the last 16 bytes as the odd package key.
[0070] At this point, the identity authentication process is completed, and the upgraded host computer and the device end simultaneously obtain the same odd package key and the same even package key based on the random numbers Rand2 and Rand3.
[0071] Transmission phase:
[0072] like Fig.10 , use the message key (odd package key and even package key) to encrypt and transmit the upgrade package in packets (SM4_ECB), the odd package is encrypted with the odd package key, and the even package is encrypted with the even package key, and then the encrypted package file is sent to the device end.
[0073] After receiving the package file, the device uses the odd package key and the even package key to decrypt the corresponding package files respectively, and then concatenates them to obtain the binary file ciphertext, binary file length, binary file plaintext verification information, and binary file ciphertext verification information.
[0074] The device needs to use the verification information of the binary file ciphertext to verify the binary file ciphertext. Fig.11 As shown, the binary file ciphertext is decrypted using the program encryption key encrypted and saved on the device side to obtain the binary file plaintext, and finally the binary file plaintext is verified using the verification information of the binary file plaintext. The above verification information is all hash values. It should be noted that, for those skilled in the art, it is obvious that the present invention is not limited to the details of the above exemplary embodiments, and the present invention can be implemented in other specific forms without departing from the spirit or basic features of the present invention. The scope of the present invention is defined by the claims rather than the above description.
Claims
1. A point-to-point secure upgrade method for metering equipment used in electric energy meters and collection terminals, characterized in that: Before the upgrade host computer sends the program file to the device end, it first authenticates the device end by means of the transmission of random numbers, and during the authentication process, both parties determine the message key when encrypting and sending the program file based on the intermediate variable generated by the transmitted random number. Then the upgrade host computer and the device end encrypt, transmit and decrypt the program file according to the determined message key; the encrypted transmission content includes the program file and the verification information corresponding to the program file.
2. The point-to-point secure upgrade method for metering equipment used for electric energy meters and data collection terminals according to claim 1, characterized in that: When upgrading the upper computer to encrypt and transmit the program file to the device end, a double-layer or more nested encryption method is adopted, wherein one layer of encryption adopts the message key; The message key includes an odd-numbered packet key and an even-numbered packet key.
3. The point-to-point secure upgrade method for metering equipment used for electric energy meters and data collection terminals according to claim 2, characterized in that: When the upgrade host computer encrypts and transmits the program file to the device end, the program encryption key obtained from the management system is first used to encrypt the binary file plain text of the program file to obtain the binary file ciphertext, and then the binary file ciphertext and the verification information of the binary file plain text and the verification information of the binary file ciphertext are spliced into an upgrade package; The upgrade package is then divided into packages, with odd-numbered packages encrypted using odd-numbered package keys and even-numbered packages encrypted using even-numbered package keys, and the encrypted package files are then sent to the device.
4. The point-to-point secure upgrade method for metering equipment used for electric energy meters and collection terminals according to claim 2, characterized in that: The identity authentication process is as follows: the upgraded host computer obtains the identity authentication key generated according to the hardware identification information of the device from the management system, and the identity authentication key is consistent with the identity authentication key pre-stored in the device; then the upgraded host computer generates a random number Rand2, and uses the identity authentication key to encrypt Rand2 to obtain Rand2' and sends it to the device; After receiving Rand2', the device uses the local authentication key to decrypt Rand2 and generate a random number Rand3. It then concatenates Rand2 and Rand3 into Rand2_Rand3, and then uses the local authentication key to encrypt Rand2_Rand3 to obtain Rand2_Rand3' and returns it to the upgrade host computer. After receiving the data, the upgraded host computer uses the identity authentication key to decrypt the data to obtain Rand2_Rand3, and then verifies whether the part of Rand2_Rand3 corresponding to Rand2 is the same as Rand2. If they are not the same, the authentication fails. If they are the same, Rand3 in Rand2_Rand3 is extracted and encrypted with the identity authentication key to obtain Rand3' and send it to the device. The device decrypts the received Rand3' to obtain Rand3_1, and determines whether Rand3_1 is the same as the previously generated Rand3. If they are not the same, it is considered as authentication failure. If they are the same, it is considered as authentication success and the upgrade host is notified. At the same time, the first half of the hash value of Rand2_Rand3 is used as the even package key, and the second half as the odd package key; After the upgraded host computer learns that the identity authentication is successful, it also uses the first half of the hash value of Rand2_Rand3 as the even-numbered package key and the second half as the odd-numbered package key; At this point, the identity authentication process is completed, and the upgraded host computer and the device end simultaneously obtain the same odd package key and the same even package key based on the random numbers Rand2 and Rand3.
5. The point-to-point secure upgrade method for metering equipment used for electric energy meters and data collection terminals according to claim 3, characterized in that: The device side encrypts and saves the program encryption key and the authentication key required in the authentication process through the local protection key.
6. The point-to-point secure upgrade method for metering equipment used for electric energy meters and data collection terminals according to claim 5, characterized in that: The local protection key includes a key protection key and a protection key initialization vector, and the two are generated by using the first half of the hash value of the hardware identification information of the device as the key protection key and the second half as the protection key initialization vector.
7. The point-to-point secure upgrade method for metering equipment used for electric energy meters and data collection terminals according to claim 3, characterized in that: After receiving the package file, the device uses the odd package key and the even package key to decrypt the corresponding package files respectively, and then concatenates them to obtain the binary file ciphertext, the verification information of the binary file plaintext, and the verification information of the binary file ciphertext; After verifying the binary file ciphertext using the verification information of the binary file ciphertext, the binary file ciphertext is decrypted using the program encryption key stored on the device to obtain the binary file plaintext, and then the binary file plaintext is verified using the verification information of the binary file plaintext; The verification information is a hash value.
8. The point-to-point secure upgrade method for metering equipment used for electric energy meters and data collection terminals according to claim 3, characterized in that: During the identity authentication process, the upgrade host computer and the device end hold the same identity authentication key that matches the device; the identity authentication key is obtained by encrypting the hardware identification information of the device using the identity authentication root key.
9. The point-to-point secure upgrade method for metering equipment used for electric energy meters and data collection terminals according to claim 3, characterized in that: Before the upgrade, the management system encrypts the program encryption key and the authentication root key used to generate the authentication key on the device side and transmits them to the device side through a temporary key.
10. The point-to-point secure upgrade method for metering equipment used for electric energy meters and data collection terminals according to claim 9, characterized in that: The temporary key is generated at the device end and the management system at the same time. The generation process is as follows: the device end reads its own hardware identification information SN and generates a random number Rand1, and sends the hardware identification information SN and the random number Rand1 to the management system at the same time; the management system and the device end perform the following operations at the same time: the hardware identification information SN and the random number Rand1 are spliced into SN_Rand1, and then SN_Rand1 is copied 5 times and spliced into 5 different strings respectively to obtain 5 intermediate strings, and then the hash value of each intermediate string is calculated, and the first half and the second half of each hash value are used as the candidate key, respectively, and a total of 10 candidate keys are obtained and sorted, and then the random number Rand1 is modulo 10, and the remainder is used as the sequence number to select the temporary key from the 10 candidate keys; When the temporary key is used to transmit the program encryption key and the identity authentication root key, the verification value of the program encryption key and the identity authentication root key is also included, and the verification value refers to the result of encrypting the first half and the second half of the hash value of the encryption object with the temporary key; After receiving the program encryption key and identity authentication root key, the device side calculates the check value for each encrypted object in the same way and compares it with the received check value to determine whether the received information is valid.
Citation Information
Cited By
Electric energy meter firmware security upgrading method and system
CN122132064A