A method, device, equipment and medium for improving message authentication code algorithm
By using key derivation functions and combination functions in the message authentication code algorithm to process message subsections and adding transformations of message input, the security problems of classic algorithms in key leakage and side channel analysis are solved, and the security of the chip is significantly improved. .
Patent Information
- Application Number
- CN202210182961.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-25
- Publication Date
- 2024-09-03
- Estimated Expiration
- 2042-02-25
AI Technical Summary
The classic message authentication code algorithm is easily leaked during key storage or use, leading to potential security risks during the secure startup of the chip. In particular, side channel analysis methods can obtain key information and destroy the authenticity of the message authentication process.
The derived secret key is obtained through the key derivation function, the original message is preprocessed and divided into equal parts, combined with the derived secret key for combined function processing to form multiple message sub-segments, and the improved message authentication code is obtained through iterative calculation to increase message input The transformation makes it inconsistent with the external controllable input and is difficult to analyze through a simple side channel analysis model.
It effectively protects the secret key, improves the security of chip use, makes it difficult to carry out side channel analysis, and significantly improves the security of the algorithm.
Smart Images

Figure CN114513311B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of security algorithms, and in particular to a method, apparatus, device and medium for improving a message authentication code algorithm. Background Art
[0002] Message Authentication Code (MAC) is a set of checksums used to verify the integrity of a message. The message authentication code algorithm is a specific calculation method that combines a cryptographic algorithm (usually a hash algorithm or a block cipher algorithm) with a secret encryption key. It can effectively verify the authenticity of a message data segment. Common message authentication code algorithms include HMAC\CMAC, etc., which are widely used in scenarios such as chip secure boot and remote login authentication. Message authentication code algorithms usually need to consider the security protection of the keys used, such as ensuring the security of the key storage process and the process of using it.
[0003] The classic message authentication code algorithm structure may use the side channel analysis method to obtain key information, resulting in the authenticity of the message authentication process cannot be effectively guaranteed. For example, when the message authentication code algorithm is applied to verify the main program in the chip security boot, if the message authentication code algorithm key is leaked during storage or use, it will further make it possible to maliciously implant code or tamper with code, which will cause potential security risks during the use of the chip. Summary of the invention
[0004] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for an improved message authentication code algorithm that can improve the security of chip use in response to the above technical problems.
[0005] A method for improving a message authentication code algorithm, the method comprising:
[0006] Get the initial secret key and the original message;
[0007] Obtaining a derived secret key according to the initial secret key through a key derivation function, preprocessing the original message and dividing it into equal parts according to a preset length, and processing the divided messages and the derived secret key through a combination function to obtain a plurality of message sub-segments;
[0008] Each message sub-segment in the multiple message sub-segments is used as the input of each iteration of the message verification algorithm, and the iterative calculation is repeated until all the message sub-segments are traversed to obtain the calculation result of the improved message authentication code algorithm on the original message.
[0009] In one of the embodiments, it also includes: when the message authentication algorithm is the HMAC algorithm, each message sub-segment of the multiple message sub-segments is used as the input of each hash function of the message authentication algorithm, and the calculation is iterated repeatedly until all the message sub-segments are traversed to obtain the HMAC value of the improved message authentication code algorithm for the original message.
[0010] In one of the embodiments, the method further includes: padding the original message so that the length of the padded message is an integer multiple of a preset length;
[0011] The padded message is divided into equal parts according to the preset length.
[0012] In one of the embodiments, the method further includes: merging each equally divided message with the derived secret key bit by bit;
[0013] After shuffling the order of each bit of each merged message according to a specific rule, a new message sub-segment is obtained;
[0014] Traverse all equally divided messages to obtain multiple message sub-segments.
[0015] In one embodiment, the method further includes: performing a bitwise XOR operation on the initial secret key, the ipad string and the opad string, respectively, and then performing a hash operation on the initial state value of the hash function to obtain the input value K of the first hash operation. i and the input value K of the last hash operation o ;
[0016] According to the initial state value IV of the hash function, the input value K of the first hash operation i , the input value K of the last hash operation o and the plurality of message sub-segments, performing multiple hash operation iterations; wherein the first hash operation is performed with the initial state value IV of the hash function and the input value K of the first hash operation i The last hash operation is performed with the initial state value IV of the hash function and the input value K of the last hash operation. o The intermediate hash operations between the first and last hash operations take the output of the previous hash operation and each message sub-segment as input;
[0017] Get the HMAC value of the original message using the improved message authentication code algorithm.
[0018] In one of the embodiments, the method further includes: reading the initial secret key in the OTP through the startup code stored in the read-only memory;
[0019] The hash value of the initial secret key is calculated and compared with the check value stored in the OTP.
[0020] In one of the embodiments, the method further includes: calculating a hash value of the initial secret key and comparing it with a check value stored in the OTP;
[0021] If the hash value of the initial secret key is matched with the check value stored in the OTP, the HMAC value of the original message of the improved message authentication code algorithm is obtained through the main program in the FLASH.
[0022] In one of the embodiments, the method further includes: comparing the HMAC value of the improved message authentication code algorithm with respect to the original message with the authentication code stored in the FLASH;
[0023] If the comparison passes, the main program is loaded and run to achieve chip security startup.
[0024] A device for improving a message authentication code algorithm, the device comprising:
[0025] An initialization module for obtaining an initial secret key and an original message;
[0026] a message sub-segment acquisition module, configured to obtain a derived secret key according to the initial secret key through a key derivation function, pre-process the original message and divide it into equal parts according to a preset length, and process the divided messages and the derived secret key through a combination function to obtain a plurality of message sub-segments;
[0027] The calculation result output module is used to use each message sub-segment of the multiple message sub-segments as the input of each iteration of the message verification algorithm, repeatedly iterate the calculation until all message sub-segments are traversed, and obtain the calculation result of the improved message authentication code algorithm on the original message.
[0028] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0029] Get the initial secret key and the original message;
[0030] Obtaining a derived secret key according to the initial secret key through a key derivation function, preprocessing the original message and dividing it into equal parts according to a preset length, and processing the divided messages and the derived secret key through a combination function to obtain a plurality of message sub-segments;
[0031] Each message sub-segment in the multiple message sub-segments is used as the input of each iteration of the message verification algorithm, and the iterative calculation is repeated until all the message sub-segments are traversed to obtain the calculation result of the improved message authentication code algorithm on the original message.
[0032] A computer-readable storage medium stores a computer program, which, when executed by a processor, implements the following steps:
[0033] Get the initial secret key and the original message;
[0034] Obtaining a derived secret key according to the initial secret key through a key derivation function, preprocessing the original message and dividing it into equal parts according to a preset length, and processing the divided messages and the derived secret key through a combination function to obtain a plurality of message sub-segments;
[0035] Each message sub-segment in the multiple message sub-segments is used as the input of each iteration of the message verification algorithm, and the iterative calculation is repeated until all the message sub-segments are traversed to obtain the calculation result of the improved message authentication code algorithm on the original message.
[0036] The method, device, computer equipment and storage medium for improving the message authentication code algorithm are as follows: a derived secret key is obtained according to an initial secret key through a key derivation function; the original message is preprocessed and then divided into equal parts according to a preset length; the divided message and the derived secret key are processed through a combination function to obtain multiple message sub-segments; each message sub-segment in the multiple message sub-segments is used as the input of each iteration of the message verification algorithm, and the iterative calculation is repeated until all the message sub-segments are traversed to obtain the calculation result of the improved message authentication code algorithm on the original message. Due to the transformation of the original message segment, the message input directly involved in the hash function calculation is inconsistent with the externally controllable message input, so that it is impossible to directly construct a simple side channel analysis model such as a first-order DPA / CPA for information analysis; in addition, although there is no complex calculation logic or nonlinear transformation mechanism in the combination function operation, the side channel information leakage caused by the combination function operation accounts for a very small proportion of the leakage in the entire chip operation process, and it is difficult to effectively capture and extract in actual scenarios; therefore, it is difficult to carry out side channel analysis on the message authentication code algorithm improved by the present invention, and the present invention better protects the secret key, and the security of the algorithm implementation is greatly improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A schematic diagram of a flow chart of a method for improving a message authentication code algorithm in one embodiment;
[0038] Figure 2 A schematic diagram of the transformation of the original message segment in one embodiment;
[0039] Figure 3 A schematic diagram of the structure of an improved message authentication code algorithm in one embodiment;
[0040] Figure 4A schematic diagram of an application scheme of the improved algorithm in chip secure startup in one embodiment;
[0041] Figure 5 A structural block diagram of a device for improving a message authentication code algorithm in one embodiment;
[0042] Figure 6 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0044] In one embodiment, Figure 1 As shown, a method for improving a message authentication code algorithm is provided, comprising the following steps:
[0045] Step 102, obtaining an initial secret key and an original message.
[0046] Assume that the initial secret key of the message authentication code algorithm is K, and the original message is m = (m1, m2, ···m n-1 ,m n ).
[0047] Step 104, obtain a derived secret key according to the initial secret key through a key derivation function, divide the original message into equal parts according to a preset length after preprocessing, and process the divided message and the derived secret key through a combination function to obtain multiple message sub-segments.
[0048] In cryptography, a key derivation function is a cryptographic hash function that uses a pseudorandom function to derive one or more secret keys from a secret value such as a master key, password, or passphrase.
[0049] Specifically, Figure 2 As shown in FIG. 1 , the derived secret key K′ is obtained according to the initial secret key K through the key derivation function d{}. Considering that the original message m may not be divided into integer groups exactly, it may be necessary to pad the original message, such as adding a number of 0s or 1s after it to form an integer multiple of a specific length L, and then dividing the padded original message into equal parts according to the length L, and dividing the equally divided messages m i The derived secret key K′ is processed by the combination function c{} to obtain multiple message sub-segments m i ′.
[0050] Step 106, using each message sub-segment in the plurality of message sub-segments as an input for each iteration of the message verification algorithm, and repeatedly performing iterative calculations until all message sub-segments are traversed to obtain a calculation result of the improved message authentication code algorithm on the original message.
[0051] The algorithm for calculating the message sub-segment in the present invention can be applied to the HMAC algorithm, and is also applicable to other classic message authentication code algorithms, such as CMAC.
[0052] In the above method for improving the message authentication code algorithm, a derived secret key is obtained according to the initial secret key through a key derivation function, the original message is preprocessed and then divided into equal parts according to a preset length, and the divided message and the derived secret key are processed through a combination function to obtain multiple message sub-segments; each message sub-segment in the multiple message sub-segments is used as the input of each iteration of the message verification algorithm, and the iterative calculation is repeated until all the message sub-segments are traversed to obtain the calculation result of the improved message authentication code algorithm on the original message. Due to the transformation of the original message segment, the message input directly involved in the hash function calculation is inconsistent with the externally controllable message input, so that it is impossible to directly construct a simple side channel analysis model such as a first-order DPA / CPA for information analysis; in addition, although there is no complex calculation logic or nonlinear transformation mechanism in the combination function operation, the side channel information leakage caused by the combination function operation accounts for a very small proportion of the leakage in the entire chip operation process, and it is difficult to effectively capture and extract in actual scenarios; therefore, it is difficult to carry out side channel analysis on the message authentication code algorithm improved by the present invention, and the present invention better protects the secret key, and the security of the algorithm implementation is greatly improved.
[0053] In one of the embodiments, it also includes: when the message authentication algorithm is the HMAC algorithm, each message sub-segment in the multiple message sub-segments is used as the input of each hash function of the message authentication algorithm, and the calculation is iterated repeatedly until all the message sub-segments are traversed to obtain the HMAC value of the improved message authentication code algorithm for the original message.
[0054] In the HMAC algorithm, the hash function is used to compress a message m of any length into data f(m) of a specified length. Specifically, Figure 3 As shown, the transformed new message segment is used as the input of the hash function f{}, the initial secret key is subjected to bitwise XOR operation with the ipad string and the opad string respectively, and then the hash operation is performed with the initial state value of the hash function to obtain the input value K of the first hash operation respectively. i and the input value K of the last hash operation o ,Right now Among them, ipad and opad are two fixed strings, which are 0x36 with B bytes repeated and 0x5C with B bytes repeated. According to the initial state value IV of the hash function and the input value K of the first hash operation i , the input value K of the last hash operation o and multiple message sub-segments, and perform multiple hash operation iterations; wherein the first hash operation is performed with the initial state value IV of the hash function and the input value K of the first hash operation i The last hash operation is based on the initial state value IV of the hash function and the input value K of the last hash operation. o The intermediate hash operations between the first and last hash operations take the output of the previous hash operation and each message sub-segment as input; and the HMAC value of the improved message authentication code algorithm for the original message is obtained.
[0055] Since the original message segment is transformed, the message input directly involved in the calculation of the hash function f{} is inconsistent with the externally controllable message input, so it is impossible to directly construct a simple side channel analysis model such as first-order DPA / CPA to analyze K i and K o At the same time, if we consider performing side channel analysis on K′ first, since there is no complex calculation logic or nonlinear transformation mechanism in the combination function c{} operation, the side channel information leakage caused by the combination function operation accounts for a very small proportion of the leakage in the entire chip operation process, and it is difficult to effectively capture and extract in actual scenarios. And for the entire improved message authentication code algorithm, if we further analyze K i and K o , it is theoretically possible to implement it with complex side channel models such as second-order DPA / CPA, and the analysis cost will increase exponentially, making it difficult to conduct effective analysis in actual scenarios. In summary, it will be very difficult to conduct side channel analysis on the improved message authentication code algorithm structure. The analyst cannot obtain the secret key, and thus cannot further forge the HMAC value, greatly improving the security of the algorithm implementation.
[0056] In one of the embodiments, the method further includes: padding the original message so that the length of the padded message is an integer multiple of a preset length; and dividing the padded message into equal parts according to the preset length.
[0057] In one of the embodiments, the method further includes: merging each equally divided message with the derived secret key bit by bit; scrambling the order of each bit of each merged message according to a specific rule to obtain a new message sub-segment; and traversing all equally divided messages to obtain multiple message sub-segments.
[0058] In one of the embodiments, the patent proposes an example of an application scheme based on the improved algorithm in chip secure booting, such as Figure 4 As shown, the initial secret key in the OTP is read through the startup code stored in the read-only memory; the hash value of the initial secret key is calculated and compared with the check value stored in the OTP. If the hash value of the initial secret key is compared with the check value stored in the OTP, the HMAC value of the original message of the improved message authentication code algorithm is obtained through the main program in the FLASH. The HMAC value of the original message of the improved message authentication code algorithm is compared with the authentication code stored in the FLASH; if the comparison is passed, the main program is loaded and run to realize the secure startup of the chip.
[0059] OTP (One Time Password) is a one-time password, also known as a "one-time password", which refers to a password that can only be used once.
[0060] Based on the improved message authentication code algorithm, the key can better resist side channel analysis during use, and the initial secret key is stored in the secure storage area of the chip. OTP is a one-time programmable unit that can effectively resist physical tampering. At the same time, the chip system storage access control mechanism is used to limit the read permission of the initial secret key, ensuring that the message authentication code algorithm key has high security during storage or use, thereby improving the security of the chip startup process.
[0061] It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0062] In one embodiment, Figure 5 As shown, a device for improving a message authentication code algorithm is provided, comprising: an initialization module 502, a message sub-segment acquisition module 504 and a calculation result output module 506, wherein:
[0063] Initialization module 502, used to obtain an initial secret key and an original message;
[0064] The message sub-segment acquisition module 504 is used to obtain a derived secret key according to the initial secret key through a key derivation function, divide the original message into equal parts according to a preset length after preprocessing, and process the divided message and the derived secret key through a combination function to obtain multiple message sub-segments;
[0065] The calculation result output module 506 is used to use each message sub-segment in the multiple message sub-segments as the input of each iteration of the message verification algorithm, and repeatedly iterate the calculation until all message sub-segments are traversed to obtain the calculation result of the improved message authentication code algorithm on the original message.
[0066] The calculation result output module 506 is also used to, when the message authentication algorithm is the HMAC algorithm, use each message sub-segment in the multiple message sub-segments as the input of each hash function of the message authentication algorithm, and repeatedly iterate the calculation until all the message sub-segments are traversed to obtain the HMAC value of the improved message authentication code algorithm for the original message.
[0067] The message sub-segment acquisition module 504 is also used to fill the original message so that the length of the filled message is an integer multiple of the preset length; and divide the filled message into equal parts according to the preset length.
[0068] The message sub-segment acquisition module 504 is also used to merge each equally divided message with the derived secret key bit by bit; after scrambling the order of each bit of each merged message according to a specific rule, a new message sub-segment is obtained; and all equally divided messages are traversed to obtain multiple message sub-segments.
[0069] The calculation result output module 506 is also used to perform a bitwise XOR operation on the initial secret key, the ipad string and the opad string, and then perform a hash operation with the initial state value of the hash function to obtain the input value K of the first hash operation. i and the input value K of the last hash operation o ; According to the initial state value IV of the hash function and the input value K of the first hash operation i , the input value K of the last hash operation o and multiple message sub-segments, and perform multiple hash operation iterations; wherein the first hash operation is performed with the initial state value IV of the hash function and the input value K of the first hash operation i The last hash operation is based on the initial state value IV of the hash function and the input value K of the last hash operation. o The intermediate hash operations between the first and last hash operations take the output of the previous hash operation and each message sub-segment as input; and the HMAC value of the improved message authentication code algorithm for the original message is obtained.
[0070] The initialization module 502 is also used to read the initial secret key in the OTP through the startup code stored in the read-only memory; calculate the hash value of the initial secret key, and compare it with the check value stored in the OTP.
[0071] The initialization module 502 is also used to calculate the hash value of the initial secret key and compare it with the check value stored in the OTP; if the hash value of the initial secret key is compared with the check value stored in the OTP, the HMAC value of the original message of the improved message authentication code algorithm is obtained through the main program in the FLASH.
[0072] The initialization module 502 is also used to compare the HMAC value of the improved message authentication code algorithm about the original message with the authentication code stored in the FLASH; if the comparison passes, the main program is loaded and run to realize chip security startup.
[0073] The specific definition of the device for improving the message authentication code algorithm can be found in the definition of the method for improving the message authentication code algorithm in the above text, which will not be repeated here. Each module in the above-mentioned device for improving the message authentication code algorithm can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0074] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for improving a message authentication code algorithm is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.
[0075] Those skilled in the art will understand that Figure 6The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0076] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above method embodiment when executing the computer program.
[0077] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiment are implemented.
[0078] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0079] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0080] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.
Claims
1. A method for improving a message authentication code algorithm, characterized in that: The method comprises: Obtaining an initial secret key and an original message; the obtaining of the initial secret key comprises: reading the initial secret key in the one-time password OTP through a startup code stored in a read-only memory, calculating a hash value of the initial secret key, and comparing it with a check value stored in the OTP; If the hash value of the initial secret key is compared with the check value stored in the OTP, the HMAC value of the original message of the improved message authentication code algorithm is obtained through the main program in the FLASH, and the HMAC value of the original message of the improved message authentication code algorithm is compared with the authentication code stored in the FLASH. If the comparison is successful, the main program is loaded and run to realize chip security startup; The HMAC value of the improved message authentication code algorithm for the original message includes: A derived secret key is obtained according to the initial secret key through a key derivation function, the original message is pre-processed and then divided into equal parts according to a preset length, and the divided messages and the derived secret key are processed through a combination function to obtain a plurality of message sub-segments; the divided messages and the derived secret key are processed through a combination function to obtain a plurality of message sub-segments, including: merging each of the divided messages with the derived secret key bit by bit, and obtaining a new message sub-segment after disrupting the order of each bit of each merged message according to a specific rule, and traversing all the divided messages to obtain a plurality of message sub-segments; Each message sub-segment of the multiple message sub-segments is used as the input of each iteration of the message verification algorithm, and the iterative calculation is repeated until all the message sub-segments are traversed to obtain the calculation result of the improved message authentication code algorithm on the original message; the message verification algorithm is the HMAC algorithm, and the calculation result is the HMAC value of the improved message authentication code algorithm on the original message.
2. The method according to claim 1, characterized in that The original message is pre-processed and divided into equal parts according to a preset length, including: Padding the original message so that the length of the padded message is an integer multiple of a preset length; The padded message is divided into equal parts according to the preset length.
3. The method according to claim 2, characterized in that Using each message sub-segment of the multiple message sub-segments as the input of each iteration of the message verification algorithm, repeatedly iterating the calculation until all message sub-segments are traversed, and obtaining the calculation result of the improved message authentication code algorithm on the original message; The message authentication algorithm is an HMAC algorithm, and the calculation result is an HMAC value of the improved message authentication code algorithm with respect to the original message, including: After performing bitwise XOR operation on the initial secret key, the ipad string and the opad string, respectively, a hash operation is performed with the initial state value of the hash function to obtain the input value Ki of the first hash operation and the input value Ko of the last hash operation respectively; Perform multiple hash operation iterations according to the initial state value IV of the hash function, the input value Ki of the first hash operation, the input value Ko of the last hash operation and the multiple message sub-segments; wherein the first hash operation takes the first message sub-segment and the input value Ki of the first hash operation as input, the last hash operation takes the output of the previous hash operation and the input value Ko of the last hash operation as input, and the intermediate hash operations between the first and last hash operations take the output of the previous hash operation and each message sub-segment as input; The calculation result of the improved message authentication code algorithm on the original message is obtained; the message authentication algorithm is the HMAC algorithm, and the calculation result is the HMAC value of the improved message authentication code algorithm on the original message.
4. A device for improving a message authentication code algorithm, characterized in that: The device comprises: An initialization module is used to obtain an initial secret key and an original message; the obtaining of the initial secret key includes: reading the initial secret key in the one-time password OTP through a startup code stored in a read-only memory, calculating a hash value of the initial secret key, and comparing it with a check value stored in the OTP; If the hash value of the initial secret key is compared with the check value stored in the OTP, the HMAC value of the original message of the improved message authentication code algorithm is obtained through the main program in the FLASH, and the HMAC value of the original message of the improved message authentication code algorithm is compared with the authentication code stored in the FLASH. If the comparison is successful, the main program is loaded and run to realize chip security startup; The HMAC value of the improved message authentication code algorithm for the original message includes: A message sub-segment acquisition module, used to obtain a derived secret key according to the initial secret key through a key derivation function, pre-process the original message and divide it into equal parts according to a preset length, and process the equally divided messages and the derived secret key through a combination function to obtain multiple message sub-segments; the equally divided messages and the derived secret key are processed through a combination function to obtain multiple message sub-segments, including: merging each equally divided message with the derived secret key bit by bit, and obtaining a new message sub-segment after disrupting the order of each bit of each merged message according to a specific rule, and traversing all equally divided messages to obtain multiple message sub-segments; A calculation result output module is used to use each message sub-segment of the multiple message sub-segments as the input of each iteration of the message verification algorithm, repeatedly iterate the calculation until all message sub-segments are traversed, and obtain the calculation result of the improved message authentication code algorithm on the original message; the message verification algorithm is the HMAC algorithm, and the calculation result is the HMAC value of the improved message authentication code algorithm on the original message.
5. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 3 are implemented.
Citation Information
Patent Citations
Method and system for constructing MAC (Media Access Control) code by utilizing packet mode
CN102946315A
Side channel energy analysis method for SM3 cryptographic algorithm HMAC mode
CN103457719A
Anti-attack method and device of password module based on SM3 algorithm
CN106330424A
Side channel energy analysis method and device for SM3-HMAC
CN106656459A
Hardware optimization method based on SM3 password hash algorithm
CN107579811A
