Data encryption method, data encryption device and electronic equipment
By supporting the configuration and activation of multiple protection functions, the problem that the cryptographic algorithm hardware architecture in the existing technology is difficult to adapt to different needs and scenarios, and the multi-level application support for security and performance is realized, and the application flexibility of the data encryption architecture is improved. sex.
Patent Information
- Application Number
- CN202310960662.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-31
- Publication Date
- 2025-02-18
AI Technical Summary
The prior art is difficult to adapt to different needs and scenarios when implementing high-performance and high-security cryptographic algorithm hardware architectures, and protection measures against side channel attacks and fault injection attacks are usually at the expense of algorithm performance and chip area.
By providing a data encryption method and device, it supports the configuration and activation of multiple protection functions, generates protection enable instructions based on external protection configuration information, and performs encryption calculations corresponding to the enabled protection functions, thereby meeting different scenarios and needs. encryption operation.
It realizes multi-level application support for security and performance, improves the applicable flexibility of the data encryption architecture, can meet users' security and performance needs in different scenarios, and avoids the limitations that performance and security cannot be achieved.
Smart Images

Figure CN119475362A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of data encryption, and in particular to a data encryption method, a data encryption device, and an electronic device. Background Art
[0002] In chip products such as vehicle control chips that require high information security, cryptographic algorithms such as the SM2 algorithm are often embedded to ensure the privacy and security of data. These cryptographic algorithms are considered to have strong security in mathematical theory. However, in the actual working process of the chip, it may face security threats such as side channel attacks and fault injection attacks. Side channel attacks mainly use the leakage of side information (such as time, electromagnetic, power consumption, etc.) during the operation of the cryptographic algorithm, and attack by analyzing the dependency between the side information and the secret information. Fault injection attacks cause the algorithm to run incorrectly through external electromagnetic or voltage injection during the operation of the cryptographic algorithm, allowing the attacker to skip security authentication to obtain permissions, or analyze the wrong operation results to obtain secret information. Anti-attack cryptographic algorithm architectures can provide effective security protection against side channel attacks and fault injection attacks, but usually at the expense of algorithm performance and chip area.
[0003] As high performance and high security of cryptographic algorithms are often not achieved at the same time, how to make the hardware architecture of cryptographic algorithms adapt to different needs and scenarios has become a technical problem that needs to be solved urgently. Summary of the invention
[0004] The embodiments of the present disclosure provide a data encryption method, a data encryption device, and an electronic device.
[0005] In a first aspect, an embodiment of the present disclosure provides a data encryption method, comprising: obtaining protection configuration information; determining an enabled protection function according to the protection configuration information, and generating a protection enable instruction; and performing encryption calculations on data according to the protection enable instruction.
[0006] In a second aspect, an embodiment of the present disclosure provides a data encryption device, comprising: an interface module, used to obtain protection configuration information; a protection control module, used to determine the enabled protection function according to the protection configuration information and generate a protection enable instruction; and a calculation module, used to perform encryption calculations on data according to the protection enable instruction.
[0007] In a third aspect, an embodiment of the present disclosure provides an electronic device, comprising the data encryption device described in the second aspect of the embodiment of the present disclosure.
[0008] In the disclosed embodiments, the data encryption architecture includes a variety of protection functions, and supports enabling all or part of the protection functions through protection configuration information configuration, that is, supports external custom protection requirements. After all or part of the protection functions are enabled through external configuration, encryption calculations corresponding to the enabled protection functions are performed on the data, thereby being able to meet encryption operations in different scenarios and with different requirements. For example, in application scenarios with high protection security requirements, strong security is ensured by enabling more protection functions; in application scenarios with high performance requirements, high performance is ensured by turning off most protection functions. This achieves support for applications with multiple levels of security and performance, and can be applied to a variety of application scenarios with large differences in security requirements and performance requirements, improving the applicability and flexibility of the data encryption architecture, and is conducive to meeting the different security and performance requirements of users. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Figure 1 is a flow chart of a data encryption method in an embodiment of the present disclosure;
[0010] Figure 2 is a flowchart of some steps in another data encryption method in an embodiment of the present disclosure;
[0011] Figure 3 It is a schematic diagram of the composition of a data encryption device in an embodiment of the present disclosure;
[0012] Figure 4 It is a schematic diagram of the composition of another data encryption device in an embodiment of the present disclosure;
[0013] Figure 5 is a schematic diagram of the composition of an electronic device in an embodiment of the present disclosure;
[0014] Figure 6 It is a schematic diagram of the composition of a hardware architecture for data encryption in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0015] In order to enable those skilled in the art to better understand the technical solution of the present disclosure, the data encryption method, data encryption device, and electronic device provided by the present disclosure are described in detail below in conjunction with the accompanying drawings.
[0016] Example embodiments will be described more fully below with reference to the accompanying drawings, but the example embodiments may be embodied in different forms and should not be construed as limited to the embodiments set forth herein. On the contrary, the purpose of providing these embodiments is to make the present disclosure thorough and complete and to enable those skilled in the art to fully understand the scope of the present disclosure.
[0017] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.
[0018] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.
[0019] The terms used herein are only used to describe specific embodiments and are not intended to limit the present disclosure. As used herein, the singular forms "a", "an" and "the" are also intended to include the plural forms, unless the context clearly indicates otherwise. It will also be understood that when the terms "comprising" and / or "made of" are used in this specification, the presence of the features, wholes, steps, operations, elements and / or components is specified, but the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or groups thereof is not excluded.
[0020] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by those of ordinary skill in the art. It will also be understood that terms such as those defined in commonly used dictionaries should be interpreted as having a meaning consistent with their meaning in the context of the relevant art and the present disclosure, and will not be interpreted as having an idealized or overly formal meaning unless explicitly defined as such herein.
[0021] In the SM2 algorithm flow, the dot product calculation P A =[d A ]G. Modular multiplication calculation r*d A , modular inverse calculation (1+d A ) -1 , both have private key d A direct participation, and in addition to d A If the rest is known information, the attacker can collect a large number of energy curves and perform differential power consumption or correlation power consumption analysis on the energy consumption curves to crack d A In addition, there are many judgment branches in the SM2 algorithm process. Attackers may cause the cryptographic algorithm to enter the wrong judgment branch through fault injection attacks, thereby affecting the normal function and security of the chip. If the algorithm still outputs incorrect related information in the case of calculation errors, attackers can also use this information to deduce some secret information. Therefore, in application scenarios with high security requirements (such as vehicle control chips, password keys, etc.), the implementation of the SM2 cryptographic algorithm must have complete side channel attack and fault injection attack protection measures to prevent attackers from obtaining password information and protect the personal and property safety of consumers.
[0022] In some related technologies, the security protection scheme for the SM2 algorithm mainly focuses on the protection of point multiplication, because this calculation step is most vulnerable to side channel attacks, has low implementation difficulty, and has many related studies; while there are fewer studies on attacks on large number modular multiplication and modular inversion, and no corresponding protection schemes are provided, which has security defects. Therefore, as the intensity of side channel attacks increases and the number of attack methods increases, the protection measures also need to be continuously improved and enhanced.
[0023] In some related technologies, the SM2 algorithm protection scheme mainly focuses on protecting against mainstream attack methods such as simple power consumption and differential power consumption in side channel attacks, but lacks protection schemes for fault injection attacks that are more difficult to implement and attack, and also has security defects.
[0024] Although the anti-attack SM2 cryptographic algorithm architecture provides effective security protection, it sacrifices algorithm performance and chip area, resulting in reduced algorithm performance and increased resources. As a public key cryptographic algorithm, the SM2 algorithm has a relatively complex and time-consuming calculation process. After adding security protection measures, the performance is further weakened, that is, high performance and high security cannot be achieved at the same time. When faced with multi-scenario applications with large differences in security requirements and performance requirements, the hardware architecture has poor applicability and flexibility.
[0025] In view of this, firstly, refer to Figure 1 , the present disclosure provides a data encryption method, including:
[0026] S1. Obtain protection configuration information;
[0027] S2. Determine the protection function to be enabled according to the protection configuration information, and generate a protection enabling instruction;
[0028] S3. Perform encryption calculation corresponding to the enabled protection function on the data according to the protection enabling instruction.
[0029] The data encryption architecture provided by the embodiments of the present disclosure is applied to chip products such as secure communication systems, smart integrated circuits, password keys, vehicle control chips, and security chips.
[0030] In the disclosed embodiment, the data encryption architecture includes a variety of protection functions. The disclosed embodiment does not specifically limit the protection functions supported by the data encryption architecture. For example, the protection functions include z-random, k-random, same block operation, redundant operation, modular multiplication blinding, modular inverse blinding, coordinate detection, repeated calculation, etc. In the disclosed embodiment, the various protection functions in the data encryption architecture can provide security protection against various attacks.
[0031] In the disclosed embodiment, external customized protection requirements are supported, that is, all or part of the protection functions are enabled through configuration. In the disclosed embodiment, the protection configuration information is information used to configure whether various security protection functions in the data encryption architecture are enabled.
[0032] In the embodiments of the present disclosure, after all or part of the protection functions are enabled in the external configuration, encryption calculations corresponding to the enabled protection functions are performed on the data, so that encryption operations in different scenarios and with different requirements can be met. For example, in application scenarios with high protection security requirements, strong security is ensured by enabling more protection functions; in application scenarios with high performance requirements, high performance is ensured by disabling most protection functions.
[0033] The data encryption method provided by the embodiments of the present disclosure supports multi-level applications of security and performance, can be applied to a variety of application scenarios with large differences in security requirements and performance requirements, and improves the applicability and flexibility of the data encryption architecture.
[0034] In the disclosed embodiment, each protection function can be enabled or disabled by external configuration. For example, each protection function corresponds to a protection control register, and the configuration value of the protection control register represents whether the corresponding protection function is enabled or disabled. The external device can enable or disable a custom protection function by configuring the configuration value of the protection control register.
[0035] Accordingly, in some embodiments, obtaining protection configuration information includes:
[0036] A configuration value configured to at least one protection control register is received, wherein the protection configuration information includes the configuration value of the at least one protection control register, the protection control register corresponds to a protection function one-to-one, and the configuration value of the protection control register represents whether the corresponding protection function is enabled.
[0037] In the embodiments of the present disclosure, it also supports pre-setting the protection level according to the usage scenario. Different protection functions are enabled at different protection levels. There is no need to configure each protection function to be enabled or disabled externally. You only need to select the corresponding protection level according to security and performance requirements to enable the corresponding protection function at that protection level.
[0038] Accordingly, in some embodiments, obtaining protection configuration information includes:
[0039] Receive protection level information;
[0040] The configuration value of at least one protection control register is configured according to the protection level information, wherein the protection configuration information includes the configuration value of the at least one protection control register, the protection control register corresponds to a protection function one by one, and the configuration value of the protection control register represents whether the corresponding protection function is enabled.
[0041] In some embodiments, before obtaining the protection configuration information, the data encryption method further includes:
[0042] Determine the protection functions that need to be enabled corresponding to each of the protection levels.
[0043] In some embodiments, determining the enabled protection function according to the protection configuration information and generating a protection enabling instruction includes:
[0044] The protection enable instruction is generated according to the configuration values of each of the protection control registers.
[0045] In some embodiments, reference Figure 2 , performing encryption calculations corresponding to the enabled protection function on the data according to the protection enabling instruction, including:
[0046] S31, determining a calculation process corresponding to the enabled protection function according to the protection enabling instruction;
[0047] S32. Perform encryption calculation on the data according to the calculation process.
[0048] In some embodiments, determining a calculation process corresponding to the enabled protection function according to the protection enabling instruction includes:
[0049] Determining a target protection function according to the computing mode represented by the computing instruction and the protection enabling instruction, wherein the target protection function is an enabled protection function corresponding to the computing mode;
[0050] Select the corresponding calculation process according to the target protection function and calculation mode.
[0051] The embodiments of the present disclosure do not specifically limit the protection functions in the data encryption architecture. In some embodiments, the protection functions include at least one of z random, k random, same block operation, redundant operation, modular multiplication blinding, modular inverse blinding, coordinate detection, and repeated calculation.
[0052] z random refers to the randomization of the projection coordinate z: external input random value z and the coordinate to be calculated, the input coordinate (X, Y) is projected to the Jacobian weighted projection coordinate system, and the new coordinate (xz 2 , yz 3 ,z), the purpose is to blind the calculation data, which has little effect on the performance of the point multiplication algorithm.
[0053] Same block operations: In some embodiments, the point addition and doubling in the dot product calculation are split into a series of "modular multiplication + modular addition + modular subtraction" same block operations, as shown in Table 1, in order to hide the operations, which will cause the performance of the dot product algorithm to be reduced by about 10%.
[0054] Table 1
[0055]
[0056]
[0057] The corresponding dummy indicates that the corresponding calculation is a virtual calculation, which will not affect the calculation results of the dot multiplication operation or the dot multiplication operation.
[0058] As shown in Table 1, the doubling operation corresponds to the first operation blocks 1 to 14, and the dot addition operation corresponds to the second operation blocks 1 to 14. The calculation process in each pair of corresponding first operation blocks is the same as the calculation process in the second operation block. For example, the calculation process of the first operation block and the second operation block is modular multiplication + modular addition + modular subtraction. By using the same block operation, the power consumption and time of the doubling operation and the dot addition operation are the same, so that the specific operation can be hidden and resist power consumption analysis.
[0059] Redundant operations: Adding several redundant identical block operations makes the time consumption of point addition and dot multiplication calculation the same, in order to hide the operations and time, which will cause the performance of the dot multiplication algorithm to decrease by about 15%.
[0060] k-random refers to the randomization of the multiplication coefficient k: external input random value r and multiplication coefficient k, calculate k′=r*n+k (n is the order of the elliptic curve base point). The calculation result k ′ As a new dot multiplication coefficient, it participates in the dot multiplication operation to blind the calculated data. When the r value is large, the performance will be greatly affected. It is recommended that the bit width does not exceed 32 bits, which will cause the dot multiplication algorithm performance to decrease by about 10%;
[0061] Modular multiplication blinding: For modular multiplication calculation x*y(mod n), assuming that x is secret information and y is known information, the following operations are performed as shown in Table 2. The random number m introduced in the calculation process blinds the data. In the SM2 algorithm, there are very few modular multiplication calculation steps involving secret information, and the performance loss caused by blinding is negligible compared to the entire algorithm.
[0062] Table 2
[0063]
[0064] Modular inverse blinding: For modular inverse calculation x-1 (mod n), assuming that x is secret information, the following operations are performed as shown in Table 3. The random number m introduced in the calculation process blinds the data. Similarly, in the SM2 algorithm, there are very few modular exponentiation calculation steps involving secret information, and the performance loss caused by blinding is negligible compared to the entire algorithm.
[0065] Table 3
[0066]
[0067] Coordinate detection: Substitute the coordinate value of the external input or the coordinate value of the point operation result into the curve for operation to determine whether the point is on the curve, as shown in Table 4. If an error is detected, no result is output and an alarm is output. This function is used to determine whether the calculation process has suffered a fault injection attack and caused unknown errors, and has little impact on the algorithm performance.
[0068] Table 4
[0069]
[0070] Repeated calculation: key calculation steps in the SM2 algorithm that involve secret information, such as P B =[d B ]G and s = ((1 + d A ) -1 ·(kr·d A ))modp, repeat the calculation, and only output the result when the two calculation results are exactly the same, otherwise no result is output and an alarm is output. This function is used to determine whether the algorithm has suffered a fault injection attack during operation, resulting in unknown errors. At the same time, the algorithm performance will be reduced by 50% due to the calculation twice.
[0071] Accordingly, in some embodiments, a corresponding calculation process is selected according to the target protection function and the calculation mode, including:
[0072] When the same block operation is enabled, the dot doubling operation and the dot addition operation in the dot multiplication calculation are decomposed into the same block operation, wherein the dot doubling operation in the same block operation corresponds to multiple first operation blocks, and the dot addition operation corresponds to multiple second operation blocks, and the calculation process in the first operation blocks is the same as the calculation process in the second operation blocks.
[0073] In some embodiments, the dot multiplication operation and the dot addition operation in the dot multiplication calculation are decomposed into the same block operations, including:
[0074] According to a preset calculation process, virtual calculation is added to the calculation process of doubling point operation to obtain a plurality of the first operation blocks;
[0075] According to the preset calculation process, virtual calculation is added to the calculation process of point addition operation to obtain multiple second operation blocks.
[0076] In some embodiments, selecting a corresponding calculation process according to the target protection function and the calculation mode also includes:
[0077] When redundant operation is enabled, redundant blocks are added to the calculation process of doubling point operation and / or the calculation process of point addition operation, wherein the redundant blocks are composed of virtual calculations that satisfy the preset calculation process.
[0078] In some embodiments, performing encryption calculation on data according to the calculation process includes:
[0079] Get data;
[0080] The data is encrypted and calculated according to the calculation process.
[0081] Second, refer to Figure 3 , the present disclosure provides a data encryption device, comprising:
[0082] Interface module 110, used to obtain protection configuration information;
[0083] The protection control module 120 is used to determine the enabled protection function according to the protection configuration information and generate a protection enabling instruction;
[0084] The calculation module 130 is used to perform encryption calculations corresponding to the enabled protection function on the data according to the protection enabling instruction.
[0085] The data encryption architecture provided by the embodiments of the present disclosure is applied to chip products such as secure communication systems, smart integrated circuits, password keys, vehicle control chips, and security chips.
[0086] In the disclosed embodiment, the data encryption architecture includes a variety of protection functions. The disclosed embodiment does not specifically limit the protection functions supported by the data encryption architecture. For example, the protection functions include z-random, k-random, same block operation, redundant operation, modular multiplication blinding, modular inverse blinding, coordinate detection, repeated calculation, etc. In the disclosed embodiment, the various protection functions in the data encryption architecture can provide security protection against various attacks.
[0087] In the disclosed embodiment, external customized protection requirements are supported, that is, all or part of the protection functions are enabled through configuration. In the disclosed embodiment, the protection configuration information is information used to configure whether various security protection functions in the data encryption architecture are enabled.
[0088] In the embodiments of the present disclosure, after all or part of the protection functions are enabled in the external configuration, encryption calculations corresponding to the enabled protection functions are performed on the data, so that encryption operations in different scenarios and with different requirements can be met. For example, in application scenarios with high protection security requirements, strong security is ensured by enabling more protection functions; in application scenarios with high performance requirements, high performance is ensured by disabling most protection functions.
[0089] The data encryption device provided by the embodiment of the present disclosure supports multi-level applications of security and performance, and can be applied to a variety of application scenarios with large differences in security requirements and performance requirements, thereby improving the applicability and flexibility of the data encryption architecture.
[0090] In the disclosed embodiment, each protection function can be enabled or disabled by external configuration. For example, each protection function corresponds to a protection control register, and the configuration value of the protection control register represents whether the corresponding protection function is enabled or disabled. The external device can enable or disable a custom protection function by configuring the configuration value of the protection control register.
[0091] Accordingly, in some embodiments, the protection control module includes a plurality of protection control registers, the protection control registers correspond to protection functions one by one, and the configuration value of the protection control register represents whether the corresponding protection function is enabled;
[0092] The interface module is used to receive a configuration value configured to at least one protection control register, wherein the protection configuration information includes the configuration value of the at least one protection control register.
[0093] In the embodiments of the present disclosure, it also supports pre-setting the protection level according to the usage scenario. Different protection functions are enabled at different protection levels. There is no need to configure each protection function to be enabled or disabled externally. You only need to select the corresponding protection level according to security and performance requirements to enable the corresponding protection function at that protection level.
[0094] In some embodiments, the protection control module includes a plurality of protection control registers, the protection control registers correspond to protection functions one by one, and the configuration value of the protection control register represents whether the corresponding protection function is enabled;
[0095] The interface module is used to receive protection level information; configure the configuration value of at least one protection control register according to the protection level information, wherein the protection configuration information includes the configuration value of the at least one protection control register.
[0096] In some embodiments, the data encryption device further includes:
[0097] The protection level configuration module is used to determine the protection functions that need to be enabled corresponding to each protection level.
[0098] In some embodiments, the protection control module is used to generate the protection enable instruction according to the configuration value of each of the protection control registers.
[0099] In some embodiments, reference Figure 4 , the computing module 130 includes a computing control module 131 and a domain computing module 132;
[0100] The calculation control module 131 is used to determine the calculation process corresponding to the enabled protection function according to the protection enabling instruction;
[0101] The domain operation module 132 is used to perform encryption calculations on data according to the calculation process.
[0102] In some embodiments, the computing control module is used to determine the target protection function based on the computing mode represented by the computing instruction and the protection enable instruction, wherein the target protection function is the enabled protection function corresponding to the computing mode; and select the corresponding computing process based on the target protection function and the computing mode.
[0103] In some embodiments, the computing control module is used to decompose the dot multiplication operation and the dot addition operation in the dot multiplication calculation into the same block operations when the same block operations are enabled, wherein the dot multiplication operation in the same block operation corresponds to multiple first operation blocks, and the dot addition operation corresponds to multiple second operation blocks, and the computing process in the first operation blocks is the same as the computing process in the second operation blocks.
[0104] In some embodiments, the calculation control module is used to add virtual calculations to the calculation process of doubling operations according to a preset calculation process to obtain multiple first operation blocks; and to add virtual calculations to the calculation process of point addition operations according to the preset calculation process to obtain multiple second operation blocks.
[0105] In some embodiments, the computing control module is also used to add redundant blocks in the computing process of doubling operations and / or the computing process of point addition operations when redundant operations are enabled, wherein the redundant blocks are composed of virtual calculations that satisfy the preset computing process.
[0106] In some embodiments, reference Figure 4 , the computing module 130 further includes a storage module 133;
[0107] The domain operation module 132 obtains data from the storage module 133 and performs encryption calculation on the data according to the calculation process.
[0108] In some embodiments, the protection function includes at least one of z-random, k-random, same block operation, redundant operation, modular multiplication blinding, modular inverse blinding, coordinate detection, and repeated calculation.
[0109] Thirdly, refer to Figure 5 An embodiment of the present disclosure provides an electronic device, including the data encryption device described in the second aspect of the embodiment of the present disclosure.
[0110] In a fourth aspect, an embodiment of the present disclosure provides an electronic device, comprising:
[0111] one or more processors;
[0112] A memory having one or more programs stored thereon, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the data encryption method described in the first aspect of the embodiment of the present disclosure;
[0113] One or more I / O interfaces are connected between the processor and the memory and are configured to implement information exchange between the processor and the memory.
[0114] Among them, the processor is a device with data processing capabilities, including but not limited to the central processing unit (CPU) and the like; the memory is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory (FLASH); the I / O interface (read-write interface) is connected between the processor and the memory, and can realize information exchange between the processor and the memory, including but not limited to the data bus (Bus) and the like.
[0115] In some embodiments, the processor, memory, and I / O interface are connected to each other and, in turn, to other components of the computing device via a bus.
[0116] In a fifth aspect, an embodiment of the present disclosure provides a computer-readable medium on which a computer program is stored. When the program is executed by a processor, the data encryption method described in the first aspect of the embodiment of the present disclosure is implemented.
[0117] In order to enable those skilled in the art to more clearly understand the technical solutions provided by the embodiments of the present disclosure, the technical solutions provided by the embodiments of the present disclosure are described in detail below through specific embodiments:
[0118] Embodiment 1
[0119] In this embodiment, the hardware architecture of data encryption is as follows Figure 6 As shown, it includes an interface module, a protection control module, a calculation control module, a domain operation module, and a storage module.
[0120] The interface module uses a static random-access memory (SRAM) interface, which allows users to access the protection control registers and storage modules inside the module by adapting various bus interfaces.
[0121] The protection control module receives external protection configuration information through the interface module, and after processing, outputs the corresponding protection enable signaling to the calculation control module. The protection control module contains protection control registers such as z random, k random, same block operation, redundant operation, blinded modular multiplication operation, blinded modular inverse operation, coordinate detection and repeated calculation. By configuring the configuration values of these protection control registers, SM2 operations with different security levels can be realized externally.
[0122] The calculation control module receives external calculation instructions through the interface module, and then receives the protection enable instruction from the protection control module. It selects different calculation processes based on this information, and finally schedules the domain operation module according to the process to realize complex calculations. The calculation control module includes point multiplication, pre-calculation, doubling point, point addition, modular multiplication blinding, modular inverse blinding, point verification and coordinate transformation sub-modules. The module internally schedules the domain operation module through the state machine to realize elliptic curve point multiplication calculation, Montgomery pre-calculation, elliptic curve point addition calculation, elliptic curve doubling point calculation, modular multiplication calculation with blinding operation, modular inverse calculation with blinding operation, verification calculation of coordinate points on elliptic curve and calculation of elliptic curve projection coordinate transformation.
[0123] The domain operation module reads data from the storage module under the instruction control of the calculation control module and then performs calculations. After the calculation is completed, the calculation results are written back to the storage module. The domain operation module contains modular addition, modular subtraction, modular multiplication and modular inverse submodules, which are used to implement large number modular addition, modular subtraction, modular multiplication and modular inverse calculations under the specified prime field.
[0124] The storage module is responsible for storing calculation input data, calculation intermediate data and calculation output data.
[0125] This hardware architecture has complete protection measures against side-channel attacks and fault injection attacks. It also supports the reconstruction of security protection levels through external configuration of protection control modules to achieve differentiated security protection and performance parameters. It is suitable for SM2 cryptographic algorithm hardware accelerators in various demand scenarios.
[0126] Embodiment 2
[0127] This embodiment is based on the hardware architecture of the first embodiment, and the data encryption process includes:
[0128] 1. Configure the calculation control information and protection control information through the interface module, and then write the elliptic curve parameters and the data to be calculated into the storage module;
[0129] 2. The protection control module determines which protection functions are enabled based on external configuration information. All protection functions are as follows:
[0130] z random refers to the randomization of the projection coordinate z: external input random value z and the coordinate to be calculated, the input coordinate (X, Y) is projected to the Jacobian weighted projection coordinate system, and the new coordinate (xz 2 , yz 3 ,z), the purpose is to blind the calculation data, which has little effect on the performance of the point multiplication algorithm.
[0131] Same block operations: In some embodiments, the point addition and doubling in the dot product calculation are split into a series of "modular multiplication + modular addition + modular subtraction" same block operations, as shown in Table 1, in order to hide the operations, which will cause the performance of the dot product algorithm to be reduced by about 10%.
[0132] Redundant operations: Adding several redundant identical block operations makes the time consumption of point addition and dot multiplication calculation the same, in order to hide the operations and time, which will cause the performance of the dot multiplication algorithm to decrease by about 15%.
[0133] k-random refers to the randomization of the multiplication coefficient k: external input random value r and multiplication coefficient k, calculate k′=r*n+k (n is the order of the elliptic curve base point). The calculation result k ′ As a new dot multiplication coefficient, it participates in the dot multiplication operation to blind the calculated data. When the r value is large, the performance will be greatly affected. It is recommended that the bit width does not exceed 32 bits, which will cause the dot multiplication algorithm performance to decrease by about 10%;
[0134] Modular multiplication blinding: For modular multiplication calculation x*y(mod n), assuming that x is secret information and y is known information, the operations shown in Table 2 are performed. The random number m introduced in the calculation process blinds the data. In the SM2 algorithm, there are very few modular multiplication calculation steps involving secret information, and the performance loss caused by blinding is negligible compared to the entire algorithm.
[0135] Modular inverse blinding: For modular inverse calculation x-1 (mod n), assuming that x is secret information, the operations shown in Table 3 are performed, and the random number m introduced in the calculation process blinds the data. Similarly, in the SM2 algorithm, there are very few modular exponentiation calculation steps involving secret information, and the performance loss caused by blinding is negligible compared to the entire algorithm.
[0136] Coordinate detection: Substitute the coordinate value of the external input or the coordinate value of the point operation result into the curve for operation to determine whether the point is on the curve, as shown in Table 4. If an error is detected, no result is output and an alarm is output. This function is used to determine whether the calculation process has suffered a fault injection attack and caused unknown errors, and has little impact on the algorithm performance.
[0137] Repeated calculation: key calculation steps in the SM2 algorithm that involve secret information, such as P B =[d B ]G and s = ((1 + d A ) -1 ·(kr·d A ))modp, repeat the calculation, and only output the result when the two calculation results are exactly the same, otherwise no result is output and an alarm is output. This function is used to determine whether the algorithm has suffered a fault injection attack during operation, resulting in unknown errors. At the same time, the algorithm performance will be reduced by 50% due to the calculation twice.
[0138] 3. The computing control module selects and executes the corresponding computing state machine process according to the computing control information and the protection control information, and continuously schedules the domain computing module according to the process to complete the entire calculation. The process is as follows:
[0139] If the calculation mode is selected as dot product calculation:
[0140] Determine whether to enable the randomization of the projection coordinate z. If enabled, perform the randomization calculation of the projection coordinate;
[0141] Determine whether to enable randomization of the point multiplication coefficient k. If enabled, perform randomization calculation of the point multiplication coefficient.
[0142] Start the dot multiplication calculation and determine whether the same block operation and redundant operation are enabled. If enabled, perform the dot addition and doubling calculations according to the steps in Table 1. If not enabled, skip the dummy step.
[0143] Convert the dot product calculation result under the projection coordinates back to the affine coordinates;
[0144] Determine whether repeated calculation is enabled. If enabled, repeat the above calculation process (1)-(4) and compare the two calculation results. If they are different, output an error interrupt and the calculation ends.
[0145] Determine whether coordinate detection is enabled. If enabled, perform coordinate detection calculation on the point multiplication result according to the process in Table 4. If the point is not on the curve, an error interrupt is output and the calculation ends.
[0146] If the calculation mode is selected as modular multiplication calculation:
[0147] Determine whether to enable blind modular multiplication. If enabled, perform calculation according to the process shown in Table 2. Otherwise, perform ordinary modular multiplication calculation.
[0148] If the calculation mode is modular inverse calculation:
[0149] Determine whether to enable modular inverse blinding. If enabled, perform calculations according to the process shown in Table 3; otherwise, perform ordinary modular inverse calculations.
[0150] 4. The calculation start and domain operation selection instructions of the calculation control module are sent to the domain operation module in the process sequence. The domain operation module reads the calculation data from the storage module, completes the corresponding prime domain operation, and then writes the calculation results back to the storage module;
[0151] 5. After the calculation is completed, the calculation completion signal or calculation error signal is output to the outside world through the top-level interface module, and the outside world then reads the calculation result data from the storage module through the top-level interface module.
[0152] It will be appreciated by those skilled in the art that all or some of the steps, systems, and functional modules / units in the methods disclosed above may be implemented as software, firmware, hardware, and appropriate combinations thereof. In hardware implementations, the division between the functional modules / units mentioned in the above description does not necessarily correspond to the division of physical components; for example, a physical component may have multiple functions, or a function or step may be performed by several physical components in cooperation. Some or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor, or a microprocessor, or implemented as hardware, or implemented as an integrated circuit, such as an application-specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or non-transitory medium) and a communication medium (or temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as computer-readable instructions, data structures, program modules, or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tapes, magnetic disk storage or other magnetic storage devices, or any other medium that can be used to store the desired information and can be accessed by a computer. In addition, it is well known to those skilled in the art that communication media typically contain computer-readable instructions, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.
[0153] Example embodiments have been disclosed herein, and although specific terms are employed, they are used and should be interpreted only in a general illustrative sense and not for limiting purposes. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly noted, features, characteristics, and / or elements described in conjunction with a particular embodiment may be used alone or in combination with features, characteristics, and / or elements described in conjunction with other embodiments. Therefore, those skilled in the art will appreciate that various changes in form and detail may be made without departing from the scope of the present disclosure as set forth in the appended claims.
Claims
1. A data encryption method, comprising: Get protection configuration information; Determine the protection function to be enabled according to the protection configuration information, and generate a protection enabling instruction; An encryption calculation corresponding to the enabled protection function is performed on the data according to the protection enabling instruction.
2. The data encryption method according to claim 1, wherein: Obtain protection configuration information, including: A configuration value configured to at least one protection control register is received, wherein the protection configuration information includes the configuration value of the at least one protection control register, the protection control register corresponds to a protection function one-to-one, and the configuration value of the protection control register represents whether the corresponding protection function is enabled.
3. The data encryption method according to claim 1, wherein: Obtain protection configuration information, including: Receive protection level information; The configuration value of at least one protection control register is configured according to the protection level information, wherein the protection configuration information includes the configuration value of the at least one protection control register, the protection control register corresponds to a protection function one by one, and the configuration value of the protection control register represents whether the corresponding protection function is enabled.
4. The data encryption method according to claim 3, wherein: Before obtaining the protection configuration information, the data encryption method further includes: Determine the protection functions that need to be enabled corresponding to each of the protection levels.
5. The data encryption method according to any one of claims 2 to 4, wherein: Determining the enabled protection function according to the protection configuration information and generating a protection enabling instruction includes: The protection enable instruction is generated according to the configuration values of each of the protection control registers.
6. The data encryption method according to any one of claims 1 to 4, wherein: Performing encryption calculations corresponding to the enabled protection function on the data according to the protection enabling instruction includes: Determining a calculation process corresponding to the enabled protection function according to the protection enabling instruction; Perform encryption calculation on the data according to the calculation process.
7. The data encryption method according to claim 6, wherein: Determining a calculation process corresponding to the enabled protection function according to the protection enabling instruction includes: Determining a target protection function according to the computing mode represented by the computing instruction and the protection enabling instruction, wherein the target protection function is an enabled protection function corresponding to the computing mode; Select the corresponding calculation process according to the target protection function and calculation mode.
8. The data encryption method according to claim 7, wherein: Select the corresponding calculation process according to the target protection function and calculation mode, including: When the same block operation is enabled, the dot doubling operation and the dot addition operation in the dot multiplication calculation are decomposed into the same block operation, wherein the dot doubling operation in the same block operation corresponds to multiple first operation blocks, and the dot addition operation corresponds to multiple second operation blocks, and the calculation process in the first operation blocks is the same as the calculation process in the second operation blocks.
9. The data encryption method according to claim 8, wherein: Decompose the dot multiplication and dot addition operations in the dot multiplication calculation into the same block operations, including: According to a preset calculation process, virtual calculation is added to the calculation process of doubling point operation to obtain a plurality of the first operation blocks; According to the preset calculation process, virtual calculation is added to the calculation process of point addition operation to obtain multiple second operation blocks.
10. The encryption method according to claim 9, wherein: Select the corresponding calculation process according to the target protection function and calculation mode, including: When redundant operation is enabled, redundant blocks are added to the calculation process of doubling point operation and / or the calculation process of point addition operation, wherein the redundant blocks are composed of virtual calculations that satisfy the preset calculation process.
11. The encryption method according to claim 6, wherein: Performing encryption calculation on the data according to the calculation process includes: Get data; The data is encrypted and calculated according to the calculation process.
12. The data encryption method according to claims 1 to 4, wherein: The protection function includes at least one of z random, k random, same block operation, redundant operation, modular multiplication blinding, modular inverse blinding, coordinate detection, and repeated calculation.
13. A data encryption device, comprising: Interface module, used to obtain protection configuration information; A protection control module, used to determine the enabled protection function according to the protection configuration information and generate a protection enabling instruction; A computing module is used to perform encryption calculations corresponding to the enabled protection function on the data according to the protection enabling instruction.
14. The data encryption device according to claim 13, wherein: The protection control module includes a plurality of protection control registers, each of which corresponds to a protection function one by one, and a configuration value of the protection control register indicates whether the corresponding protection function is enabled; The interface module is used to receive a configuration value configured to at least one protection control register, wherein the protection configuration information includes the configuration value of the at least one protection control register.
15. The data encryption device according to claim 13, wherein: The protection control module includes a plurality of protection control registers, each of which corresponds to a protection function one by one, and a configuration value of the protection control register indicates whether the corresponding protection function is enabled; The interface module is used to receive protection level information; configure the configuration value of at least one protection control register according to the protection level information, wherein the protection configuration information includes the configuration value of the at least one protection control register.
16. The data encryption device according to claim 15, wherein: The data encryption device also includes: The protection level configuration module is used to determine the protection functions that need to be enabled corresponding to each protection level.
17. The data encryption device according to any one of claims 14 to 16, wherein: The protection control module is used to generate the protection enable instruction according to the configuration value of each of the protection control registers.
18. The data encryption device according to any one of claims 13 to 16, wherein: The computing module includes a computing control module and a domain computing module; The calculation control module is used to determine the calculation process corresponding to the enabled protection function according to the protection enabling instruction; The domain operation module is used to perform encryption calculations on data according to the calculation process.
19. The data encryption device according to claim 18, wherein: The computing control module is used to determine the target protection function according to the computing mode represented by the computing instruction and the protection enable instruction, wherein the target protection function is the enabled protection function corresponding to the computing mode; and select the corresponding computing process according to the target protection function and the computing mode.
20. The data encryption device according to claim 19, wherein: The calculation control module is used to decompose the dot doubling operation and the dot addition operation in the dot multiplication calculation into the same block operations when the same block operations are enabled, wherein the dot doubling operation in the same block operation corresponds to multiple first operation blocks, the dot addition operation corresponds to multiple second operation blocks, and the calculation process in the first operation blocks is the same as the calculation process in the second operation blocks.
21. The data encryption device according to claim 20, wherein: The calculation control module is used to add virtual calculation to the calculation process of doubling point operation according to a preset calculation process to obtain a plurality of the first operation blocks; According to the preset calculation process, virtual calculation is added to the calculation process of point addition operation to obtain multiple second operation blocks.
22. The encryption device according to claim 21, wherein: The calculation control module is also used to add redundant blocks in the calculation process of doubling point operation and / or the calculation process of point addition operation when redundant operation is enabled, wherein the redundant blocks are composed of virtual calculations that meet the preset calculation process.
23. The encryption device according to claim 18, wherein: The computing module also includes a storage module; The domain operation module obtains data from the storage module; and performs encryption calculation on the data according to the calculation process.
24. The data encryption device according to claims 13 to 16, wherein: The protection function includes at least one of z random, k random, same block operation, redundant operation, modular multiplication blinding, modular inverse blinding, coordinate detection, and repeated calculation.
25. An electronic device comprising the data encryption device according to any one of claims 13 to 24.