Data generation method, authentication method, medium and computer program product
By using the real-time clock and CPU feature data of the ECU in the vehicle, combining the hash algorithm to generate non-repetitive random numbers, and regularly updating the key, the problem of high repetition of random number generation in BMS authentication and authentication is solved, and the vehicle is realized Improve information security and reduce costs.
Patent Information
- Application Number
- CN202411254355.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-09
- Publication Date
- 2024-12-31
AI Technical Summary
The prior art has high repetition of random number generation in the BMS authentication mechanism in vehicles, resulting in increased keys being easily cracked and replayed, and the cost is difficult to reduce without HSM, affecting vehicle information security.
By utilizing random characteristic data such as the real-time clock of the ECU peripheral module and the CPU usage rate, combined with the HMAC-SHA2 and HASH256 algorithms, non-repetitive and unique random numbers are generated and the key is updated regularly to ensure the uniqueness of the random numbers and Security.
It significantly reduces the probability of repetition of random numbers, protects the security of keys, reduces R&D and design costs, and achieves the improvement of vehicle information security.
Smart Images

Figure CN119227050A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of data processing, and in particular to a data generating method, an authentication method, a medium and a computer program product. Background Art
[0002] Vehicles have become an indispensable consumer product in our lives, and their intelligence is becoming increasingly advanced, so vehicle information security is becoming more and more important. The WP.29 Association has passed a resolution stipulating that all vehicles listed in EU countries before 2024 must meet the Vehicle Type Approval (VTA), and the Electronic Control Unit (ECU) in the vehicle must meet the corresponding vehicle information security requirements.
[0003] The battery management system (BMS) must achieve vehicle information security, and one of the important points is to have high requirements for the random number generation in the BMS authentication mechanism. If the random number is repeated multiple times, the secret key in the BMS authentication mechanism will be easily cracked and replay attacks will be easier, which will directly lead to the failure of vehicle information security protection measures.
[0004] Therefore, how to provide random numbers with low repetition while not significantly increasing costs, thereby achieving vehicle information security, has become a technical problem that needs to be urgently solved by those skilled in the art. Summary of the invention
[0005] The purpose of the present invention is to provide a data generation method, an authentication method, a medium and a computer program product, which can generate random numbers with low repetition without a hardware encryption module (HSM, Hardware Security Module), reduce costs and achieve vehicle information security.
[0006] The present invention discloses a data generation method, which comprises:
[0007] Acquire first input data and second input data;
[0008] Using a first hash algorithm to calculate hash values of the first input data and the second input data to generate output data;
[0009] The first input data is generated by performing hash value calculation on multiple feature data using a second hash algorithm, the multiple feature data include time feature data and / or performance feature data, and the second input data is a key of the first hash algorithm.
[0010] Optionally, the time characteristic data includes an identifier of the current time obtained from the RTC and / or an identifier indicating the current working time of the CPU.
[0011] Optionally, the performance characteristic data includes an identifier indicating a current CPU usage rate and / or an identifier indicating a current CPU stack usage rate.
[0012] Optionally, the method further comprises:
[0013] The plurality of feature data are combined and rearranged, wherein the first input data is generated by performing hash value calculation on the rearranged plurality of feature data using the second hash algorithm.
[0014] Optionally, the method further comprises:
[0015] Acquire the usage time and usage count of the second input data;
[0016] respectively determining whether the usage time and the usage times exceed corresponding thresholds;
[0017] When any one of the usage time and the usage count exceeds the corresponding threshold, the second input data is updated.
[0018] Optionally, the first hash algorithm includes an HMAC-SHA2 algorithm, and / or the second hash algorithm includes a HASH256 algorithm.
[0019] The present invention discloses an authentication method, which comprises:
[0020] The authentication module to be authenticated transmits an authentication request to the authentication module;
[0021] In response to the authentication request, the authentication module transmits a random number to the authentication module to be authenticated;
[0022] The authentication module to be authenticated calculates a hash value of the random number using a third hash algorithm to generate first comparison data, and transmits the first comparison data to the authentication module;
[0023] In response to the first comparison data, the authentication module compares the first comparison data with second comparison data, wherein the second comparison data is generated by the authentication module performing hash value calculation on the random number using a fourth hash algorithm;
[0024] If the comparison results are consistent, the authentication module completes the authentication of the authentication module to be authenticated;
[0025] The random number is output data generated according to the data generation method described above.
[0026] The present invention discloses a computer-readable storage medium on which computer-executable instructions are stored. The instructions are executed by a processor to implement the data generation method or authentication method described above.
[0027] The present invention discloses a computer program product, comprising computer executable instructions, wherein the instructions are executed by a processor to implement the data generation method or authentication method described above.
[0028] Compared with the prior art, the present invention has the following main differences and effects:
[0029] The present invention utilizes the real-time clock (RTC) of the ECU peripheral module and the timer of the CPU (or microcontroller unit) and other control modules during operation and assists in random feature data such as CPU usage and stack usage to generate the first random input data. The uniqueness, randomness and time-varying nature of the feature data can determine the uniqueness of the final random number.
[0030] The present invention periodically updates the second input data, which can make the finally generated random number less likely to be repeated and is beneficial to the protection of the key.
[0031] The present invention applies the HMAC-SHA2 algorithm and the HASH256 algorithm to the generation of random numbers, reasonably utilizes the characteristics of the relevant algorithms, and ensures the uniqueness of the output under a certain input condition.
[0032] For ECUs with lower vehicle information security requirements, without using HSM to generate true random numbers, the present invention can significantly reduce the probability of generating duplicate random numbers, while reducing R&D and design costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] Figure 1 is a flow chart of a data generation method according to the present invention;
[0034] Figure 2 is a schematic diagram of generating output data according to the present invention;
[0035] Figure 3 is a schematic diagram of generating first input data according to the present invention;
[0036] Figure 4 is a schematic diagram of updating second input data according to the present invention;
[0037] Figure 5 is a flow chart of the authentication method according to the present invention. DETAILED DESCRIPTION
[0038] In order to make the purpose and technical solution of the embodiment of the present invention clearer, the technical solution of the embodiment of the present invention will be clearly and completely described below in conjunction with the drawings of the embodiment of the present invention. Obviously, the described embodiment is a part of the embodiment of the present invention, not all of the embodiments. Based on the described embodiment of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0039] In order for BMS to achieve vehicle information security, one very important point is to have high requirements for the random number generation in the BMS authentication mechanism. If the random number is repeated multiple times, the secret key in the BMS authentication mechanism will be easily cracked and replay attacks will be easier, which will directly lead to the failure of vehicle information security protection measures.
[0040] One random number generation method is to generate pseudo-random numbers based on the timer data generated by the ECU internal chip and in conjunction with a random number function. However, the random numbers generated by this method have a high probability of repetition. For example, when the vehicle is powered off and then on, the ECU will also be powered off and then on, which will cause the timer data generated by the internal chip to repeat the state after the last power-on, resulting in data duplication.
[0041] Another random number generation method is to generate real random numbers through the HSM carried by the internal chip of the ECU. However, this method has high requirements for the on-board chip. A separate HSM is required. Not only is the chip expensive, but the software and hardware need to be redeveloped to adapt to the chip, resulting in a significant increase in the overall cost of the original project. This is difficult for upstream vehicle manufacturers (OEMs) and downstream parts suppliers to accept.
[0042] Based on this, it is expected to generate random numbers with low repetition without HSM, reduce R&D costs, and achieve vehicle information security.
[0043] Figure 1 is a flow chart of a data generating method according to the present invention. Figure 2 This is a schematic diagram of generating output data according to the present invention. Figure 1 and Figure 2 The data generation method according to the present invention comprises the following steps:
[0044] S11, obtaining first input data and second input data;
[0045] S12, using a first hash algorithm to calculate hash values for the first input data and the second input data to generate output data;
[0046] The first input data is generated by performing hash value calculation on multiple feature data using a second hash algorithm, the multiple feature data include time feature data and / or performance feature data, and the second input data is a key of the first hash algorithm.
[0047] The present invention obtains two input data and generates unique output data using a first hash algorithm, which can be used as a non-repetitive random number and applied to a BMS authentication mechanism, thereby solving the problem of high repetition of pseudo-random numbers generated when there is no HSM.
[0048] In one embodiment, the first hash algorithm includes an HMAC-SHA2 algorithm. The HMAC-SHA2 algorithm is a hash-based message authentication code, which has two input parameters, one is a message (ie, the first input data), and the other is a secret key (ie, the second input data).
[0049] In order to obtain a non-repeating random number, the first input data must not be repeated or must have a very low degree of repetition. Therefore, the present invention generates unique first input data by using a second hash algorithm to calculate hash values of multiple feature data.
[0050] In one embodiment, the second hash algorithm includes a HASH256 algorithm. The HASH256 algorithm can ensure that different values are obtained by performing hash value operations on different data, so it is also necessary to find a set of non-repeating data to perform the HASH256 hash value operation. The present invention uses characteristic data as this set of non-repeating data to ensure that the first input data that is as unique and non-repeating as possible is generated.
[0051] In one embodiment, the plurality of characteristic data include time characteristic data, wherein the time characteristic data includes an identifier of the current time obtained from the RTC and / or an identifier indicating the current working time of the CPU.
[0052] Each time the ECU is powered on, the current time can be obtained from the RTC every 30 seconds, accurate to seconds. This ensures that the time changes every 30 seconds, and its 16 bytes are used as the identifier of the current time obtained from the RTC.
[0053] After the ECU is powered on, the internal timer of the CPU works at the same time, which records how long the CPU is currently working, accurate to milliseconds, so that it can be guaranteed to change every 1 millisecond, and its 16 bytes are taken as an identifier to indicate the current working time of the CPU.
[0054] The present invention utilizes the uniqueness of the time dimension of the ECU peripheral module RTC and the randomness and time-varying nature of the CPU's runtime characteristic parameters to generate first input data that is as unique and non-repetitive as possible. It is understandable that in addition to the identifier of the current time obtained from the RTC and / or the identifier indicating the current working time of the CPU, other time characteristic data may also be additionally utilized or replaced, as long as the uniqueness, randomness and time-varying nature can be ensured.
[0055] In one embodiment, the plurality of characteristic data includes performance characteristic data, wherein the performance characteristic data includes an identifier indicating a current utilization rate of the CPU and / or an identifier indicating a current stack utilization rate of the CPU.
[0056] When the CPU is working, affected by the working environment and workload, the CPU utilization rate is not fixed, and its value may change in real time. The 8 bytes are used as an identifier to indicate the current CPU utilization rate.
[0057] Similarly, when the CPU is working, affected by the working environment and workload, the CPU stack usage is not fixed, and its value may change in real time. Its 8 bytes are used as an identifier to indicate the current CPU stack usage.
[0058] The present invention utilizes performance characteristic data to generate first input data that is as unique and non-repetitive as possible. It is understandable that, in addition to the identifier indicating the current CPU usage rate and / or the identifier indicating the current CPU stack usage rate, other characteristic parameters during CPU operation may also be additionally utilized or replaced, as long as uniqueness, randomness, and time-varying properties can be ensured.
[0059] In order to further ensure the non-repetitiveness of the characteristic data, in one embodiment, multiple characteristic data include both time characteristic data and performance characteristic data, wherein the time characteristic data includes both an identifier of the current time obtained from the RTC and an identifier indicating the current working time of the CPU, and wherein the performance characteristic data includes both an identifier indicating the current utilization rate of the CPU and an identifier indicating the current stack utilization rate of the CPU.
[0060] The present invention utilizes performance characteristic data to assist time characteristic data to generate first input data that is as unique and non-repetitive as possible.
[0061] In order to further ensure the non-repetitiveness of the feature data, in one embodiment, a plurality of feature data are merged and rearranged, wherein the first input data is generated by performing hash value calculation on the rearranged plurality of feature data using a second hash algorithm.
[0062] Figure 3Schematic diagram of generating first input data according to the present invention. Figure 3 Detailed description is given. Continuing with the above example, after obtaining a 16-byte identifier of the current time obtained from the RTC (i.e., the first feature data), a 16-byte identifier indicating the current working time of the CPU (i.e., the second feature data), an 8-byte identifier indicating the current utilization rate of the CPU (i.e., the third feature data), and an 8-byte identifier indicating the current stack utilization rate of the CPU (i.e., the fourth feature data), they are combined and rearranged into a 48-byte identifier (i.e., the rearranged feature data), and then the hash value is calculated using the HASH256 algorithm (i.e., the second hash algorithm) to generate the first input data. It can be understood that the number of feature data can be more or less, such as one, two, three, five or other numbers, and the steps of combining and rearranging can also be omitted, as long as it can ensure that the first input data that is as unique and non-repetitive as possible is generated.
[0063] In order to obtain non-repeating random numbers, in addition to requiring that the first input data cannot be repeated or has a very low degree of repetition, it is also required that the second input data be updated regularly.
[0064] Figure 4 Schematic diagram of updating the second input data according to the present invention. Figure 4 In one embodiment, the use time and the number of times of use of the second input data are obtained, and it is determined whether the use time and the number of times of use exceed corresponding thresholds respectively, and when either the use time or the number of times of use exceeds the corresponding threshold, the second input data is updated.
[0065] In the process of generating random numbers, the present invention can use RTC to count the usage time of the key, and the number of times the key is used can be stored in the EEPROM. For example, when the usage time of the key exceeds 10,000 hours, or when the number of times the key is used exceeds 100,000 times, the key is automatically updated. Regularly updating the key can effectively prevent the key from being cracked, and the regularly updated key can also be stored in the EEPROM.
[0066] Figure 5 Flow chart of the authentication method according to the present invention. Figure 5 The authentication method according to the present invention comprises the following steps:
[0067] S21, the authentication module to be authenticated transmits an authentication request to the authentication module;
[0068] S22, in response to the authentication request, the authentication module transmits a random number to the authentication module to be authenticated;
[0069] S23, the authentication module to be authenticated calculates a hash value of the random number using a third hash algorithm to generate first comparison data, and transmits the first comparison data to the authentication module;
[0070] S24, in response to the first comparison data, the authentication module compares the first comparison data with the second comparison data, wherein the second comparison data is generated by the authentication module performing hash value calculation on the random number using a fourth hash algorithm;
[0071] S25, when the comparison results are consistent, the authentication module completes the authentication of the authentication module to be authenticated;
[0072] The random number is output data generated by the data generation method according to the first embodiment of the present invention.
[0073] In one embodiment, the authentication module to be authenticated can be an OEM device (such as a diagnostic instrument, a host computer for updating software, or any device that wants to establish communication with the BMS), and the authentication module can be the vehicle's BMS. The OEM device and the BMS respectively use their hash algorithms and their keys to calculate the hash value of the same random number. If the calculation results of the two are the same, it means that the encryption methods of the two are consistent. The BMS completes the authentication of the OEM device, so that the two can establish communication. It can be understood that in addition to the BMS authentication mechanism, the authentication method according to the second embodiment of the present invention can also be applied to any authentication mechanism, without limitation here.
[0074] In one embodiment, the third hash algorithm and the fourth hash algorithm include an HMAC algorithm. It is understandable that the third hash algorithm and the fourth hash algorithm may also be other encryption algorithms as long as they can ensure that different values are obtained by operating on different data.
[0075] In the authentication mechanism, any data transmitted between the authentication module to be authenticated and the authentication module may be intercepted. The only thing that cannot be intercepted is the secret key of the encryption algorithm, which is the only thing that the two parties of the authentication agree to keep confidential. However, if the random number transmitted by the authentication module to the authentication module to be authenticated is the same each time in response to the authentication request, the first comparison data generated by the authentication module to be authenticated and transmitted to the authentication module is also the same. In this way, the decryptor will use replay attacks to obtain access rights to the authentication module, and the secret key of the encryption algorithm can also be easily cracked. Therefore, it is required that the random number should not be repeated as much as possible.
[0076] Since the random numbers generated by the data generation method according to the first embodiment of the present invention have low repetition, the secret key in the BMS authentication mechanism is not easily cracked and is not easily vulnerable to replay attacks, thereby achieving vehicle information security.
[0077] The first embodiment is a method implementation method corresponding to the present embodiment, and the present embodiment can be implemented in conjunction with the first embodiment. The relevant technical details mentioned in the first embodiment are still valid in the present embodiment, and are not repeated here to reduce repetition. Accordingly, the relevant technical details mentioned in the present embodiment can also be applied in the first embodiment.
[0078] The present invention also provides a computer-readable storage medium on which computer-executable instructions are stored. The instructions are executed by a processor to implement the data generation method or authentication method described above.
[0079] The present invention also provides a computer program product, which includes computer executable instructions. The instructions are executed by a processor to implement the data generation method or authentication method described above.
[0080] It should be noted that in the claims and description of this patent, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "including one" do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0081] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be modified or may be combined with other features.
[0082] While the present invention has been shown and described with reference to certain preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the invention.
Claims
1. A data generation method, characterized in that: The method comprises: Acquire first input data and second input data; Using a first hash algorithm to calculate hash values of the first input data and the second input data to generate output data; The first input data is generated by performing hash value calculation on multiple feature data using a second hash algorithm, the multiple feature data include time feature data and / or performance feature data, and the second input data is a key of the first hash algorithm.
2. The method according to claim 1, characterized in that The time characteristic data includes an identifier of the current time obtained from the RTC and / or an identifier indicating the current working time of the CPU.
3. The method according to claim 1, characterized in that The performance characteristic data includes an identifier indicating a current utilization rate of the CPU and / or an identifier indicating a current stack utilization rate of the CPU.
4. The method according to any one of claims 1 to 3, characterized in that The method further comprises: The plurality of feature data are combined and rearranged, wherein the first input data is generated by performing hash value calculation on the rearranged plurality of feature data using the second hash algorithm.
5. The method according to claim 1, characterized in that The method further comprises: Acquire the usage time and usage count of the second input data; respectively determining whether the usage time and the usage times exceed corresponding thresholds; When any one of the usage time and the usage count exceeds the corresponding threshold, the second input data is updated.
6. The method according to claim 1, characterized in that The first hash algorithm includes an HMAC-SHA2 algorithm, and / or the second hash algorithm includes a HASH256 algorithm.
7. An authentication method, characterized in that: The method comprises: The authentication module to be authenticated transmits an authentication request to the authentication module; In response to the authentication request, the authentication module transmits a random number to the authentication module to be authenticated; The authentication module to be authenticated calculates a hash value of the random number using a third hash algorithm to generate first comparison data, and transmits the first comparison data to the authentication module; In response to the first comparison data, the authentication module compares the first comparison data with second comparison data, wherein the second comparison data is generated by the authentication module performing hash value calculation on the random number using a fourth hash algorithm; If the comparison results are consistent, the authentication module completes the authentication of the authentication module to be authenticated; The random number is output data generated by the data generation method according to any one of claims 1 to 6.
8. The method according to claim 7, characterized in that The authentication module to be authenticated is an OEM device, and the authentication module is a BMS of a vehicle.
9. A computer-readable storage medium having computer-executable instructions stored thereon, characterized in that: The instructions are executed by a processor to implement the data generation method according to any one of claims 1 to 6 or the authentication method according to any one of claims 7 to 8.
10. A computer program product comprising computer executable instructions, characterized in that: The instructions are executed by a processor to implement the data generation method according to any one of claims 1 to 6 or the authentication method according to any one of claims 7 to 8.
