Data processing method, device and equipment
By determining the blinding factor based on the length of the message and key and blinding the message and key, the problem of low security of the existing encryption algorithm is solved and the security of the encryption algorithm is improved.
Patent Information
- Application Number
- CN202210521149.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-13
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2042-05-13
AI Technical Summary
In existing encryption algorithms, fixed-length blinding factors are difficult to meet actual security needs, resulting in low security of encryption algorithms.
By determining the first blinding factor based on the message length and the preset modulus, and determining the second blinding factor based on the key length, the message and key are blinded to generate the first ciphertext and the second ciphertext, and finally, Obtain the encrypted blinded ciphertext.
The security of the encryption algorithm is improved, and the security of the encryption algorithm is enhanced through double blinding of the message and the key, making it difficult to obtain the key through side channel attacks.
Smart Images

Figure CN114978641B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of computer technology, and in particular, to a data processing method, device, and equipment. Background Art
[0002] In the actual communication process, before data transmission, the data can be encrypted by an encryption algorithm to improve the security of data transmission. Among them, the RSA algorithm (Ron Rivest, Adi Shamir, Leonard Adleman) is the most widely used encryption algorithm.
[0003] In order to meet security requirements, the key in the encryption algorithm can be blinded. In the related art, the key in the encryption algorithm is blinded in the following manner: a blinding factor of a fixed length (e.g., 128 bits) is determined, and the key is blinded by the blinding factor. In the above process, since the blinding factor is a fixed length, it is difficult to meet the actual security requirements, resulting in low security of the encryption algorithm. Summary of the invention
[0004] The embodiments of the present application provide a data processing method, apparatus and device, which solve the problem of low security of encryption algorithms.
[0005] In a first aspect, an embodiment of the present application provides a data processing method, including:
[0006] determining a first message to be encrypted and a first key;
[0007] Determining a first blinding factor according to the length of the first message and a preset modulus;
[0008] Determining a second blinding factor according to the length of the first key;
[0009] Blinding the first message according to the first blinding factor to obtain a first ciphertext;
[0010] Blinding the first key according to the second blinding factor to obtain a second ciphertext;
[0011] A blinded ciphertext of the first message is obtained according to the first ciphertext, the second ciphertext and the preset modulus.
[0012] In a possible implementation, determining the first blinding factor includes:
[0013] generating a first random number;
[0014] Determine a first modulus value according to the first random number and the preset modulus value;
[0015] Determine whether the first modulus value and the preset modulus are mutually prime, and when it is determined that the first modulus value and the preset modulus are mutually prime, determine the first modulus value as the first blinding factor.
[0016] In a possible implementation manner, determining whether the first modulus value is coprime with the preset modulus includes:
[0017] Determining the preset modulus as a first operator, and determining the first modulus value as a second operator;
[0018] Updating the first operator to a first odd number corresponding to the preset modulus, and updating the second operator to a second odd number corresponding to the first modulus;
[0019] The first operator and the second operator are subjected to at least one subtraction process and one-bit right shift process to determine whether the first modulus value is coprime with the preset modulus.
[0020] In a possible implementation manner, updating the first operator to a first odd number corresponding to the preset modulus includes:
[0021] If the preset modulus is an odd number, updating the first operator to the preset modulus;
[0022] If the preset modulus is an even number, the preset modulus is right-shifted by one bit at least once until a first right-shift result is an odd number, and the first operator is updated to the first right-shift result.
[0023] In a possible implementation, updating the second operator with a second odd number corresponding to the first modulus value includes:
[0024] If the first modulus value is an odd number, updating the second operator to the first modulus value;
[0025] If the first modulus value is an even number, the first modulus value is right-shifted by one bit at least once until a second right-shift result is an odd number, and the second operator is updated to the second right-shift result.
[0026] In a possible implementation manner, performing at least one subtraction process and one-bit right shift process on the first operator and the second operator to determine whether the first modulus value is coprime with the preset modulus includes:
[0027] Performing a first operation, the first operation comprising: updating the first operator to a maximum value between the first operator and the second operator, and updating the second operator to a minimum value between the first operator and the second operator;
[0028] Performing a second operation, the second operation comprising: determining a difference between the first operator and the second operator, and updating the first operator to a result of right-shifting the difference by one bit;
[0029] Performing a judgment operation, the judgment operation comprising: judging whether the first operator is equal to 0;
[0030] If yes, if the second operator is 1, it is determined that the first modulus value and the preset modulus are coprime; if the second operator is not 1, it is determined that the first modulus value and the preset modulus are not coprime;
[0031] If not, the first operator is updated to an odd number corresponding to the first operator, and the first operation is performed.
[0032] In a possible implementation manner, updating the first operator to an odd number corresponding to the first operator includes:
[0033] When the first operator is an even number, the first operator is right-shifted by one bit at least once until a third right-shift result is an odd number, and the first operator is updated to the third right-shift result.
[0034] In a possible implementation manner, determining the first modulus value according to the first random number and the preset modulus value further includes:
[0035] If the preset modulus and the first modulus value are both even numbers, a new random number is generated.
[0036] In a possible implementation, blinding the first message according to the first blinding factor to obtain a first ciphertext includes:
[0037] The first ciphertext is obtained by performing a modulo operation on the product of the first blinding factor and the first message.
[0038] In a possible implementation manner, performing blinding processing according to the second blinding factor and the first key to obtain a second ciphertext includes:
[0039] A difference between the first secret key and the second blinding factor is determined as the second blinding factor.
[0040] In a possible implementation, processing the first message according to the first blinding factor, the first ciphertext, the second ciphertext, and the preset modulus to obtain a blinded ciphertext of the first message includes:
[0041] Performing a power operation on the first ciphertext, where the base of the power operation is the first ciphertext and the exponent of the power operation is the second ciphertext;
[0042] A modulo operation is performed on the result of the power operation to determine the blinded ciphertext.
[0043] In a possible implementation, the method further includes determining a deblinded message ciphertext C:
[0044] Performing the power operation on the first blinding factor, where the base of the power operation is the reciprocal of the first blinding factor, the exponent of the power operation is the second ciphertext, and determining a result of the power operation as a first result;
[0045] Performing the exponentiation operation on the first message, where the base of the exponentiation operation is the first message, the exponent of the exponentiation operation is the second blinding factor, and determining a result of the exponentiation operation as a second result;
[0046] Perform a modulo operation on the product of the first result, the second result, and the blinded ciphertext to obtain the message ciphertext.
[0047] In a possible implementation, the length of the first message is equal to the length of a first blinding factor, and the first blinding factor is coprime with the preset modulus;
[0048] The length of the first key is equal to the length of the second blinding factor, and the second blinding factor is smaller than the first key.
[0049] In a second aspect, an embodiment of the present application provides a data processing device, the device comprising:
[0050] A first determination module, used to determine a first message to be encrypted and a first key;
[0051] A second determination module, configured to determine a first blinding factor according to a length of the first message and a preset modulus;
[0052] A third determination module, used to determine a second blinding factor according to the length of the first key;
[0053] A first processing module, configured to perform blinding processing on the first message according to the first blinding factor to obtain a first ciphertext;
[0054] A second processing module, configured to perform blinding processing on the first key according to the second blinding factor to obtain a second ciphertext;
[0055] The third processing module is used to process the first message according to the first blinding factor, the first ciphertext, the second ciphertext and the preset modulus to obtain the message ciphertext of the first message.
[0056] In a possible implementation manner, the second determining module is specifically configured to:
[0057] generating a first random number;
[0058] Determine a first modulus value according to the first random number and the preset modulus value;
[0059] Determine whether the first modulus value and the preset modulus are mutually prime, and when it is determined that the first modulus value and the preset modulus are mutually prime, determine the first modulus value as the first blinding factor.
[0060] In a possible implementation manner, the second determining module is specifically configured to:
[0061] Determining the preset modulus as a first operator, and determining the first modulus value as a second operator;
[0062] Updating the first operator to a first odd number corresponding to the preset modulus, and updating the second operator to a second odd number corresponding to the first modulus;
[0063] The first operator and the second operator are subjected to at least one subtraction process and one-bit right shift process to determine whether the first modulus value is coprime with the preset modulus.
[0064] In a possible implementation manner, the second determining module is specifically configured to:
[0065] If the preset modulus is an odd number, updating the first operator to the preset modulus;
[0066] If the preset modulus is an even number, the preset modulus is right-shifted by one bit at least once until a first right-shift result is an odd number, and the first operator is updated to the first right-shift result.
[0067] In a possible implementation manner, the second determining module is specifically configured to:
[0068] If the first modulus value is an odd number, updating the second operator to the first modulus value;
[0069] If the first modulus value is an even number, the first modulus value is right-shifted by one bit at least once until a second right-shift result is an odd number, and the second operator is updated to the second right-shift result.
[0070] In a possible implementation manner, the second determining module is specifically configured to:
[0071] Performing a first operation, the first operation comprising: updating the first operator to a maximum value between the first operator and the second operator, and updating the second operator to a minimum value between the first operator and the second operator;
[0072] Performing a second operation, the second operation comprising: determining a difference between the first operator and the second operator, and updating the first operator to a result of right-shifting the difference by one bit;
[0073] Performing a judgment operation, the judgment operation comprising: judging whether the first operator is equal to 0;
[0074] If yes, if the second operator is 1, it is determined that the first modulus value and the preset modulus are coprime; if the second operator is not 1, it is determined that the first modulus value and the preset modulus are not coprime;
[0075] If not, the first operator is updated to an odd number corresponding to the first operator, and the first operation is performed.
[0076] In a possible implementation manner, the second determining module is specifically configured to:
[0077] When the first operator is an even number, the first operator is right-shifted by one bit at least once until a third right-shift result is an odd number, and the first operator is updated to the third right-shift result.
[0078] In a possible implementation manner, the second determining module is specifically configured to:
[0079] If the preset modulus and the first modulus value are both even numbers, a new random number is generated.
[0080] In a possible implementation manner, the first processing module is specifically configured to:
[0081] The first ciphertext is obtained by performing a modulo operation on the product of the first blinding factor and the first message.
[0082] In a possible implementation manner, the second processing module is specifically configured to:
[0083] A difference between the first secret key and the second blinding factor is determined as the second blinding factor.
[0084] In a possible implementation manner, the third processing module is specifically configured to:
[0085] Performing a power operation on the first ciphertext, where the base of the power operation is the first ciphertext and the exponent of the power operation is the second ciphertext;
[0086] A modulo operation is performed on the result of the power operation to determine the blinded ciphertext.
[0087] In a possible implementation manner, the device further includes a fourth determining module, wherein the fourth determining module is configured to:
[0088] Performing the power operation on the first blinding factor, where the base of the power operation is the reciprocal of the first blinding factor, the exponent of the power operation is the second ciphertext, and determining a result of the power operation as a first result;
[0089] Performing the exponentiation operation on the first message, where the base of the exponentiation operation is the first message, the exponent of the exponentiation operation is the second blinding factor, and determining a result of the exponentiation operation as a second result;
[0090] Perform a modulo operation on the product of the first result, the second result, and the blinded ciphertext to obtain the message ciphertext.
[0091] In a possible implementation, the length of the first message is equal to the length of a first blinding factor, and the first blinding factor is coprime with the preset modulus;
[0092] The length of the first key is equal to the length of the second blinding factor, and the second blinding factor is smaller than the first key.
[0093] In a third aspect, an embodiment of the present application provides a data processing device, including:
[0094] at least one processor; and
[0095] a memory communicatively connected to the at least one processor; wherein,
[0096] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform any method described in the first aspect.
[0097] In a fourth aspect, an embodiment of the present application provides a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to cause the computer to execute the method according to any one of the first aspects.
[0098] In a fifth aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, implements the method according to any one of the first aspects.
[0099] The data processing method, device and equipment provided by the embodiment of the present application perform blinding processing on both the message and the key of the encryption algorithm, and can determine the length of the blinding factor according to the message length and the preset modulus length. In the above process, since both the message and the key are blinded, the security of the encryption algorithm is improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0100] Figure 1 A schematic diagram of an application scenario provided by an embodiment of the present application;
[0101] Figure 2 A flowchart of a data processing method provided in an embodiment of the present application;
[0102] Figure 3 A schematic diagram of a process for determining a first blinding factor provided in an embodiment of the present application;
[0103] Figure 4 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application;
[0104] Figure 5 A schematic diagram of the structure of another data processing device provided in an embodiment of the present application;
[0105] Figure 6 A schematic diagram of the structure of a data processing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0106] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0107] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0108] Figure 1 This is a schematic diagram of an application scenario provided by an embodiment of the present application. Figure 1, including a first device 101 and a second device 102. The first device 101 may be a computer, a server or other device. The second device 102 may be a chip, an integrated circuit, a computer or other device. An encryption algorithm is set in the second device 102, and the encryption algorithm can be run in the second device 102, and the second device 102 stores a key of the encryption algorithm. In actual application, the first device 101 may attack the second device 102 to obtain the key of the encryption algorithm in the second device 102. If the message and key in the second device 102 are not blinded, the first device 101 may obtain the key of the encryption algorithm in the second device 102 by means of side channel attacks or the like. If the message and key in the second device 102 are blinded, it is difficult for the first device 101 to obtain the key of the encryption algorithm in the second device 102 by means of side channel attacks or the like.
[0109] In the related art, the encryption algorithm is usually blinded in the following way: a blinding factor of fixed length (usually 128 bits) is used to blind the key. In the above process, since only the key is blinded and the blinding factor is of fixed length, it is difficult to meet the actual security requirements. As a result, the encryption algorithm has low security.
[0110] In the embodiment of the present application, the message to be sent and the key of the encryption algorithm are both blinded, and the length of the blinding factor can be determined according to the message length and the preset modulus length. In the above process, since both the message and the key are blinded, the security of the encryption algorithm is improved.
[0111] The method shown in the present application is described below through specific embodiments. It should be noted that the following embodiments can exist independently or in combination with each other, and the same or similar contents will not be described repeatedly in different embodiments.
[0112] Figure 2 This is a flow chart of the data processing method provided in the embodiment of the present application. Figure 2 , the method may include:
[0113] S201. Determine a first message to be encrypted and a first key.
[0114] The execution subject of the embodiment of the present application may be a data processing device, or a data processing apparatus arranged in the data processing device. The data processing apparatus may be implemented by software, or by a combination of software and hardware.
[0115] The first message may be a message to be sent by the data processing device.
[0116] The first key may be a number randomly generated by the data processing device before encrypting the first message.
[0117] S202: Determine a first blinding factor according to a length of the first message and a preset modulus.
[0118] The length of the first message is equal to the length of the first blinding factor, and the first blinding factor is relatively prime to the preset modulus.
[0119] The binary information of the first message can be obtained, and the length of the first message can be represented by the number of bits of the binary information. For example, if the binary information of the first message is 01100110, the length of the first message is 8.
[0120] The preset modulus may be the modulus of the RSA algorithm.
[0121] The first blinding factor is coprime with the preset modulus. When the greatest common divisor of two numbers is only 1, the two numbers are coprime. The first blinding factor is coprime with the preset modulus, that is, the greatest common divisor of the first blinding factor and the preset modulus is 1. For example, the preset modulus can be 11, and the first blinding factor can be 3, 5, etc.
[0122] S203: Determine a second blinding factor according to the length of the first key.
[0123] The length of the first key is equal to the length of the second blinding factor, and the second blinding factor is smaller than the first key.
[0124] The binary information of the first key can be obtained, and the length of the first key can be represented by the number of bits of the binary information. For example, if the binary information of the first key is 01101110, the length of the first key is 8.
[0125] S204: Perform blinding processing on the first message according to a first blinding factor to obtain a first ciphertext.
[0126] A first ciphertext is obtained by performing a modulo operation on the product of the first blinding factor and the first message.
[0127] The first ciphertext M′ is determined by the following formula 1:
[0128] M′=(V i ×M)mod N Formula 1;
[0129] Among them, V i is the first blinding factor, M is the first message, and N is the preset modulus.
[0130] S205. Blind the first key according to the second blinding factor to obtain a second ciphertext.
[0131] The difference between the first secret key and the second blinding factor is determined as the second blinding factor.
[0132] The second ciphertext d′ is determined by the following formula 2:
[0133] d′=dr Formula 2;
[0134] Wherein, d is the first key and r is the second blinding factor.
[0135] S206. Obtain a blinded ciphertext of the first message according to the first ciphertext, the second ciphertext and a preset modulus.
[0136] The blinded ciphertext of the first message may be determined in the following manner: performing a power operation on the first ciphertext, where the base of the power operation is the first ciphertext and the exponent of the power operation is the second ciphertext; and performing a modulus operation on a result of the power operation to determine the blinded ciphertext.
[0137] The blinded ciphertext C′ is determined by the following formula 3:
[0138] C′=M′ d′ mod N formula 3;
[0139] Wherein, M′ is the first ciphertext, d′ is the second ciphertext, and N is the preset modulus.
[0140] Optionally, the unblinded message ciphertext may be determined based on the blinded ciphertext. The unblinded message ciphertext may be determined in the following manner: performing a power operation on the first blinding factor, the base of the power operation being the reciprocal of the first blinding factor, the exponent of the power operation being the second ciphertext, and determining the result of the power operation as the first result; performing a power operation on the first message, the base of the power operation being the first message, the exponent of the power operation being the second blinding factor, and determining the result of the power operation as the second result; performing a modulo operation on the product of the first result, the second result, and the blinded ciphertext to obtain the message ciphertext.
[0141] According to the following formula 4 and formula 5, the message ciphertext C after deblinding is determined;
[0142] V f =V i -d′ mod N formula 4;
[0143] C=(V f ×C′×M r )mod N Formula 5;
[0144] Among them, V i is the first blinding factor, d′ is the second ciphertext, N is the preset modulus, C′ is the blinded ciphertext, M is the first message, and r is the second blinding factor.
[0145] The data processing method provided in the embodiment of the present application determines the first message and the first key to be encrypted; determines the first blinding factor according to the length of the first message and the preset modulus; determines the second blinding factor according to the length of the first key; blinds the first message according to the first blinding factor to obtain the first ciphertext; blinds the first key according to the second blinding factor to obtain the second ciphertext; processes the first message according to the first blinding factor, the first ciphertext, the second ciphertext and the preset modulus to obtain the ciphertext of the first message. In the above process, since both the message and the key are blinded, and the length of the blinding factor is determined according to the length of the message and the key, the security of the encryption algorithm is improved.
[0146] In the related art, the Euclidean algorithm or the Euclidean algorithm based on XOR operation is usually used to determine the first blinding factor, that is, the modulus operation is continuously performed on two random numbers, and when the remainder is 0, the divisor of the current formula is taken as the greatest common divisor. In the above process, if the Euclidean algorithm or the Euclidean algorithm based on XOR operation is used to perform a modulus operation on a number larger than 128 bits, the operation process is complicated and slow. In order to increase the speed of determining the first blinding factor, the embodiment of the present application can determine the first blinding factor by subtracting and right shifting by one bit. Next, in combination with Figure 3 , the detailed process of determining the first blinding factor is explained.
[0147] Figure 3 This is a flow chart of a method for determining a first blinding factor provided in an embodiment of the present application. Figure 3 , the method comprising:
[0148] S301. Generate an i-th random number.
[0149] Initially, i is 1.
[0150] S302, obtaining an i-th modulus value obtained by taking the i-th random number and a preset modulus.
[0151] For example, the random number can be W i , the preset modulus can be N, and the i-th modulus value can be V i The relationship between them can be expressed as V i =W i mod N.
[0152] S303: Determine whether the preset modulus and the i-th modulus value are both even numbers.
[0153] If yes, execute S304.
[0154] If not, execute S305.
[0155] S304: Update i to i+1.
[0156] After S304, S301 is executed.
[0157] S305: Determine a preset modulus as a first operator, and determine the i-th modulus value as a second operator.
[0158] S306: Update the first operator to a first odd number corresponding to the preset modulus.
[0159] The first odd number corresponding to the first operator can be determined in the following manner: if the preset modulus is an odd number, the first operator is updated to the preset modulus; if the preset modulus is an even number, the preset modulus is right-shifted by one bit at least once until the first right-shift result is an odd number, and the first operator is updated to the first right-shift result.
[0160] The preset modulus can be right-shifted in the following manner: obtain the binary information of the preset modulus, and right-shift the binary form of the preset modulus by one digit. That is, fill the leftmost digit of the binary form with zeros and remove the rightmost digit. For example, if the binary information corresponding to the preset modulus is 0110, the right-shift result obtained after right-shifting the preset modulus once is 0011.
[0161] For example, if the preset modulus is 5, which is an odd number, the first operator can be determined to be 5. If the preset modulus is 6, which is an even number, 6 can be represented as 0110 in binary, and the preset modulus 0110 is shifted right by one position to obtain 0011, which can be represented as 3 in decimal. At this time, the first right shift result 3 is an odd number, so the first operator can be determined to be 3.
[0162] S307. Update the second operator with a second odd number corresponding to the i-th modulus value.
[0163] The second odd number corresponding to the second operator can be determined in the following manner: if the i-th modulus value is an odd number, the second operator is updated to the i-th modulus value; if the i-th modulus value is an even number, the i-th modulus value is right-shifted by one bit at least once until the second right-shift result is an odd number, and the second operator is updated to the second right-shift result.
[0164] For example, if the i-th modulus value is 7, which is an odd number, then the second operator can be determined to be 7. If the i-th modulus value is 10, which is an even number, 10 can be represented as 1010 in binary, and 1010 is shifted right by one position to obtain 0101, which can be represented as 5 in decimal. At this time, the first integer result 5 obtained is an odd number, so the second operator can be determined to be 5.
[0165] S308: Update the first operator to the maximum value of the first operator and the second operator, and update the second operator to the minimum value of the first operator and the second operator.
[0166] For example, the first operator is 57 and the second operator is 71, then the updated first operator is the maximum value 71 between the first operator and the second operator, and the updated second operator is the minimum value 57 between the first operator and the second operator.
[0167] S309: Determine the difference between the first operator and the second operator, and update the first operator to the operation result of right-shifting the difference between the first operator and the second operator by one position.
[0168] For example, if the first operator is 9 and the second operator is 7, then the difference between the first operator and the second operator is 2, which can be represented as 0010 in binary, shifted right by one position to 0001, and represented as 1 in decimal.
[0169] S310: Determine whether the first operator is equal to 0.
[0170] If so, execute S312.
[0171] If not, execute S311.
[0172] S311. Update the first operator to an odd number corresponding to the first operator.
[0173] The first operator can be updated to an odd number corresponding to the first operator in the following manner: when the first operator is an odd number, the first operator is directly used as the updated first operator; when the first operator is an even number, the first operator is right-shifted by one bit at least once until the third right-shift result is an odd number, and the first operator is updated to the third right-shift result.
[0174] For example, if the preset modulus is 11 and the i-th modulus is 7, the first operator is 11 and the second operator is 7, and the first operator is updated to the right shift result 2 of the difference between the first operator and the second operator. At this time, the first operator is an even number, and it needs to be shifted right by one position, and the third right shift result is 1. At this time, the third right shift result is an odd number, and the third right shift result 1 is updated to the first operator.
[0175] After S311, S308 is executed.
[0176] S312: Determine whether the second operator is 1.
[0177] If so, execute S314.
[0178] If not, execute S313
[0179] S313, determining that the i-th modulus value is not coprime with the preset modulus.
[0180] For example, if the preset modulus is 15 and the first modulus value is 5, then according to steps S301 to S306, it is determined that the first operator is 15 and the second operator is 5. According to steps S306 to S313, the calculation results obtained are specifically shown in Table 1:
[0181] Table 1
[0182]
[0183] According to Table 1, the result of right shifting the difference between the first operator and the second operator by one position is 0, that is, the updated first operator is 0 and the second operator is 5. If the first operator is 0 and the second operator is not 1, it is determined that the first modulus value 5 is not coprime with the preset modulus 15. Then continue to execute S304.
[0184] After S313, S304 is executed.
[0185] S314, determining whether the i-th modulus value is coprime with a preset modulus.
[0186] S315. Determine the i-th modulus value as the first blinding factor.
[0187] If the first operator is 0 and the second operator is 1, the i-th modulus value can be determined to be the first blinding factor.
[0188] For example, the preset modulus is 9 and the first modulus value is 19, then according to steps S301 to S306, the first operator is determined to be 11 and the second operator is determined to be 9. According to steps S306 to S315, the specific situation of determining the first blinding factor is shown in Table 2:
[0189] Table 2
[0190]
[0191] According to Table 2, the result of right shifting the difference between the first operator and the second operator by one position is 0, that is, the updated first operator is 0. At this time, the first operator is 0 and the second operator is 1. If the first operator is 0 and the second operator is 1, it is determined that the first modulus value is coprime with the preset modulus, and the first blinding factor is the first modulus value 19.
[0192] The method for determining the first blinding factor provided in the embodiment of the present application obtains the i-th modulus value obtained by taking the modulus of the i-th random number and the preset modulus, and determines whether the preset modulus and the i-th modulus value are mutually prime by subtracting and right-shifting the preset modulus and the i-th modulus value. If the preset modulus and the i-th modulus value are mutually prime, the i-th modulus value is the first blinding factor. In the above process, a subtraction operation is used instead of a modulus operation, and the calculation process can be nearly 10 times faster than the Euclidean algorithm and the Euclidean algorithm based on XOR operation, thereby increasing the speed of determining the first blinding factor.
[0193] exist Figure 3 Based on the embodiment, the detailed process of determining the first blinding factor is illustrated below.
[0194] The first random number W1 is 52, the preset modulus N is 6, and the first modulus V1 obtained by taking the first random number 52 and the preset modulus 6 is V1=W1 mod N=52mod 6=4. The preset modulus 6 is an even number, and the first modulus 4 is an even number, so the second random number W2 generated is 93, and the preset modulus N is 15.
[0195] The second random number W2 is 93, and the preset modulus N is 15. The second modulus V2 obtained by taking the second random number 93 and the preset modulus 15 is obtained, specifically V2=W2 mod N=93mod 15=3. The preset modulus 15 is an odd number, and the first modulus 3 is an odd number. The preset modulus 15 is determined as the first operator, and the second modulus 3 is determined as the second operator. The difference between the first operator and the second operator is determined to be 15-3=12, and the operation result 6 of the right shift of the difference between the first operator and the second operator is determined to be an even number. The first operator is updated to the third right shift result 3 after the right shift processing. At this time, the first operator is 3, and the second operator is 3. The difference between the first operator and the second operator is determined to be 3-3=0, and the first operator is updated to the operation result 0 of the right shift of the difference between the first operator and the second operator 0. At this time, the first operator is 0, and the second operator is 3. Since the second operator is not equal to 1, it can be determined that the second modulus 3 is not coprime with the preset modulus 15. The third random number W3 is generated as 77, and the preset modulus N is 15.
[0196] The third random number W3 is 77, and the preset modulus N is 15. The third modulus V3 obtained by taking the third random number 77 and the preset modulus 15 is specifically V3=W3 mod N=77mod 15=2. The preset modulus 15 is an odd number, and the third modulus 2 is an even number. The preset modulus 15 is determined as the first operator, and the second right shift result 1 obtained by shifting the second modulus 2 right by one position is determined as the second operator. The difference between the first operator and the second operator is determined to be 15-1=14, and the first operator is updated to the operation result 7 of the right shift of the difference 14 between the first operator and the second operator. At this time, the first operator is 7 and the second operator is 1. The difference between the first operator and the second operator is determined to be 7-1=6, and the first operator is updated to the operation result 3 of the right shift of the difference 6 between the first operator and the second operator. At this time, the first operator is 3 and the second operator is 1. It is determined that the difference between the first operator and the second operator is 3-1=2, and the first operator is updated to the operation result 1 of the right shift of the difference 2 of the first operator and the second operator. At this time, the first operator is 1 and the second operator is 1. It is determined that the difference between the first operator and the second operator is 1-1=0, and the first operator is updated to the operation result 0 of the right shift of the difference 0 of the first operator and the second operator. At this time, the first operator is 0 and the second operator is 1, then it is determined that the third modulus 2 is coprime with the preset modulus 15, and the third modulus 2 is determined as the first blinding factor.
[0197] The example provided in the embodiment of the present application illustrates a method for determining the first blinding factor, obtaining the i-th modulus value obtained by taking the modulus of the i-th random number and the preset modulus, and determining whether the preset modulus and the i-th modulus value are mutually prime by subtracting and right-shifting the preset modulus and the i-th modulus value. If the preset modulus and the i-th modulus value are mutually prime, the i-th modulus value is the first blinding factor. In the above process, a subtraction operation is used instead of a modulus operation to increase the speed of determining the first blinding factor.
[0198] Figure 4 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. Figure 4 , the data processing device 10 may include:
[0199] A first determination module 11, used to determine a first message to be encrypted and a first key;
[0200] A second determination module 12, configured to determine a first blinding factor according to the length of the first message and a preset modulus;
[0201] A third determination module 13, configured to determine a second blinding factor according to the length of the first key;
[0202] A first processing module 14, configured to perform blinding processing on the first message according to the first blinding factor to obtain a first ciphertext;
[0203] A second processing module 15, configured to perform blinding processing on the first key according to the second blinding factor to obtain a second ciphertext;
[0204] The third processing module 16 is used to process the first message according to the first blinding factor, the first ciphertext, the second ciphertext and the preset modulus to obtain the message ciphertext of the first message.
[0205] The data processing device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0206] In a possible implementation manner, the second determining module 12 is specifically configured to:
[0207] Generate the i-th random number;
[0208] generating a first random number;
[0209] Determine a first modulus value according to the first random number and the preset modulus value;
[0210] Determine whether the first modulus value and the preset modulus are mutually prime, and when it is determined that the first modulus value and the preset modulus are mutually prime, determine the first modulus value as the first blinding factor.
[0211] In a possible implementation manner, the second determining module 12 is specifically configured to:
[0212] Determining the preset modulus as a first operator, and determining the first modulus value as a second operator;
[0213] Updating the first operator to a first odd number corresponding to the preset modulus, and updating the second operator to a second odd number corresponding to the first modulus;
[0214] The first operator and the second operator are subjected to at least one subtraction process and one-bit right shift process to determine whether the first modulus value is coprime with the preset modulus.
[0215] In a possible implementation manner, the second determining module 12 is specifically configured to:
[0216] If the preset modulus is an odd number, updating the first operator to the preset modulus;
[0217] If the preset modulus is an even number, the preset modulus is right-shifted by one bit at least once until a first right-shift result is an odd number, and the first operator is updated to the first right-shift result.
[0218] In a possible implementation manner, the second determining module 12 is specifically configured to:
[0219] If the first modulus value is an odd number, updating the second operator to the first modulus value;
[0220] If the first modulus value is an even number, the first modulus value is right-shifted by one bit at least once until a second right-shift result is an odd number, and the second operator is updated to the second right-shift result.
[0221] In a possible implementation manner, the second determining module 12 is specifically configured to:
[0222] Performing a first operation, the first operation comprising: updating the first operator to a maximum value between the first operator and the second operator, and updating the second operator to a minimum value between the first operator and the second operator;
[0223] Performing a second operation, the second operation comprising: determining a difference between the first operator and the second operator, and updating the first operator to a result of right-shifting the difference by one bit;
[0224] Performing a judgment operation, the judgment operation comprising: judging whether the first operator is equal to 0;
[0225] If yes, if the second operator is 1, it is determined that the first modulus value and the preset modulus are coprime; if the second operator is not 1, it is determined that the first modulus value and the preset modulus are not coprime;
[0226] If not, the first operator is updated to an odd number corresponding to the first operator, and the first operation is performed.
[0227] In a possible implementation manner, the second determining module 12 is specifically configured to:
[0228] When the first operator is an even number, the first operator is right-shifted by one bit at least once until a third right-shift result is an odd number, and the first operator is updated to the third right-shift result.
[0229] In a possible implementation manner, the second determining module 12 is specifically configured to:
[0230] If the preset modulus and the first modulus value are both even numbers, a new random number is generated.
[0231] In a possible implementation manner, the first processing module 14 is specifically configured to:
[0232] The first ciphertext is obtained by performing a modulo operation on the product of the first blinding factor and the first message.
[0233] In a possible implementation manner, the second processing module 15 is specifically used to:
[0234] A difference between the first secret key and the second blinding factor is determined as the second blinding factor.
[0235] In a possible implementation manner, the third processing module 16 is specifically configured to:
[0236] Performing a power operation on the first ciphertext, where the base of the power operation is the first ciphertext and the exponent of the power operation is the second ciphertext;
[0237] A modulo operation is performed on the result of the power operation to determine the blinded ciphertext.
[0238] The data processing device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0239] Figure 5 A schematic diagram of the structure of another data processing device provided in an embodiment of the present application. Figure 4 Based on the examples shown, see Figure 5 , the data processing device further includes a fourth determining module 17:
[0240] Wherein, the fourth determining module 17 is used for:
[0241] Performing the power operation on the first blinding factor, where the base of the power operation is the reciprocal of the first blinding factor, the exponent of the power operation is the second ciphertext, and determining a result of the power operation as a first result;
[0242] Performing the exponentiation operation on the first message, where the base of the exponentiation operation is the first message, the exponent of the exponentiation operation is the second blinding factor, and determining a result of the exponentiation operation as a second result;
[0243] Perform a modulo operation on the product of the first result, the second result, and the blinded ciphertext to obtain the message ciphertext.
[0244] The data processing device provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.
[0245] Figure 6 This is a schematic diagram of the structure of a data processing device provided in an embodiment of the present application. Figure 6 The data processing device 20 may include: a memory 21 and a processor 22. Exemplarily, the memory 21 and the processor 22 are interconnected via a bus 23.
[0246] The memory 21 is used to store program instructions;
[0247] The processor 22 is used to execute the program instructions stored in the memory, so as to enable the data processing device 20 to execute the method shown in the above method embodiment.
[0248] An embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the above method.
[0249] The embodiment of the present application may also provide a computer program product, including a computer program, which can implement the above method when executed by a processor.
[0250] All or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a readable memory. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned memory (storage medium) includes: read-only memory (English: read-only memory, abbreviated: ROM), RAM, flash memory, hard disk, solid state drive, magnetic tape (English: magnetic tape), floppy disk (English: floppy disk), optical disc (English: optical disc) and any combination thereof.
[0251] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0252] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0253] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0254] Obviously, those skilled in the art can make various changes and modifications to the embodiments of the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the embodiments of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
[0255] In the present application, the term "include" and its variations may refer to non-restrictive inclusion; the term "or" and its variations may refer to "and / or". The terms "first", "second", etc. in the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. In the present application, "plurality" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B may mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previously associated objects are in an "or" relationship.
Claims
1. A data processing method, characterized in that: include: Determining a first message to be encrypted and a first key; Determining a first blinding factor according to the length of the first message and a preset modulus; Determining a second blinding factor according to the length of the first key; Blinding the first message according to the first blinding factor to obtain a first ciphertext; Blinding the first key according to the second blinding factor to obtain a second ciphertext; Obtain a blinded ciphertext of the first message according to the first ciphertext, the second ciphertext and the preset modulus; Determine the first blinding factor, including: generating a first random number; Determine a first modulus value according to the first random number and the preset modulus; Determining the preset modulus as a first operator, and determining the first modulus value as a second operator; If the preset modulus is an odd number, updating the first operator to the preset modulus; If the preset modulus is an even number, right-shift the preset modulus by one bit at least once until a first right-shift result is an odd number, and then update the first operator to the first right-shift result; If the first modulus value is an odd number, updating the second operator to the first modulus value; If the first modulus value is an even number, right-shift the first modulus value by one bit at least once until a second right-shift result is an odd number, and then update the second operator to the second right-shift result; Perform at least one subtraction process and one-bit right shift process on the first operator and the second operator to determine whether the first modulus value is coprime with the preset modulus; When it is determined that the first modulus value and the preset modulus are mutually prime, the first modulus value is determined as the first blinding factor.
2. The method according to claim 1, characterized in that Performing at least one subtraction process and one-bit right shift process on the first operator and the second operator to determine whether the first modulus value is coprime with the preset modulus, including: Performing a first operation, the first operation comprising: updating the first operator to a maximum value between the first operator and the second operator, and updating the second operator to a minimum value between the first operator and the second operator; Performing a second operation, the second operation comprising: determining a difference between the first operator and the second operator, and updating the first operator to a result of right-shifting the difference by one bit; Performing a judgment operation, the judgment operation comprising: judging whether the first operator is equal to 0; If yes, if the second operator is 1, it is determined that the first modulus value and the preset modulus are coprime; if the second operator is not 1, it is determined that the first modulus value and the preset modulus are not coprime; If not, the first operator is updated to an odd number corresponding to the first operator, and the first operation is performed.
3. The method according to claim 2, characterized in that Updating the first operator to an odd number corresponding to the first operator includes: When the first operator is an even number, the first operator is right-shifted by one bit at least once until a third right-shift result is an odd number, and the first operator is updated to the third right-shift result.
4. The method according to any one of claims 1 to 3, characterized in that: Determining a first modulus value according to the first random number and the preset modulus further includes: If the preset modulus and the first modulus value are both even numbers, a new random number is generated.
5. The method according to any one of claims 1 to 3, characterized in that: Blinding the first message according to the first blinding factor to obtain a first ciphertext includes: The first ciphertext is obtained by performing a modulo operation on the product of the first blinding factor and the first message.
6. The method according to any one of claims 1 to 3, characterized in that: Blinding is performed according to the second blinding factor and the first key to obtain a second ciphertext, including: A difference between the first key and the second blinding factor is determined as the second ciphertext.
7. The method according to any one of claims 1 to 3, characterized in that: Processing the first message according to the first blinding factor, the first ciphertext, the second ciphertext, and the preset modulus to obtain a blinded ciphertext of the first message includes: Performing a power operation on the first ciphertext, where the base of the power operation is the first ciphertext and the exponent of the power operation is the second ciphertext; A modulo operation is performed on the result of the power operation to determine the blinded ciphertext.
8. The method according to claim 7, characterized in that The method further includes determining a deblinded message ciphertext C: Performing the power operation on the first blinding factor, where the base of the power operation is the reciprocal of the first blinding factor, the exponent of the power operation is the second ciphertext, and determining a result of the power operation as a first result; Performing the exponentiation operation on the first message, where the base of the exponentiation operation is the first message, the exponent of the exponentiation operation is the second blinding factor, and determining a result of the exponentiation operation as a second result; Perform a modulo operation on the product of the first result, the second result, and the blinded ciphertext to obtain the message ciphertext.
9. The method according to any one of claims 1 to 3 and 8, characterized in that: The length of the first message is equal to the length of a first blinding factor, and the first blinding factor is coprime with the preset modulus; The length of the first key is equal to the length of the second blinding factor, and the second blinding factor is smaller than the first key.
10. A data processing device, characterized in that: The device comprises: A first determination module, used to determine a first message to be encrypted and a first key; A second determination module, configured to determine a first blinding factor according to a length of the first message and a preset modulus; A third determination module, used to determine a second blinding factor according to the length of the first key; A first processing module, configured to perform blinding processing on the first message according to the first blinding factor to obtain a first ciphertext; A second processing module, configured to perform blinding processing on the first key according to the second blinding factor to obtain a second ciphertext; A third processing module, configured to process the first message according to the first blinding factor, the first ciphertext, the second ciphertext and the preset modulus to obtain a message ciphertext of the first message; A second determination module, specifically configured to generate a first random number; Determine a first modulus value according to the first random number and the preset modulus; Determining the preset modulus as a first operator, and determining the first modulus value as a second operator; If the preset modulus is an odd number, updating the first operator to the preset modulus; If the preset modulus is an even number, right-shift the preset modulus by one bit at least once until a first right-shift result is an odd number, and then update the first operator to the first right-shift result; If the first modulus value is an odd number, updating the second operator to the first modulus value; If the first modulus value is an even number, right-shift the first modulus value by one bit at least once until a second right-shift result is an odd number, and then update the second operator to the second right-shift result; Perform at least one subtraction process and one-bit right shift process on the first operator and the second operator to determine whether the first modulus value is coprime with the preset modulus; When it is determined that the first modulus value and the preset modulus are mutually prime, the first modulus value is determined as the first blinding factor.
11. A data processing device, characterized in that: include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 9.
12. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 9.
13. A computer program product, comprising a computer program, which implements the method according to any one of claims 1 to 9 when executed by a processor.
Citation Information
Patent Citations
Password device using information blinding and password processing method thereof
CN111385092A