Data encryption method, data encryption apparatus, and electronic device

By supporting custom configurations of multiple protection functions in the cryptographic algorithm hardware architecture, the problem of difficulty in taking into account high performance and high security in the existing technology is solved, and flexible adaptation to different scenarios and needs is achieved, and the data encryption architecture is improved. applicability.

WO2025025980A1PCT designated stage expired Publication Date: 2025-02-06SANECHIPS TECH CO LTD

Patent Information

Application Number
PCT/CN2024/103879
Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Priority Date
2023-07-31
Filing Date
2024-07-05
Publication Date
2025-02-06

AI Technical Summary

Technical Problem

In the prior art, when implementing a high-performance and high-security cryptographic algorithm hardware architecture, it is difficult to take into account different scenarios and needs, especially when facing side channel attacks and fault injection attacks, algorithm performance and chip area are usually required.

Method used

By providing a data encryption method and device, it supports custom configurations of multiple protection functions, including z-random, k-random, same block operation, redundant operation, modular multiplication blinding, modular inverse blinding, coordinate detection and repeated calculations etc. Dynamically configure to enable or turn off these protection functions according to different application scenarios and requirements.

Benefits of technology

It realizes multi-level application support for security and performance, and can be applied to multiple application scenarios where security and performance requirements are largely different, improving the applicable flexibility of data encryption architecture, and meeting the different security and performance needs of users.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN2024103879_06022025_PF_FP_ABST
    Figure CN2024103879_06022025_PF_FP_ABST
Patent Text Reader

Abstract

The present disclosure provides a data encryption method, comprising: obtaining protection configuration information; on the basis of the protection configuration information, determining a protection function to be enabled, and generating a protection enabling instruction; and on the basis of the protection enabling instruction, performing encryption calculation corresponding to said protection function on the data. The present disclosure also provides a data encryption apparatus and an electronic device.
Need to check novelty before this filing date? Find Prior Art

Description

Data encryption method, data encryption device, and electronic equipment

[0001] CROSS-REFERENCE TO RELATED APPLICATIONS

[0002] This application claims priority to Chinese patent application No. 202310960662.2 filed on July 31, 2023, the contents of which are incorporated herein by reference in their entirety. Technical Field

[0003] 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

[0004] To ensure data privacy and security, chip products such as automotive control chips often incorporate cryptographic algorithms, such as the SM2 algorithm (full name: SM2 elliptic curve public key cryptography). These cryptographic algorithms are considered highly secure in mathematical theory. However, in actual chip operation, they may face security threats from side-channel attacks and fault injection attacks. Side-channel attacks primarily exploit the leakage of side information (such as timing, electromagnetic field, and power consumption) during the cryptographic algorithm's operation, analyzing the dependency between this side information and secret information. Fault injection attacks involve injecting external electromagnetic or voltage into the cryptographic algorithm during operation, causing the algorithm to malfunction. This allows attackers to bypass security authentication and gain access, or analyze erroneous calculation results to obtain secret information. Cryptographic algorithm architectures that are resilient to attacks can provide effective protection against side-channel and fault injection attacks, but typically at the expense of algorithm performance and chip area.

[0005] Since 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.

[0006] Summary of the Invention

[0007] The embodiments of the present disclosure provide a data encryption method, a data encryption device, and an electronic device.

[0008] 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 based on the protection configuration information, and generating a protection enable instruction; and performing encryption calculations on data based on the protection enable instruction.

[0009] In the second aspect, an embodiment of the present disclosure provides a data encryption device, including: an interface module, configured to obtain protection configuration information; a protection control module, configured to determine the enabled protection function based on the protection configuration information and generate a protection enable instruction; and a calculation module, configured to perform encryption calculations on data according to the protection enable instruction.

[0010] 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.

[0011] In the disclosed embodiment, 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, it supports external customized protection requirements. After all or part of the protection functions are enabled externally, encryption calculations corresponding to the enabled protection functions are performed on the data, thereby meeting 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 multi-level security and performance applications, and is applicable to a variety of application scenarios with large differences in security and performance requirements. It improves 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

[0012] FIG1 is a flow chart of a data encryption method according to an embodiment of the present disclosure;

[0013] FIG2 is a flowchart of some steps in another data encryption method according to an embodiment of the present disclosure;

[0014] FIG3 is a schematic diagram of the composition of a data encryption device according to an embodiment of the present disclosure;

[0015] FIG4 is a schematic diagram showing the composition of another data encryption device according to an embodiment of the present disclosure;

[0016] FIG5 is a schematic diagram of the composition of an electronic device according to an embodiment of the present disclosure;

[0017] FIG6 is a schematic diagram showing the composition of a data encryption hardware architecture according to an embodiment of the present disclosure. DETAILED DESCRIPTION

[0018] 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 with reference to the accompanying drawings.

[0019] Example embodiments will be described more fully hereinafter 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. Rather, these embodiments are provided so that this disclosure will be thorough and complete and will fully convey the scope of this disclosure to those skilled in the art.

[0020] In the absence of conflict, the various embodiments of the present disclosure and the various features therein may be combined with each other.

[0021] As used herein, the term "and / or" includes any and all combinations of one or more of the associated listed items.

[0022] The terms used herein are used only 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.

[0023] Unless otherwise defined, all terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one 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 expressly defined as such herein.

[0024] In the SM2 algorithm process, 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 The rest is known information. Therefore, 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 the d AIn 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 to the outside in the event of a calculation error, the attacker can also use this information to deduce some secret information. Therefore, in application scenarios with very high security requirements (such as vehicle control chips, password keys, etc.), the implementation of the SM2 cryptographic algorithm must have comprehensive 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.

[0025] Among related technologies, security protections for the SM2 algorithm primarily focus on point multiplication, as this calculation step is most vulnerable to side-channel attacks, is relatively easy to implement, and has extensive research. However, attacks on large-number modular multiplication and modular inversion are less well-researched, lacking corresponding protection solutions and presenting security flaws. Therefore, as the intensity of side-channel attacks increases and the number of attack methods increases, protection measures must also be continuously refined and enhanced.

[0026] 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 flaws.

[0027] In some related technologies, the attack-resistant SM2 cryptographic algorithm architecture, while providing effective security protection, does so at the expense of algorithm performance and chip area, resulting in reduced algorithm performance and increased resource usage. As a public key cryptographic algorithm, the SM2 algorithm has a complex and time-consuming computational process. Adding security measures further weakens performance, meaning that high performance and high security cannot be achieved simultaneously. This hardware architecture offers limited adaptability in diverse application scenarios with significantly different security and performance requirements.

[0028] In view of this, in a first aspect, an embodiment of the present disclosure provides a data encryption method. Referring to FIG1 , the data encryption algorithm according to an embodiment of the present disclosure includes the following steps S1 to S3.

[0029] In step S1, protection configuration information is obtained.

[0030] In step S2, the protection function to be enabled is determined according to the protection configuration information, and a protection enabling instruction is generated.

[0031] In step S3, an encryption calculation corresponding to the enabled protection function is performed on the data according to the protection enabling instruction.

[0032] 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.

[0033] In the disclosed embodiments, the data encryption architecture includes multiple protection functions. The disclosed embodiments do not specifically limit the protection functions supported by the data encryption architecture. For example, protection functions include z-randomization, k-randomization, identical block operations, redundant operations, modular multiplication blinding, modular inverse blinding, coordinate detection, repeated calculations, or subsets of these functions. In the disclosed embodiments, the multiple protection functions in the data encryption architecture provide security protection against various attacks.

[0034] In the embodiment of the present disclosure, external customized protection requirements are supported, that is, all or part of the protection functions can be enabled through configuration. In the embodiment of the present disclosure, the protection configuration information is used to configure whether various security protection functions in the data encryption architecture are enabled.

[0035] In the embodiments of the present disclosure, after all or part of the protection functions are enabled by 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 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. Thus, support for applications with multiple levels of security and performance is achieved, and it can be applied to a variety of application scenarios with large differences in security and performance requirements, improving the applicability and flexibility of the data encryption architecture and helping to meet the different security and performance requirements of users.

[0036] The data encryption method provided by the embodiments of the present disclosure supports multi-level applications of security and performance, and can be applied to various application scenarios with large differences in security requirements and performance requirements, thereby improving the applicability and flexibility of the data encryption architecture.

[0037] In the disclosed embodiments, each protection function can be externally configured to be enabled or disabled. For example, each protection function corresponds to a protection control register, and the configuration value of the protection control register indicates whether the corresponding protection function is enabled or disabled. Externally, the protection function can be enabled or disabled by configuring the configuration value of the protection control register.

[0038] Accordingly, in some embodiments, obtaining protection configuration information (step S1 above) includes: receiving 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, the protection control register corresponds one-to-one to the protection function, and the configuration value of the protection control register represents whether the corresponding protection function is enabled.

[0039] In the embodiment 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 under the protection level.

[0040] Accordingly, in some embodiments, obtaining protection configuration information (step S1 above) includes: receiving protection level information; configuring 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, the protection control register corresponds one-to-one to the protection function, 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: determining the protection functions that need to be enabled corresponding to each of the protection levels.

[0042] In some embodiments, determining the enabled protection function according to the protection configuration information and generating a protection enable instruction (the above step S2) includes: generating the protection enable instruction according to the configuration value of each of the protection control registers.

[0043] In some embodiments, referring to FIG. 2 , performing encryption calculations corresponding to the enabled protection function on the data according to the protection enabling instruction (the above-mentioned step S3 ) includes the following steps S31 and S32 .

[0044] In step S31, a calculation process corresponding to the enabled protection function is determined according to the protection enabling instruction.

[0045] In step S32, encryption calculation is performed on the data according to the calculation process.

[0046] In some embodiments, determining the calculation process corresponding to the enabled protection function according to the protection enable instruction (the above-mentioned step S31) includes: determining the target protection function according to the calculation mode represented by the calculation instruction and the protection enable instruction, wherein the target protection function is the enabled protection function corresponding to the calculation mode; and selecting the corresponding calculation process according to the target protection function and the calculation mode.

[0047] 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.

[0048] z random refers to the randomization operation of the projected coordinate z: the external input random value z and the coordinate to be calculated are 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.

[0049] Identical Block Operations: The point addition and doubling operations in the dot multiplication calculation are split into sequential "modular multiplication + modular addition + modular subtraction" operations (identical block operations), as shown in Table 1. This conceals the operations and results in a roughly 10% performance reduction in the dot multiplication algorithm. This makes the doubling and addition operations appear almost identical in terms of leaked side information, making it difficult for attackers to distinguish between dot addition and doubling, and thus to derive secret information.

[0050] Table 1

[0051] In Table 1, dummy indicates that the corresponding calculation is a virtual calculation, which will not affect the calculation results of the dot multiplication or point multiplication operation.

[0052] As shown in Table 1, doubling operations correspond to first operation blocks 1 through 14, and dot addition operations correspond to second operation blocks 1 through 14. The computational flow in each pair of first and second operation blocks is identical. For example, the computational flow in both the first and second operation blocks is modular multiplication, modular addition, and modular subtraction. By using the same block operations, doubling operations and dot addition operations consume the same power and time, thus hiding the specific operations and resisting power analysis.

[0053] Redundant operations: Adding several redundant identical block operations makes the time taken for dot addition and dot multiplication calculations the same. The purpose is to hide the operations and time, which will cause the performance of the dot multiplication algorithm to decrease by about 15%.

[0054] k-random refers to randomizing the dot multiplication coefficient k: A random value r and the dot multiplication coefficient k are input externally, and k′ is calculated as r*n+k (where n is the order of the elliptic curve base point). The result k′ is used as the new dot multiplication coefficient in the dot multiplication operation, blinding the calculated data. Larger values ​​of r have a significant impact on performance, and a bit width of 32 bits is recommended, as this will reduce the performance of the dot multiplication algorithm by approximately 10%.

[0055] Blinding modular multiplication: For the modular multiplication calculation x*y(mod n), assuming x is secret information and y is known information, the operations shown in Table 2 are performed. The random number m introduced during the calculation blinds the data. In the SM2 algorithm, only a few modular multiplication steps involve secret information, and the performance loss caused by blinding is negligible compared to the overall performance of the algorithm.

[0056] Table 2

[0057] Blinding the modular inverse: For the modular inverse calculation x-1 (mod n), assuming x is secret information, the operations shown in Table 3 are performed. The random number m introduced during the calculation blinds the data. Similarly, in the SM2 algorithm, only a few modular exponentiation steps involve secret information, and the performance loss due to blinding is negligible compared to the overall algorithm performance.

[0058] Table 3

[0059] Coordinate Check: Externally input coordinate values ​​or the coordinate values ​​of a point calculation result are substituted into the curve to determine whether the point lies on the curve, as shown in Table 4. If an error is detected, the result is not output and an alarm is issued. This function is used to determine whether the calculation process has been subjected to a fault injection attack, which may cause unknown errors. It has minimal impact on algorithm performance.

[0060] Table 4

[0061] Repeated calculation: The key calculation steps of the SM2 algorithm that involve secret information, such as P B =[d B ]G and s=((1+d A ) -1 ·(kr·d A ))modp performs repeated calculations and outputs the result only if the two calculations are identical. Otherwise, no result is output and an alarm is issued. This function is used to determine whether the algorithm has been subjected to a fault injection attack during execution, causing unknown errors. Furthermore, performing the calculation twice can cause a 50% drop in algorithm performance.

[0062] Accordingly, in some embodiments, a corresponding calculation process is selected according to the target protection function and the calculation mode, including: when the same block operation is enabled, the doubling operation and the point addition operation in the point multiplication calculation are decomposed into the same block operation, wherein the doubling operation in the same block operation corresponds to multiple first operation blocks, and the point addition operation corresponds to multiple second operation blocks, and the calculation process in the first operation block is the same as the calculation process in the second operation block.

[0063] In some embodiments, the doubling operation and the point addition operation in the point multiplication calculation are decomposed into the same block operations, including: according to a preset calculation process, adding virtual calculations to the calculation process of the doubling operation to obtain multiple first operation blocks; according to the preset calculation process, adding virtual calculations to the calculation process of the point addition operation to obtain multiple second operation blocks.

[0064] In some embodiments, selecting a corresponding calculation process according to the target protection function and the calculation mode also includes: when redundant operations are enabled, adding redundant blocks in the calculation process of doubling operations and / or the calculation process of point addition operations, wherein the redundant blocks are composed of virtual calculations that meet the preset calculation process.

[0065] In some embodiments, performing encryption calculation on the data according to the calculation process (the above-mentioned step S32) includes: obtaining data; and performing encryption calculation on the data according to the calculation process.

[0066] In the second aspect, referring to Figure 3, an embodiment of the present disclosure provides a data encryption device, including: an interface module 110, configured to obtain protection configuration information; a protection control module 120, configured to determine the enabled protection function according to the protection configuration information and generate a protection enable instruction; a calculation module 130, configured to perform encryption calculations corresponding to the enabled protection function on the data according to the protection enable instruction.

[0067] The data encryption device provided by the embodiments of the present disclosure may be, or be applied to, chip products such as secure communication systems, smart integrated circuits, password keys, vehicle-mounted control chips, and security chips.

[0068] In the disclosed embodiments, the data encryption architecture includes multiple protection functions. The disclosed embodiments do not specifically limit the protection functions supported by the data encryption architecture. For example, protection functions include z-random, k-random, identical block operations, redundant operations, modular multiplication blinding, modular inverse blinding, coordinate detection, repeated calculations, or subsets of these functions. In the disclosed embodiments, the multiple protection functions in the data encryption architecture can provide security protection against various attacks.

[0069] In the disclosed embodiment, the data encryption architecture supports external customized protection requirements, that is, enabling all or part of the protection functions through configuration. In the disclosed embodiment, the protection configuration information is used to configure whether various security protection functions in the data encryption architecture are enabled.

[0070] In the disclosed embodiments, after enabling all or some of the protection functions through external configuration, encryption calculations corresponding to the enabled protection functions are performed on the data, thereby meeting encryption operations in different scenarios and with different requirements. For example, in application scenarios with high security requirements, strong security can be ensured by enabling more protection functions; in application scenarios with high performance requirements, high performance can be ensured by disabling most protection functions.

[0071] 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 various application scenarios with large differences in security requirements and performance requirements, thereby improving the applicability flexibility of the data encryption architecture.

[0072] In the disclosed embodiments, each protection function can be externally configured to be enabled or disabled. For example, each protection function corresponds to a protection control register, and the configuration value of the protection control register indicates whether the corresponding protection function is enabled or disabled. Externally, the protection function can be enabled or disabled by configuring the configuration value of the protection control register.

[0073] Accordingly, in some embodiments, the protection control module includes multiple protection control registers, the protection control registers correspond one-to-one to the protection functions, and the configuration value of the protection control register represents whether the corresponding protection function is enabled; the interface module is configured to receive the 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.

[0074] In the embodiment 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 under the protection level.

[0075] In some embodiments, the protection control module includes multiple protection control registers, each of which 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; the interface module is configured to receive protection level information; and 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.

[0076] In some embodiments, the data encryption device further includes: a protection level configuration module configured to determine the protection functions that need to be enabled corresponding to each of the protection levels.

[0077] In some embodiments, the protection control module is configured to generate the protection enable instruction according to the configuration value of each of the protection control registers.

[0078] 4 , the calculation module 130 includes a calculation control module 131 and a domain operation module 132. The calculation control module 131 is configured to determine a calculation process corresponding to the enabled protection function according to the protection enable instruction.

[0079] The domain operation module 132 is configured to perform encryption calculations on the data according to the calculation process.

[0080] In some embodiments, the computing control module is configured 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.

[0081] In some embodiments, the calculation control module is configured to decompose the doubling operation and the point addition operation in the point multiplication calculation into the same block operations when the same block operation is enabled, wherein the doubling operation in the same block operation corresponds to multiple first operation blocks, and the point addition operation corresponds to multiple second operation blocks, and the calculation process in the first operation block is the same as the calculation process in the second operation block.

[0082] In some embodiments, the calculation control module is configured to add virtual calculations to the calculation process of doubling point operations according to a preset calculation process to obtain multiple first operation blocks; and add virtual calculations to the calculation process of point addition operations according to the preset calculation process to obtain multiple second operation blocks.

[0083] In some embodiments, the computing control module is further configured 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.

[0084] 4 , the computing module 130 further includes a storage module 133. The domain computing module 132 obtains data from the storage module 133 and performs encryption calculation on the data according to the computing process.

[0085] 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.

[0086] In a third aspect, referring to FIG. 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.

[0087] In a fourth aspect, an embodiment of the present disclosure provides an electronic device, comprising: one or more processors; a memory on which one or more programs are stored, and 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; one or more I / O interfaces, connected between the processor and the memory, and configured to implement information interaction between the processor and the memory.

[0088] Among them, the processor is a device with data processing capabilities, including but not limited to the central processing unit (CPU); the memory is a device with data storage capabilities, including but not limited to random access memory (RAM, more specifically such as SDRAM, DDR, etc.), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), and flash memory (FLASH); the I / O interface (read-write interface) is connected between the processor and the memory, which can realize information exchange between the processor and the memory, including but not limited to the data bus (Bus), etc.

[0089] 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.

[0090] 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.

[0091] 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 examples:

[0092] Example 1

[0093] In this embodiment, the data encryption hardware architecture is shown in FIG6 , including an interface module, a protection control module, a calculation control module, a domain operation module, and a storage module.

[0094] 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.

[0095] The protection control module receives external protection configuration information through the interface module, processes it, and outputs the corresponding protection enable signaling to the computation control module. The protection control module contains protection control registers for z-random, k-random, identical block operations, redundant operations, blinded modular multiplication, blinded modular inversion, coordinate detection, and repeated computation. External configuration of these protection control registers enables SM2 operations with varying security levels.

[0096] The computation control module receives external computation instructions through the interface module and then receives protection enable instructions from the protection control module. Based on this information, it selects different computation flows and finally schedules domain computation modules according to these flows to implement complex computations. The computation control module includes submodules for point multiplication, precomputation, point doubling, point addition, blinded modular multiplication, blinded modular inverse, point verification, and coordinate transformation. Internally, the module uses a state machine to schedule domain computation modules to implement elliptic curve point multiplication, Montgomery precomputation, elliptic curve point addition, elliptic curve doubling, modular multiplication with blinding, modular inverse with blinding, verification of coordinate points on elliptic curves, and elliptic curve projective coordinate transformations.

[0097] Under the control of the computation control module, the domain operation module reads data from the storage module and performs computations. Once the computations are complete, the module writes the results back to the storage module. The domain operation module includes modular addition, modular subtraction, modular multiplication, and modular inversion submodules, which respectively implement modular addition, modular subtraction, modular multiplication, and modular inversion computations on large numbers within a specified prime field.

[0098] The storage module is responsible for storing calculation input data, calculation intermediate data and calculation output data.

[0099] This hardware architecture has comprehensive protection 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.

[0100] Example 2

[0101] This embodiment is based on the hardware architecture of the first embodiment. The data encryption process includes:

[0102] 1. Configure calculation control information and protection control information through the interface module, and then write the elliptic curve parameters and data to be calculated into the storage module;

[0103] 2. The protection control module determines which protection functions are enabled based on external configuration information. All protection functions are as follows:

[0104] z random refers to the randomization operation of the projected coordinate z: external input random value z and the coordinate to be calculated are 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.

[0105] Same-Block Operations: In some embodiments, the dot addition and dot doubling operations in a dot product calculation are split into sequential "modular multiplication + modular addition + modular subtraction" operations (same-block operations), as shown in Table 1. This is to hide the operations, which results in a performance reduction of approximately 10% for the dot product algorithm.

[0106] Redundant operations: Adding several redundant identical block operations makes the time taken for dot addition and dot multiplication calculations the same. The purpose is to hide the operations and time, which will cause the performance of the dot multiplication algorithm to decrease by about 15%.

[0107] k-random refers to the randomization of the dot multiplication coefficient k: an external random value r and the dot multiplication coefficient k are input, and k′=r*n+k (n is the order of the elliptic curve base point). The calculated result k′ is used as the new dot multiplication coefficient in the dot multiplication operation to blind the calculated data. Large r values ​​have a significant impact on performance. It is recommended that the bit width does not exceed 32 bits, which will cause the dot multiplication algorithm performance to decrease by approximately 10%;

[0108] Blinding modular multiplication: For the modular multiplication calculation x*y(mod n), assuming x is secret information and y is known information, the operations shown in Table 2 are performed. The random number m introduced during the calculation blinds the data. In the SM2 algorithm, only a few modular multiplication steps involve secret information, and the performance loss caused by blinding is negligible compared to the overall algorithm performance.

[0109] Blinding the Modular Inverse: For the modular inverse calculation x-1 (mod n), assuming x is secret information, the operations shown in Table 3 are performed. The random number m introduced during the calculation blinds the data. Similarly, in the SM2 algorithm, only a few modular exponentiation steps involve secret information, and the performance loss due to blinding is negligible compared to the overall performance of the algorithm.

[0110] Coordinate Check: Externally input coordinate values ​​or the coordinate values ​​of a point calculation result are substituted into the curve to determine whether the point lies on the curve, as shown in Table 4. If an error is detected, the result is not output and an alarm is issued. This function is used to determine whether the calculation process has been subjected to a fault injection attack, which may cause unknown errors. It has minimal impact on algorithm performance.

[0111] Repeated calculation: The key calculation steps of the SM2 algorithm that involve secret information, such as PB =[d B ]G and s=((1+d A ) -1 ·(kr·d A ))modp performs repeated calculations and outputs the result only if the two calculations are identical. Otherwise, no result is output and an alarm is issued. This function is used to determine whether the algorithm has been subjected to a fault injection attack during execution, causing unknown errors. Furthermore, performing the calculation twice can cause a 50% drop in algorithm performance.

[0112] 3. The calculation control module selects and executes the corresponding calculation state machine process based on the calculation control information and protection control information, and continuously schedules the domain operation module according to the process to complete the entire calculation. The process is as follows:

[0113] If the calculation mode is selected as dot product calculation:

[0114] Determine whether to enable the randomization of the projection coordinate z. If enabled, perform the randomization calculation of the projection coordinate.

[0115] Determine whether to enable randomization of the point multiplication coefficient k. If enabled, perform randomization calculation of the point multiplication coefficient.

[0116] 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.

[0117] Convert the dot product calculation result under the projection coordinate back to the affine coordinate;

[0118] Determine whether to enable repeated calculation. If enabled, repeat the above calculation process (1)-(4), compare the two calculation results, and output an error interrupt if they are different, and the calculation ends;

[0119] Determine whether coordinate detection is enabled. If enabled, perform coordinate detection calculation on the dot 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.

[0120] If the calculation mode is modular multiplication calculation:

[0121] Determine whether blind modular multiplication is enabled. If enabled, perform the calculation according to the process shown in Table 2; otherwise, perform normal modular multiplication.

[0122] If the calculation mode is modular inverse calculation:

[0123] Determine whether to enable blind modular inversion. If enabled, perform the calculation according to the process shown in Table 3. Otherwise, perform the normal modular inversion calculation.

[0124] 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;

[0125] 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.

[0126] 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 is well 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 includes, but is 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 tape, 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 embodies 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.

[0127] 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 purposes of limitation. In some instances, it will be apparent to those skilled in the art that, unless otherwise expressly indicated, 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, it will be understood by those skilled in the art 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: An interface module configured to obtain protection configuration information; A protection control module, configured to determine the enabled protection function according to the protection configuration information and generate a protection enabling instruction; The computing module is configured to perform encryption computing 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 configured to receive a configuration value configured to at least one guard control register, wherein the guard configuration information includes the configuration value of the at least one guard 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 configured to receive protection level information; and configure a 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 configured to determine the protection functions that need to be enabled corresponding to each of the protection levels.

17. The data encryption device according to any one of claims 14 to 16, wherein: The protection control module is configured 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 configured to determine a calculation process corresponding to the enabled protection function according to the protection enabling instruction; The domain operation module is configured 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 configured to determine a target protection function according to a computing mode represented by a computing instruction and the protection enable instruction, wherein the target protection function is an enabled protection function corresponding to the computing mode; and select a 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 configured 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, 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 configured 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 computing control module is also configured to add redundant blocks in the computing process of doubling point 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.

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.

Citation Information

Patent Citations

  • Realization method of elliptic curve cryptosystem for preventing side-channel attack

    CN101562522A

  • SM2 dot multiplication configuration preventing side-channel attack

    CN108964914A

  • Big data network data protection method and system based on edge computing

    CN111371813A

  • Optimizing data reduction, security and encryption requirements in a network environment

    US20180241777A1

  • Smart card protection method and apparatus capable of side channel attack resistance

    WO2022227273A1

Cited By

  • Implementation asynchronous circuit and implementation method of SM3 algorithm for resisting side channel attack

    CN121711102A