RSA private key operation method, device, electronic device and storage medium

By splitting the RSA private key operation data into high-order and low-order data and using the existing modular multiplier to calculate the operation result, the cost increase problem caused by modular multiplier update is solved and efficient RSA private key operation is achieved.

CN114666054BActive Publication Date: 2025-09-16TSINGHUA UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210157055.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-21
Publication Date
2025-09-16
Estimated Expiration
2042-02-21

AI Technical Summary

Technical Problem

The modular multiplier equipped in existing MCUs can only process 2048-bit operations, which means that the modular multiplier and related chips need to be replaced when the key length is updated, increasing operating costs.

Method used

The data to be operated is split into high-order and low-order data with preset positions, and the existing analog multiplier processing capability is utilized to calculate the operation result through private key information and public key information, thus avoiding the need to replace the analog multiplier and related chips.

Benefits of technology

The data operation and processing larger than the preset bit is realized, thereby reducing the operation cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114666054B_ABST
    Figure CN114666054B_ABST
Patent Text Reader

Abstract

The present invention provides an RSA private key operation method, device, electronic device, and storage medium, wherein the method comprises: obtaining data to be operated and private key information; wherein the private key information comprises a first modulus, a second modulus, and inverse data; wherein the first modulus and the second modulus are prime numbers of preset positions; the number of bits of the data to be operated is twice the number of preset positions, where the preset positions are the maximum number of bits that a modular multiplier can process; splitting the data to be operated into high-order data to be operated at preset positions and low-order data to be operated at preset positions; determining an operation result corresponding to the data to be operated based on the private key information, the high-order data to be operated, the low-order data to be operated, and public key information; wherein the public key information is the product of the first modulus and the second modulus. The RSA private key operation method, device, electronic device, and storage medium provided by the present invention can implement operation processing of data to be operated that is larger than the preset positions without replacing the original modular multiplier and related chips, thereby reducing operation costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to an RSA private key operation method, device, electronic device and storage medium. Background Art

[0002] In recent years, many microcontroller units (MCUs) have incorporated public key accelerators (PKAs), highly efficient hardware accelerators that accelerate public key cryptography operations. Due to resource limitations such as random access memory (RAM) and chip area, MCUs are typically equipped with only a single modular multiplier capable of handling 2048-bit modular multiplications. However, with the rapid advancement of computing technology, 2048-bit RSA keys are increasingly considered insecure. Therefore, it is necessary to increase the key length.

[0003] In the related art, when updating the key length, since the modular multiplier equipped in the existing MCU can only process 2048-bit operations, if the updated key length is greater than 2048 bits, the modular multiplier and other related chips need to be replaced, which increases the operating cost. Summary of the Invention

[0004] The present invention provides an RSA private key operation method, device, electronic device and storage medium, which are used to solve the defect of the prior art that causes increased operation cost.

[0005] The present invention provides an RSA private key operation method, comprising:

[0006] Obtaining data to be operated and private key information; wherein the private key information includes a first modulus, a second modulus, and inverse data; the first modulus and the second modulus are prime numbers of preset positions; the number of bits of the data to be operated is twice the preset position, and the preset position is the maximum number of bits that can be processed by the modular multiplier;

[0007] Splitting the data to be operated into high-order data to be operated at the preset position and low-order data to be operated at the preset position;

[0008] An operation result corresponding to the data to be operated is determined based on the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information; wherein the public key information is the product of the first modulus and the second modulus.

[0009] According to an RSA private key operation method provided by the present invention, determining an operation result corresponding to the data to be operated based on the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information, includes:

[0010] The square of a preset value is congruent with the first modulus to obtain a first constant, and the square of the preset value is congruent with the second modulus to obtain a second constant; wherein the preset value is a preset power of 2;

[0011] An operation result corresponding to the data to be operated is determined based on the first constant, the second constant, the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information.

[0012] According to an RSA private key operation method provided by the present invention, obtaining a first constant by taking the square of a preset value and the first modulus as congruence includes:

[0013] Get s0;

[0014] Loop execution Until i is equal to the preset position;

[0015] The s 预设位 is determined as the first constant;

[0016] Among them, the s0 corresponds to represents the addition operation of the first modulus p; in represents a multiplication operation of the first modulus p, where i is an integer ranging from 1 to the preset position;

[0017] The step of obtaining a second constant by taking the square of the preset value and the second modulus as congruence includes:

[0018] Get k0;

[0019] Loop execution Until i is equal to the preset position;

[0020] The k 预设位 is determined as the second constant;

[0021] in, in Represents the multiplication operation of the second modulus q, and the k0 corresponds to Represents the addition operation of the second modulus q.

[0022] According to an RSA private key operation method provided by the present invention, the inverse metadata includes a first inverse element, a second inverse element, and a third inverse element; wherein the first inverse element is the inverse element of the target random number with respect to the first modulus minus 1, the second inverse element is the inverse element of the target random number with respect to the second modulus minus 1, and the third inverse element is the inverse element of the second modulus with respect to the first modulus; the target random number is a number coprime with phi(n), and phi(n) is the product of the first modulus minus 1 and the second modulus minus 1;

[0023] The determining the operation result corresponding to the data to be operated based on the first constant, the second constant, the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information includes:

[0024] Determine a first modular power value based on the first constant, the high-order data to be operated, the first inverse element, and the first modulus;

[0025] determining a second modular power value based on the second constant, the low-order data to be operated on, the second inverse element, and the second modulus;

[0026] An operation result corresponding to the data to be operated is determined based on the first modular exponentiation value, the second modular exponentiation value, the third inverse element and the public key information.

[0027] According to an RSA private key operation method provided by the present invention, determining a first modular power value based on the first constant, the high-order data to be operated, the first inverse element, and the first modulus includes:

[0028] Determining the first modular power value based on formula (1) and formula (2);

[0029]

[0030]

[0031] Among them, m represents the data to be operated, m1 represents the high-order data to be operated, m2 represents the low-order data to be operated, and d p represents the first inverse element, s p represents the first modular power value;

[0032] The determining of the second modular power value based on the second constant, the low-order data to be operated, the second inverse element, and the second modulus includes:

[0033] Determine the second modular power value based on formula (3) and formula (4);

[0034]

[0035]

[0036] Among them, d q represents the second inverse element, s q represents the second modular power value.

[0037] According to an RSA private key operation method provided by the present invention, determining an operation result corresponding to the data to be operated based on the first modular exponentiation value, the second modular exponentiation value, the third inverse element, and the public key information includes:

[0038] Determine the target value based on formula (5) and formula (6);

[0039]

[0040] S=s q +h×q (6)

[0041] When it is determined that the target value is greater than the public key information, determining the difference between the target value and the public key information as the operation result;

[0042] When it is determined that the target value is less than or equal to the public key information, determining the target value as the operation result;

[0043] Among them, q inv represents the third inverse element, S represents the target value, Represents the subtraction operation of the first modulus p.

[0044] According to an RSA private key operation method provided by the present invention, h×q is obtained by sequentially combining the values ​​of a first group of digits, a second group of digits, a third group of digits, and a fourth group of digits; the first group of digits is the lowest digit of h×q, the fourth group of digits is the highest digit of h×q, and the numbers of the first group of digits, the second group of digits, the third group of digits, and the fourth group of digits are all equal;

[0045] Wherein, the high digit of h is h1, the low digit of h is h2, the high digit of q is q1, the low digit of q is q2, h1=HI(h), h2=LO(h), q1=HI(q), q2=LO(q); the value of the first group of digits is The value of the second set of digits is The value of the third group of digits is The value of the fourth group of digits is h1=HI(h), h2=LO(h), q1=HI(q), q2=LO(q); represents a modular multiplication operation, where the modulus of the modular multiplication operation is a preset power of 2.

[0046] The present invention also provides an RSA private key operation device, comprising:

[0047] an acquisition unit, configured to acquire data to be operated and private key information; wherein the private key information includes a first modulus, a second modulus, and inverse data; the first modulus and the second modulus are prime numbers of preset positions; the number of bits of the data to be operated is twice the preset position, and the preset position is the maximum number of bits that can be processed by the modular multiplier;

[0048] a splitting unit, configured to split the data to be operated into high-order data to be operated at the preset position and low-order data to be operated at the preset position;

[0049] A determination unit is used to determine an operation result corresponding to the data to be operated based on the private key information, the high-order data to be operated, the low-order data to be operated and the public key information; wherein the public key information is the product of the first modulus and the second modulus.

[0050] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any one of the above-described RSA private key operation methods is implemented.

[0051] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described RSA private key operation methods.

[0052] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned RSA private key operation methods.

[0053] The RSA private key operation method, device, electronic device, and storage medium provided by the present invention, upon obtaining data to be operated and private key information, split the data to be operated into high-order data to be operated at a preset position and low-order data to be operated at a preset position, because the maximum number of bits that can be processed by the modular multiplier is a preset number of bits. The operation result corresponding to the data to be operated is then determined based on the high-order data to be operated, the low-order data to be operated, the private key information, and the public key information. In this way, operations can be performed on data to be operated that exceeds the preset number of bits without replacing the existing modular multiplier and related chips, thereby reducing operating costs. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] In order to more clearly illustrate the technical solutions in the present invention or the prior art, a brief introduction is given below to the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0055] Figure 1 This is one of the flow charts of the RSA private key operation method provided by the present invention;

[0056] Figure 2 This is the second flow chart of the RSA private key operation method provided by the present invention;

[0057] Figure 3 This is the third flow chart of the RSA private key operation method provided by the present invention;

[0058] Figure 4 It is a structural diagram of the RSA private key operation device provided by the present invention;

[0059] Figure 5 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0060] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only some of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts shall fall within the scope of protection of the present invention.

[0061] The following combination Figure 1-Figure 3 The RSA private key operation method of the present invention is described.

[0062] Figure 1 This is one of the flow charts of the RSA private key operation method provided by the present invention, such as Figure 1 As shown, the RSA private key operation method includes the following steps:

[0063] Step 101: Obtain data to be operated and private key information.

[0064] Among them, the RSA algorithm is an asymmetric encryption algorithm that can generate different public keys and private keys; the private key information includes a first modulus, a second modulus and inverse metadata; the first modulus and the second modulus are prime numbers of preset positions respectively; the number of bits of the data to be operated is twice the preset position, and the preset position is the maximum number of bits that the modular multiplier can process.

[0065] The modular multiplier may be a modular multiplier based on the Montgomery algorithm.

[0066] For example, the private key information and the data to be operated can be represented by the Chinese remainder theorem, and the preset bit is 2048 bits. Then the first modulus and the second modulus are both 2048-bit prime numbers, and the number of bits of the data to be operated is 4096 bits.

[0067] Step 102: Split the data to be operated into high-order data to be operated at the preset position and low-order data to be operated at the preset position.

[0068] For example, since the maximum number of bits that the modular multiplier can process is 2048 bits, when 4096 bits of data to be operated are obtained, the 4096 bits of data to be operated need to be split into 2048 high-order bits of high-order data to be operated and 2048 low-order bits of low-order data to be operated.

[0069] Step 103: Determine an operation result corresponding to the data to be operated based on the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information.

[0070] The public key information is the product of the first modulus and the second modulus; the public key information is a parameter in the public key; for example, the parameters of the public key include public key information n and a target random number e, the target random number e is a number coprime to phi(n), and phi(n) is the product of the first modulus minus 1 and the second modulus minus 1; when encrypting or signing plaintext c, the data to be operated can be determined by c^e mod n.

[0071] For example, when the upper 2048 bits of high-order data to be operated and the lower 2048 bits of low-order data to be operated are obtained, the operation result corresponding to the data to be operated is calculated based on the first modulus, the second modulus, the inverse metadata, the upper 2048 bits of high-order data to be operated, the lower 2048 bits of low-order data to be operated, and the public key information.

[0072] It should be noted that the present invention does not limit the specific value of the preset bit, which can be determined based on the maximum number of bits that the modular multiplier in the electronic device can process; if the modular multiplier can process a maximum of 1024 bits, the preset bit is 1024, and based on the present invention, a 2048-bit RSA private key operation can be implemented; if the modular multiplier can process a maximum of 2048 bits, the preset bit is 2048, and based on the present invention, a 4096-bit private key operation can be implemented.

[0073] The RSA private key operation method provided by the present invention, upon obtaining the data to be operated and the private key information, splits the data to be operated into high-order data to be operated and low-order data to be operated at a preset number of bits, because the maximum number of bits that the modular multiplier can process is a preset number of bits. The method then determines the operation result corresponding to the data to be operated based on the high-order data to be operated, the low-order data to be operated, the private key information, and the public key information. This allows for processing data to be operated that exceeds the preset number of bits without replacing the existing modular multiplier and related chips, thereby reducing operating costs.

[0074] Optionally, Figure 2 This is the second flow chart of the RSA private key operation method provided by the present invention, such as Figure 2 As shown, Figure 1 Step 103 in the embodiment can be specifically implemented by the following steps:

[0075] Step 1031: Taking the square of the preset value as congruent to the first modulus to obtain a first constant, and taking the square of the preset value as congruent to the second modulus to obtain a second constant.

[0076] Specifically, the square of the preset value is congruent with the first modulus to obtain the first constant in the following manner:

[0077] Get s0;

[0078] Loop execution Until i is equal to the preset position;

[0079] The s 预设位 is determined as the first constant.

[0080] Among them, the s0 corresponds to represents the addition operation of the first modulus p; in represents a multiplication operation of the first modulus p, where the value of i is an integer from 1 to the preset bit.

[0081] For example, the preset bit is 2048 bits, the first modulus is represented by p, and the preset value is represented by R, then the first constant = R 2 mod p, mod represents the modulo operation. The specific steps to solve the first constant are: first calculate Here represents the addition operation of the first modulus p, obtaining s0; then setting the value of i to 1, calculate Then set the value of i to 2 and calculate This cycle is repeated 2048 times until the result is obtained. Will s 2048 The value of is determined as the first constant; in addition, It can be expressed as s i-1 ×s i-1 / R mod p, where R represents 2 预设位 .

[0082] Specifically, the square of the preset value and the second modulus are congruent to obtain the second constant. A specific implementation method is as follows:

[0083] Get k0;

[0084] Loop execution Until i is equal to the preset position;

[0085] The k 预设位 is determined as the second constant;

[0086] in, in Represents the multiplication operation of the second modulus q, and the k0 corresponds to Represents the addition operation of the second modulus q.

[0087] For example, the preset bit is 2048 bits, the second modulus is represented by q, and the preset value is represented by R, then the second constant = R 2 Mod q, the specific steps to solve the second constant are: first calculate Here represents the addition operation of the second modulus q, and obtains k0; then the value of i is set to 1, and the calculation Then set the value of i to 2 and calculate This cycle is repeated 2048 times until the result is obtained. K 2048 The value of is determined as the second constant; in addition, It can be expressed as k i-1 ×k i-1 / R mod q.

[0088] Step 1032: Determine an operation result corresponding to the data to be operated based on the first constant, the second constant, the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information.

[0089] The preset value is a preset power of 2.

[0090] The RSA private key operation method provided by the present invention uses 2 when calculating the first constant and the second constant because the modular multiplier can only process data of a preset position at most. 预设位 -1+1 is used to represent 2 预设位 , which facilitates the modular multiplier to calculate the first constant and the second constant.

[0091] Optionally, the inverse metadata includes a first inverse element, a second inverse element and a third inverse element; wherein, the first inverse element is the inverse element of the target random number with respect to the first modulus minus 1, the second inverse element is the inverse element of the target random number with respect to the second modulus minus 1, and the third inverse element is the inverse element of the second modulus with respect to the first modulus; the target random number is a number coprime with phi(n), and phi(n) is the product of the first modulus minus 1 and the second modulus minus 1.

[0092] For example, the first inverse element adopts d p Indicates that the second inverse element uses d q Indicates that the third inverse element uses q inv The target random number is represented by e, and the private key information can be expressed as (p, q, d p ,d q ,q inv ), d p ×e=1 mod(p-1), d q ×e=1mod(q-1),q inv ×q=1 modp, phi(n)=(p-1)×(q-1).

[0093] Optionally, Figure 3 This is the third flow chart of the RSA private key operation method provided by the present invention, as shown in FIG. Figure 3 As shown, Figure 2 Step 1032 in the embodiment can be specifically implemented by the following steps:

[0094] Step 10321: Determine a first modular power value based on the first constant, the high-order data to be operated, the first inverse element, and the first modulus.

[0095] Specifically, the first modular power value is determined based on formula (1) and formula (2);

[0096]

[0097]

[0098] Among them, m represents the data to be operated, m1 represents the high-order data to be operated, m2 represents the low-order data to be operated, d p represents the first inverse element, s p represents the first modular power value.

[0099] For example, after calculating the first constant s 预设位 When the first constant s 预设位 , high-order data to be operated m1, first inverse element d pSubstitute the first modulus p into formula (1) and solve formula (1) to get the value m modulo p p ; Then m p Substituting into formula (2), the first modular power value s can be obtained by using the fast power algorithm to solve formula (2). p .

[0100] Step 10322: Determine a second modular power value based on the second constant, the low-order data to be operated on, the second inverse element, and the second modulus.

[0101] Specifically, the second modular power value is determined based on formula (3) and formula (4);

[0102]

[0103]

[0104] Among them, d q represents the second inverse element, s q represents the second modular power value.

[0105] For example, when the second constant k is calculated 预设位 When the second constant k 预设位 , high-order data to be operated m1, second inverse element d q Substitute the second modulus q into formula (3) and solve formula (3) to get the value m modulo q q ; Then m q Substituting into formula (3), and using the fast power algorithm to solve formula (4), we can get the second modular power value s q .

[0106] Step 10323: Determine an operation result corresponding to the data to be operated based on the first modular exponentiation value, the second modular exponentiation value, the third inverse element, and the public key information.

[0107] Specifically, the target value is determined based on formula (5) and formula (6);

[0108]

[0109] S=s q +h×q (6)

[0110] When it is determined that the target value is greater than the public key information, determining the difference between the target value and the public key information as the operation result;

[0111] When it is determined that the target value is less than or equal to the public key information, the target value is determined as the operation result.

[0112] Among them, qinv represents the third inverse element, S represents the target value, Represents the subtraction operation of the first modulus p.

[0113] For example, after calculating the first modular power value s p and the second modular power value s q When the first modular power value s p , the second modular power value s q ,q inv and the first modulus p are substituted into formula (5), and h can be obtained by solving formula (5); then h, the second modulus q, and the second modulus power s are replaced. q Substituting into formula (6), solving formula (6) can obtain the target value S; when the target value S is calculated, the target value S is compared with the public key information n. When it is determined that the target value S is greater than the public key information n, Sn is returned, that is, Sn is determined as the operation result of the data to be operated m; when it is determined that the target value S is less than or equal to the public key information n, S is returned, that is, S is determined as the operation result of the data to be operated m.

[0114] It should be noted that the data to be operated on can be encrypted data or signed data. When the data to be operated on is encrypted data, the operation result is the decrypted data corresponding to the encrypted data; when the data to be operated on is signed data, the operation result is the signature result corresponding to the signed data. The present invention is applicable to RSA private key operation scenarios for encrypted data and RSA private key operation scenarios for signed data.

[0115] The RSA private key operation method provided by the present invention is that the maximum number of bits that the modular multiplier can process is a preset number of bits, so s p The calculation of m is divided into two parts. First, calculate m p , and then calculate The modular multiplier is used to operate on data larger than a preset bit.

[0116] Furthermore, when calculating h×q, it can be specifically implemented in the following way:

[0117] The h×q is obtained by sequentially combining the values ​​of the first group of digits, the second group of digits, the third group of digits, and the fourth group of digits; the first group of digits is the lowest digit of the h×q, the fourth group of digits is the highest digit of the h×q, and the numbers of digits of the first group of digits, the second group of digits, the third group of digits, and the fourth group of digits are all equal.

[0118] Wherein, the high digit of h is h1, the low digit of h is h2, the high digit of q is q1, the low digit of q is q2, h1=HI(h), h2=LO(h), q1=HI(q), q2=LO(q); the value of the first group of digits is The value of the second set of digits is The value of the third group of digits is The value of the fourth group of digits is h1=HI(h), h2=LO(h), q1=HI(q), q2=LO(q); represents a modular multiplication operation, where the modulus of the modular multiplication operation is a preset power of 2.

[0119] For example, when the preset bit is 2048, the preset bit power of 2 can be expressed as 2 2048 , modular multiplication operation The modulus is 2 2048 ;For example, in addition, Indicates taking The lower 1024 bits of the value, Indicates taking The high 1024 bits of the value, Indicates taking The lower 1024 bits of the value, Indicates taking The lower 1024 bits of the value, Indicates taking The lower 1024 bits of the value, Indicates taking The high 1024 bits of the value, Indicates taking The high 1024 bits of the value, Indicates taking The high 1024 bits of the value.

[0120] It should be noted that the public key information n can be obtained directly or calculated based on the h×q calculation method described above, that is, using the h×q calculation method to calculate n=p×q. In this way, the modular multiplier can calculate the product of two preset bits of data without replacing the hardware (modular multiplier and related chips) in existing electronic devices.

[0121] The RSA private key operation method provided by the present invention divides the product calculation of two preset-bit data into the calculation of four groups with the same number of bits, calculates the values ​​of the number of bits of the four groups respectively, and finally combines the calculated values ​​of each group to obtain the product of the two preset-bit data, thereby realizing the product operation of the modular multiplier on two data greater than the preset bits.

[0122] The RSA private key operation device provided by the present invention is described below. The RSA private key operation device described below and the RSA private key operation method described above can be referenced to each other.

[0123] Figure 4 Schematic diagram of the structure of the RSA private key operation device provided by the present invention, such as Figure 4 As shown, the RSA private key operation device includes an acquisition unit 401, a splitting unit 402 and a determination unit 403; wherein:

[0124] An acquisition unit 401 is configured to acquire data to be operated and private key information; wherein the private key information includes a first modulus, a second modulus, and inverse data; the first modulus and the second modulus are prime numbers of preset positions; the number of bits of the data to be operated is twice the preset position, and the preset position is the maximum number of bits that can be processed by the modular multiplier;

[0125] A splitting unit 402 is configured to split the data to be operated on into high-order data to be operated on at a preset position and low-order data to be operated on at a preset position;

[0126] The determination unit 403 is used to determine the operation result corresponding to the data to be operated based on the private key information, the high-order data to be operated, the low-order data to be operated and the public key information; wherein the public key information is the product of the first modulus and the second modulus.

[0127] The RSA private key operation device provided by the present invention, upon obtaining data to be operated and private key information, splits the data to be operated into high-order data to be operated and low-order data to be operated at a preset number of bits, because the maximum number of bits that the modular multiplier can process is a preset number of bits. The device then determines the operation result corresponding to the data to be operated based on the high-order data to be operated, the low-order data to be operated, the private key information, and the public key information. This allows for operation processing of data to be operated that exceeds the preset number of bits without replacing the existing modular multiplier and related chips, thereby reducing operating costs.

[0128] Based on any of the above embodiments, the determining unit 403 is specifically configured to:

[0129] The square of a preset value is congruent with the first modulus to obtain a first constant, and the square of the preset value is congruent with the second modulus to obtain a second constant; wherein the preset value is a preset power of 2;

[0130] An operation result corresponding to the data to be operated is determined based on the first constant, the second constant, the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information.

[0131] Based on any of the above embodiments, the determining unit 403 is specifically configured to:

[0132] Get s0;

[0133] Loop execution Until i is equal to the preset position;

[0134] The s 预设位 is determined as the first constant;

[0135] Among them, the s0 corresponds to represents the addition operation of the first modulus p; in represents a multiplication operation of the first modulus p, where i is an integer ranging from 1 to the preset position;

[0136] The step of obtaining a second constant by taking the square of the preset value and the second modulus as congruence includes:

[0137] Get k0;

[0138] Loop execution Until i is equal to the preset position;

[0139] The k 预设位 is determined as the second constant;

[0140] in, in Represents the multiplication operation of the second modulus q, and the k0 corresponds to Represents the addition operation of the second modulus q.

[0141] Based on any of the foregoing embodiments, the inverse metadata includes a first inverse element, a second inverse element, and a third inverse element; wherein the first inverse element is the inverse element of the target random number with respect to the first modulus minus 1, the second inverse element is the inverse element of the target random number with respect to the second modulus minus 1, and the third inverse element is the inverse element of the second modulus with respect to the first modulus; the target random number is a number coprime with phi(n), and phi(n) is the product of the first modulus minus 1 and the second modulus minus 1; the determining unit 403 is specifically configured to:

[0142] Determine a first modular power value based on the first constant, the high-order data to be operated, the first inverse element, and the first modulus;

[0143] determining a second modular power value based on the second constant, the low-order data to be operated on, the second inverse element, and the second modulus;

[0144] An operation result corresponding to the data to be operated is determined based on the first modular exponentiation value, the second modular exponentiation value, the third inverse element and the public key information.

[0145] Based on any of the above embodiments, the determining unit 403 is specifically configured to:

[0146] Determining the first modular power value based on formula (1) and formula (2);

[0147]

[0148]

[0149] Among them, m represents the data to be operated, m1 represents the high-order data to be operated, m2 represents the low-order data to be operated, d p represents the first inverse element, s p represents the first modular power value;

[0150] The determining of the second modular power value based on the second constant, the low-order data to be operated, the second inverse element, and the second modulus includes:

[0151] Determine the second modular power value based on formula (3) and formula (4);

[0152]

[0153]

[0154] Among them, d q represents the second inverse element, s q represents the second modular power value.

[0155] Based on any of the above embodiments, the determining unit 403 is specifically configured to:

[0156] Determine the target value based on formula (5) and formula (6);

[0157]

[0158] S=s q +h×q (6)

[0159] When it is determined that the target value is greater than the public key information, determining the difference between the target value and the public key information as the operation result;

[0160] When it is determined that the target value is less than or equal to the public key information, determining the target value as the operation result;

[0161] Among them, q inv represents the third inverse element, S represents the target value, Represents the subtraction operation of the first modulus p.

[0162] Based on any of the above embodiments, h×q is obtained by sequentially combining the values ​​of the first group of digits, the second group of digits, the third group of digits, and the fourth group of digits; the first group of digits is the lowest digit of h×q, the fourth group of digits is the highest digit of h×q, and the numbers of digits in the first group of digits, the second group of digits, the third group of digits, and the fourth group of digits are all equal;

[0163] Wherein, the high digit of h is h1, the low digit of h is h2, the high digit of q is q1, the low digit of q is q2, h1=HI(h), h2=LO(h), q1=HI(q), q2=LO(q); the value of the first group of digits is The value of the second set of digits is The value of the third group of digits is The value of the fourth group of digits is h1=HI(h), h2=LO(h), q1=HI(q), q2=LO(q); represents a modular multiplication operation, where the modulus of the modular multiplication operation is a preset power of 2.

[0164] Figure 5 This is a schematic diagram of the physical structure of the electronic device provided by the present invention, such as Figure 5 As shown, the electronic device may include: a processor 510, a communication interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communication interface 520, and the memory 530 communicate with each other via the communication bus 540. The processor 510 may call the logic instructions in the memory 530 to execute the RSA private key operation method, which includes: obtaining data to be operated and private key information; wherein the private key information includes a first modulus, a second modulus, and inverse data; the first modulus and the second modulus are prime numbers of preset positions respectively; the number of bits of the data to be operated is twice the preset position, and the preset position is the maximum number of bits that can be processed by the modular multiplier;

[0165] Splitting the data to be operated into high-order data to be operated at the preset position and low-order data to be operated at the preset position;

[0166] An operation result corresponding to the data to be operated is determined based on the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information; wherein the public key information is the product of the first modulus and the second modulus.

[0167] In addition, the logic instructions in the above-mentioned memory 530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0168] On the other hand, the present invention further provides a computer program product, comprising a computer program, which may be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is capable of executing the RSA private key operation method provided by the above methods, the method comprising: obtaining data to be operated and private key information; wherein the private key information comprises a first modulus, a second modulus, and inverse data; the first modulus and the second modulus are prime numbers of preset positions respectively; the number of bits of the data to be operated is twice the preset position, and the preset position is the maximum number of bits that can be processed by the modular multiplier;

[0169] Splitting the data to be operated into high-order data to be operated at the preset position and low-order data to be operated at the preset position;

[0170] An operation result corresponding to the data to be operated is determined based on the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information; wherein the public key information is the product of the first modulus and the second modulus.

[0171] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the RSA private key operation method provided by each of the above methods, the method comprising: obtaining data to be operated and private key information; wherein the private key information comprises a first modulus, a second modulus, and inverse data; the first modulus and the second modulus are prime numbers of preset positions; the number of bits of the data to be operated is twice the preset position, and the preset position is the maximum number of bits that can be processed by the modular multiplier;

[0172] Splitting the data to be operated into high-order data to be operated at the preset position and low-order data to be operated at the preset position;

[0173] An operation result corresponding to the data to be operated is determined based on the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information; wherein the public key information is the product of the first modulus and the second modulus.

[0174] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they may be located in one location or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of the present embodiment. Persons of ordinary skill in the art will be able to understand and implement the present invention without inventive effort.

[0175] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, or of course, by hardware. Based on this understanding, the essence of the above technical solution or the part that contributes to the existing technology can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or certain parts of the embodiments.

[0176] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.

Claims

1. A RSA private key operation method, characterized in that: include: Obtaining data to be operated and private key information; wherein the private key information includes a first modulus, a second modulus, and inverse data; the first modulus and the second modulus are prime numbers of preset positions; the number of bits of the data to be operated is twice the preset position, and the preset position is the maximum number of bits that can be processed by the modular multiplier; Splitting the data to be operated into high-order data to be operated at the preset position and low-order data to be operated at the preset position; The square of a preset value is congruent with the first modulus to obtain a first constant, and the square of the preset value is congruent with the second modulus to obtain a second constant; wherein the preset value is a preset power of 2; Determine an operation result corresponding to the data to be operated based on the first constant, the second constant, the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information; The inverse data includes a first inverse element, a second inverse element and a third inverse element; wherein, the first inverse element is the inverse element of the target random number with respect to the first modulus minus 1, the second inverse element is the inverse element of the target random number with respect to the second modulus minus 1, and the third inverse element is the inverse element of the second modulus with respect to the first modulus; the target random number is Coprime numbers, The product of the first modulus minus 1 and the second modulus minus 1; The determining the operation result corresponding to the data to be operated based on the first constant, the second constant, the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information includes: Determine a first modular power value based on the first constant, the high-order data to be operated, the first inverse element, and the first modulus; determining a second modular power value based on the second constant, the low-order data to be operated on, the second inverse element, and the second modulus; Determine the target value based on formula (5) and formula (6); (5) (6) When it is determined that the target value is greater than the public key information, determining the difference between the target value and the public key information as the operation result; When it is determined that the target value is less than or equal to the public key information, determining the target value as the operation result; in, represents the first modular power value, represents the second modular power value, represents the second modulus, represents the third inverse element, represents the target value, Indicates the first modulus subtraction operation; wherein the public key information is the product of the first modulus and the second modulus.

2. The RSA private key operation method according to claim 1, wherein: The step of obtaining a first constant by taking the square of a preset value and the first modulus as congruence includes: calculate ,get ; Loop execution , until is equal to the preset position; Will is determined as the first constant; Among them, the Corresponding Indicates the first modulus addition operation; in Indicates the first modulus The multiplication operation, The value of is an integer from 1 to the preset position; The step of obtaining a second constant by taking the square of the preset value and the second modulus as congruence includes: calculate ,get ; Loop execution , until is equal to the preset position; Will is determined as the second constant; in, in Represents the second modulus The multiplication operation, Corresponding Represents the second modulus The addition operation.

3. The RSA private key operation method according to claim 2, wherein: The determining of the first modular power value based on the first constant, the high-order data to be operated, the first inverse element, and the first modulus includes: Determining the first modular power value based on formula (1) and formula (2); (1) (2) in, represents the data to be operated, Indicates the high-order data to be operated, Indicates the low-order data to be operated, represents the first inverse element, represents the first modular power value; The determining of the second modular power value based on the second constant, the low-order data to be operated, the second inverse element, and the second modulus includes: Determining the second modular power value based on formula (3) and formula (4); (3) (4) in, represents the second inverse element, represents the second modular power value.

4. The RSA private key operation method according to claim 1, wherein: described The first group of digits is obtained by combining the values ​​of the first group of digits, the second group of digits, the third group of digits and the fourth group of digits in sequence; the first group of digits is the The lowest digit of the fourth group of digits is The highest digit of , and the number of digits in the first group of digits, the second group of digits, the third group of digits and the fourth group of digits are all equal; Among them, the The high digit of , The low digit of , The high digit of , The low digit of , , , , ; The value of the first group of digits is , the value of the second group of digits is , the value of the third group of digits is , the value of the fourth group of digits is ; represents a modular multiplication operation, where the modulus of the modular multiplication operation is a preset power of 2.

5. An RSA private key operation device, characterized in that: include: an acquisition unit, configured to acquire data to be operated and private key information; wherein the private key information includes a first modulus, a second modulus, and inverse data; the first modulus and the second modulus are prime numbers of preset positions; the number of bits of the data to be operated is twice the preset position, and the preset position is the maximum number of bits that can be processed by the modular multiplier; a splitting unit, configured to split the data to be operated into high-order data to be operated at the preset position and low-order data to be operated at the preset position; a determining unit, configured to obtain a first constant by performing a congruence operation on the square of a preset value and the first modulus, and obtain a second constant by performing a congruence operation on the square of the preset value and the second modulus; wherein the preset value is a preset power of 2; Determine an operation result corresponding to the data to be operated based on the first constant, the second constant, the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information; The inverse data includes a first inverse element, a second inverse element and a third inverse element; wherein, the first inverse element is the inverse element of the target random number with respect to the first modulus minus 1, the second inverse element is the inverse element of the target random number with respect to the second modulus minus 1, and the third inverse element is the inverse element of the second modulus with respect to the first modulus; the target random number is Coprime numbers, The product of the first modulus minus 1 and the second modulus minus 1; The determining the operation result corresponding to the data to be operated based on the first constant, the second constant, the private key information, the high-order data to be operated, the low-order data to be operated, and the public key information includes: Determine a first modular power value based on the first constant, the high-order data to be operated, the first inverse element, and the first modulus; determining a second modular power value based on the second constant, the low-order data to be operated on, the second inverse element, and the second modulus; Determine the target value based on formula (5) and formula (6); (5) (6) When it is determined that the target value is greater than the public key information, determining the difference between the target value and the public key information as the operation result; When it is determined that the target value is less than or equal to the public key information, determining the target value as the operation result; in, represents the first modular power value, represents the second modular power value, represents the second modulus, represents the third inverse element, represents the target value, Indicates the first modulus subtraction operation; wherein the public key information is the product of the first modulus and the second modulus.

6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the RSA private key operation method according to any one of claims 1 to 4 is implemented.

7. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the RSA private key operation method according to any one of claims 1 to 4 is implemented.

Citation Information

Patent Citations

  • RSA (Ron Rivest, Adi Shamir and Leonard Adleman) algorithm digital signature method

    CN102571342A