A register-based data parallel encryption and decryption method and system
By employing a register-based parallel data encryption and decryption method, utilizing the Montgomery algorithm and binary fast exponentiation algorithm, and processing RSA encryption and decryption blocks in parallel, the low efficiency and poor resource utilization of RSA encryption and decryption technology in IoT applications are solved, achieving efficient data encryption and decryption and flexible hardware adaptation.
Patent Information
- Application Number
- CN202511563063.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-30
- Publication Date
- 2026-01-27
- Estimated Expiration
- 2045-10-30
AI Technical Summary
Existing RSA encryption and decryption technologies suffer from problems such as low software implementation efficiency, poor ASIC resource utilization, high scalar core storage costs, register access conflicts, and data security risks in IoT applications.
A register-based parallel data encryption and decryption method is adopted. By splitting plaintext or ciphertext into multiple blocks and processing each block in parallel, the Montgomery algorithm and binary fast exponentiation algorithm are used for parallel operation, and custom instructions are combined to realize parallel data encryption and decryption.
It improves encryption and decryption efficiency, reduces hardware resource consumption, supports encryption and decryption requirements of arbitrary bit widths such as 1024-bit, 2048-bit, and 4096-bit, has good flexibility and scalability, and avoids redundant operations and register access conflicts.
Smart Images

Figure CN121036949B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of information security and encryption / decryption technology, specifically relating to a register-based parallel data encryption / decryption method and system. Background Technology
[0002] RSA is an asymmetric encryption algorithm proposed by Ron Rivest, Adi Shamir, and Leonard Adleman in 1977. It uses a pair of keys (public and private) to encrypt and decrypt, and its security is based on the computational complexity of the large integer factorization problem.
[0003] However, currently available RSA encryption and decryption solutions have the following problems:
[0004] 1. The RSA algorithm is implemented using software programming, which has high flexibility. However, the algorithm involves large number operations, and the software implementation relies on the sequential execution of the instruction set of a general-purpose processor, which is relatively slow and difficult to meet the application requirements of real-time processing in the Internet of Things.
[0005] 2. Implementing the RSA algorithm through a custom ASIC results in a single hardware function that cannot be reused for other functions, leading to low hardware resource utilization and increased overall system cost.
[0006] 3. Scalar cores cannot directly store large-width data. Dedicated instantiation of large-width registers would consume significant hardware resources, increasing chip area and power consumption, leading to excessively high hardware costs. Using the core's own low-width registers would require multiple load / store operations; for example, storing 1024 bits of data in a 32-bit register would require 32 store instructions. These redundant instructions continuously occupy the scalar core's instruction fetch and decode units. Furthermore, frequent load / store operations would preempt data bus bandwidth, causing other critical instructions to wait for bus resources, significantly increasing the overall cycle time index (CPI).
[0007] 4. When reusing CPU vector registers to store large-width data, register access conflicts can easily occur with the CPU's general-purpose operations, leading to calculation errors or timing disorders, especially in scenarios with high real-time requirements. Moreover, when the CPU and coprocessor share registers, sensitive key data may be leaked through the CPU's debug interface, cache snapshots, and other means. Summary of the Invention
[0008] To address the issues of low software implementation efficiency, poor ASIC resource utilization, high scalar core storage cost, and register access conflicts and data security risks mentioned in the background technology, this invention provides a register-based parallel data encryption and decryption method and system. This method and system, relying on registers, achieves parallel data encryption and decryption by using lightweight custom instructions, block parallel storage, and vector parallel computation. It improves encryption and decryption efficiency while ensuring flexibility and data security, reduces hardware resource consumption, and is suitable for real-time processing scenarios such as the Internet of Things.
[0009] The technical solution of the present invention is as follows:
[0010] This invention provides a register-based parallel data encryption and decryption method, characterized by comprising:
[0011] S1: Based on the register bit width, the plaintext is split into multiple plaintext blocks, and then the multiple plaintext blocks are processed in parallel. Based on the Montgomery algorithm, each plaintext block is converted into a Montgomery field to obtain multiple Montgomery field plaintext blocks.
[0012] S2: Based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, multiple Montgomery field plaintext blocks are processed in parallel in each round according to the order of the most significant bit to the least significant bit of the public key exponent, resulting in multiple intermediate plaintext results. The operation is as follows:
[0013] S21: Initialize the multiplication identity of k modular exponentiation operations to 1 for use in k block encryption;
[0014] S22: If the public key exponent bit of the current round is 1, then use the multiplication unit of the previous round's modular exponentiation operation and the plaintext block of the current round's Montgomery field to perform modular multiplication operations in parallel, and obtain the multiplication unit of the current round's modular exponentiation operation for each block;
[0015] If the current round's public key index is 0, then execute S23 directly;
[0016] S23: Utilize the plaintext blocks of the current round Montgomery domain, perform the modulo square operation in parallel, update the plaintext blocks of the current round Montgomery domain for each block, and execute S22 until all binary bits of the public key exponent are processed to obtain the intermediate plaintext result corresponding to each block;
[0017] S3: Process multiple intermediate plaintext results in parallel, and based on the Montgomery algorithm, restore the multiple intermediate plaintext results to ordinary fields to obtain multiple ciphertext blocks; adjust the bit order of the multiple ciphertext blocks and merge them into ciphertext.
[0018] Furthermore, as described in S1, the plaintext is split into multiple plaintext blocks according to the register bit width, which is achieved according to the formula: k=N / M;
[0019] In the formula, k is the number of plaintext blocks; N is the key width of the plaintext; and M is the register width.
[0020] Furthermore, S1 describes a method based on the Montgomery algorithm, which converts each plaintext block into a Montgomery field, according to the formula: = ( (×R) mod n, to achieve;
[0021] In the formula, , These represent the plaintext before and after the Montgomery field transformation, respectively; i = 1, 2, 3, ..., k; mod represents ( After dividing (×R) by the modulus n, take the remainder of the result; R is the Montgomery parameter, and R=2. N N is the key width of the plaintext.
[0022] Furthermore, S3 describes using the Montgomery algorithm to restore multiple intermediate plaintext results to the ordinary field, based on the formula: =(res i ×R_inv) mod n, to achieve;
[0023] In the formula, res i Represents the intermediate plaintext result; The modulo operator represents the plaintext result as a normal field representation, where i = 1, 2, 3, ..., k; mod represents (res) i After dividing (×R_inv) by the modulus n, take the remainder of the result; R_inv is the modulus n inverse of the Montgomery parameter R, and R=2. N N is the key width of the plaintext.
[0024] Accordingly, the present invention also provides a register-based parallel data encryption and decryption system, comprising:
[0025] Plaintext Segmentation and Montgomery Field Conversion Module: Based on the register bit width, the plaintext is split into multiple plaintext blocks, and multiple plaintext blocks are processed in parallel. Based on the Montgomery algorithm, each plaintext block is converted into a Montgomery field, resulting in multiple Montgomery field plaintext blocks.
[0026] Parallel computation module: Based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, it processes multiple Montgomery field plaintext blocks in parallel in each round according to the order of the most significant bit to the least significant bit of the public key exponent, obtaining multiple intermediate plaintext results. The operation is as follows:
[0027] Initialization module: Initializes the multiplication identity of k modular exponentiation operations to 1, for use in k block encryption;
[0028] Modular multiplication module: If the public key exponent bit of the current round is 1, then the modular multiplication operation is performed in parallel using the multiplication unit of the previous round's modular exponentiation operation and the plaintext block of the Montgomery field of the current round, to obtain the multiplication unit of the current round's modular exponentiation operation for each block;
[0029] If the current round's public key index is 0, then the modulo square operation module is executed directly;
[0030] Modular square operation module: Utilize the plaintext blocks of the current round Montgomery domain, perform modular square operations in parallel, update the plaintext blocks of the current round Montgomery domain for each block, and execute the modular multiplication operation module until all binary bits of the public key exponent are processed to obtain the intermediate plaintext result corresponding to each block;
[0031] Domain restoration module: processes multiple intermediate plaintext results in parallel, and restores the multiple intermediate plaintext results to ordinary fields based on the Montgomery algorithm, resulting in multiple ciphertext blocks; adjusts the bit order of multiple ciphertext blocks and merges them into ciphertext.
[0032] This invention also provides a register-based parallel data encryption and decryption method, comprising:
[0033] (1) Based on the register bit width, the ciphertext is split into multiple ciphertext blocks, and the multiple ciphertext blocks are processed in parallel. Based on the Montgomery algorithm, each ciphertext block is converted into a Montgomery field to obtain multiple Montgomery field ciphertext blocks.
[0034] (2) Based on the binary fast exponentiation algorithm, after the multiplication identity of the modular exponentiation operation is initialized to 1, multiple Montgomery domain ciphertext blocks are processed in parallel in each round according to the order of the most significant bit to the least significant bit of the private key exponent binary bits to obtain multiple intermediate ciphertext results. The operation is as follows:
[0035] (21) Initialize the multiplication identity of the k modular exponentiation operations to 1 for use in the k block decryption;
[0036] (22) If the current round private key exponent is 1, then use the multiplication unit of the previous round modular exponentiation and the current round Montgomery field ciphertext blocks to perform modular multiplication in parallel, and obtain the multiplication unit of the current round modular exponentiation for each block.
[0037] If the current round private key index is 0, then proceed directly to step (23).
[0038] (23) Using the current round Montgomery domain ciphertext blocks, perform the modulo square operation in parallel, update the current round Montgomery domain ciphertext blocks of each block, and execute step (22) until all binary bits of the private key index are processed to obtain the intermediate ciphertext result corresponding to each block;
[0039] (3) Process multiple intermediate ciphertext results in parallel, and based on the Montgomery algorithm, restore the multiple intermediate ciphertext results to the ordinary field to obtain multiple plaintext blocks; adjust the position of the multiple plaintext blocks and merge them into plaintext.
[0040] Furthermore, step (1) involves splitting the ciphertext into multiple ciphertext blocks according to the register bit width, which is achieved according to the formula: k=N / M;
[0041] In the formula, k is the number of ciphertext blocks; N is the key width of the ciphertext; and M is the register width.
[0042] Furthermore, in step (1), based on the Montgomery algorithm, each ciphertext block is converted into a Montgomery field, which is calculated according to the formula: = ( (×R) mod n, to achieve;
[0043] In the formula, , These represent the ciphertext before and after the Montgomery field transformation, i = 1, 2, 3, ..., k; mod represents ( After dividing (×R) by the modulus n, take the remainder of the result; R is the Montgomery parameter, and R=2. N N is the key width of the ciphertext.
[0044] Furthermore, in step (3), based on the Montgomery algorithm, multiple intermediate ciphertext results are restored to ordinary fields, according to the formula: =( ×R_inv) mod n, to achieve;
[0045] In the formula, This represents the intermediate ciphertext result; The modulo operator represents the result of restoring the intermediate ciphertext to its normal field representation, where i = 1, 2, 3, ..., k; mod represents ( After dividing (×R_inv) by the modulus n, take the remainder of the result; R_inv is the modulus n inverse of the Montgomery parameter R, and R=2. N N is the key width of the ciphertext.
[0046] Accordingly, the present invention also provides a register-based parallel data encryption and decryption system, comprising:
[0047] Ciphertext Segmentation and Montgomery Field Conversion Module: Based on the register bit width, the ciphertext is split into multiple ciphertext blocks, and multiple ciphertext blocks are processed in parallel. Based on the Montgomery algorithm, each ciphertext block is converted into a Montgomery field to obtain multiple Montgomery field ciphertext blocks.
[0048] Parallel computation module: Based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, it processes multiple Montgomery field ciphertext blocks in parallel in each round according to the order of the most significant bit to the least significant bit of the private key exponent, obtaining multiple intermediate ciphertext results. The operation is as follows:
[0049] Initialization module: Initializes the multiplication identity of k modular exponentiation operations to 1, for use in the decryption of k blocks;
[0050] Modular multiplication module: If the current round's private key exponent is 1, then the modular multiplication operation is performed in parallel using the multiplication unit of the previous round's modular exponentiation operation and the current round's Montgomery field ciphertext blocks to obtain the multiplication unit of the current round's modular exponentiation operation for each block;
[0051] If the current round's private key index is 0, then the modulo square operation module is executed directly;
[0052] Modular square operation module: Utilizes the current round Montgomery domain ciphertext blocks, performs modular square operations in parallel, updates the current round Montgomery domain ciphertext block for each block, and executes the modular multiplication operation module until all binary bits of the private key exponent are processed to obtain the intermediate ciphertext result corresponding to each block;
[0053] Domain restoration module: processes multiple intermediate ciphertext results in parallel, and restores the multiple intermediate ciphertext results to ordinary fields based on the Montgomery algorithm, resulting in multiple plaintext blocks; adjusts the bit order of multiple plaintext blocks and merges them into plaintext.
[0054] Beneficial effects
[0055] This invention uses register bit width as the unit of block to achieve parallel encryption and decryption of multiple data, transforming complex operations such as Montgomery field conversion and binary fast exponentiation into a single instruction, avoiding the repetitive execution of instruction sequences for high-frequency operations, further improving execution efficiency, significantly reducing the total computation cycle, and supporting encryption and decryption requirements of arbitrary bit widths such as 1024 bits, 2048 bits, and 4096 bits. It does not require redesigning the hardware structure for different bit widths and has good flexibility, stability, and scalability. Attached Figure Description
[0056] Figure 1 This is a schematic diagram illustrating the binary encoding format and field division of the custom vrsa.load instruction for an example.
[0057] Figure 2 This is a schematic diagram illustrating the binary encoding format and field division of the custom vrsa.store directive for an example.
[0058] Figure 3 This is a schematic diagram illustrating the binary encoding format and field division of the custom vrsa.param command for an example.
[0059] Figure 4 This is a schematic diagram illustrating the binary encoding format and field division of the custom vrsa.montc instruction for an example.
[0060] Figure 5 This is a schematic diagram illustrating the binary encoding format and field division of the custom vrsa.exp command for an example.
[0061] Figure 6 This is a schematic diagram illustrating the binary encoding format and field division of the custom vrsa.merge command for an example. Detailed Implementation
[0062] The following examples are intended to illustrate the present invention, and not to further limit the invention.
[0063] The register-based parallel data encryption and decryption method provided by this invention reduces data interaction latency during the encryption and decryption process through dedicated instruction connections. The relevant instructions used are as follows:
[0064] The vrsa.load directive, such as Figure 1 This includes the target vector register address (vd), which stores plaintext m, key e, key n, and private key d; memory address 1 (vs1), used to read the data to be loaded; data type identifier (imm), where 0000 = plaintext, 0001 = key e, 0010 = key n, and 0011 = private key d; and the mask register (vm), which is fixed at 0.
[0065] The vrsa.store directive, such as Figure 2 This includes memory address 2 (vd), used to store the operation result (plaintext / ciphertext, key); register address (vs1), used to read the data to be stored; data type identifier (imm), where 0000 = plaintext, 0001 = key e, 0010 = key n, 0011 = private key d; and mask register (vm), which is fixed at 0.
[0066] The vrsa.param directive, such as Figure 3 This includes the target register address 3 (vd1), which stores the Montgomery parameter R=2. N ; Destination register address 4 (vd2) stores the Montgomery parameter R_inv; Source register address 5 (vs1) stores the key n; Mask register (vm) is fixed at 0.
[0067] The vrsa.montc command, such as Figure 4This includes destination register address 1 (vd), used to store the Montgomery field conversion result; source register address 1 (vs1), used to store plaintext or ciphertext; source register address 2 (vs2), used to store Montgomery parameters R and R_inv; operation scenario control (vm), where 1 = encryption process, 0 = decryption process; and conversion direction control (funct3), where 001 = ordinary field → Montgomery field, 000 = Montgomery field → ordinary field.
[0068] The vrsa.exp command, such as Figure 5 This includes target register address 1 (vd1), which stores the modular multiplication result; target register address 2 (vd2), which stores the modular square result; source register address 3 (vs1), which stores the plaintext or ciphertext of the Montgomery field; and operation scenario control (vm), where 1 = encryption process and 0 = decryption process.
[0069] The vrsa.merge command, such as Figure 6 It includes destination register address 2 (vd), which stores the plaintext or ciphertext after the blocks are merged; source register address 4 (vs1), which stores the block data to be merged; data type identifier (imm), which is fixed at 0; and operation scenario control (vm), where 1 = encryption process and 0 = decryption process.
[0070] This invention provides a register-based parallel data encryption and decryption method, comprising:
[0071] S1: Based on the register bit width (e.g., 64 bits), the plaintext is split into multiple plaintext blocks, and these blocks are processed in parallel. Based on the Montgomery algorithm, each plaintext block is converted into a Montgomery field, resulting in multiple Montgomery field plaintext blocks.
[0072] The specific steps are as follows:
[0073] S11: Load N plaintext m, public key e, and n using the vrsa.load command.
[0074] S12: According to the formula: k=N / 64, the plaintext is split into k plaintext blocks with a word length of 64 bits, where k is the number of plaintext blocks; N is the key width of the plaintext, which can be 1024 bits, 2048 bits, or 4096 bits.
[0075] S13: Pre-calculate Montgomery parameters using the vrsa.param command: R=2 N , R_inv, and store.
[0076] S14: Based on the Montgomery algorithm, according to the formula: = ( ×R) mod n, convert each plaintext block into a Montgomery field, resulting in k Montgomery field plaintext blocks.
[0077] In the formula, , These represent the plaintext before and after the Montgomery field transformation, respectively; i = 1, 2, 3, ..., k; mod represents ( After dividing (×R) by the modulus n, take the remainder of the result; R is the Montgomery parameter, and R=2. N .
[0078] This invention splits 64-bit words to be compatible with bit widths of 1024, 2048, and 4096 without requiring hardware modifications, offering excellent flexibility. The resulting blocks are converted synchronously, improving processing speed, and can be directly invoked through corresponding instructions, reducing redundant operations.
[0079] S2: Using the vrsa.exp command and based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, multiple Montgomery field plaintext blocks are processed in parallel in each round according to the order of the most significant bit to the least significant bit of the public key exponent, resulting in multiple intermediate plaintext results. The operation is as follows:
[0080] S21: Initialize the multiplication identity of k modular exponentiation operations to 1 for use in k block encryption.
[0081] S22: If the public key exponent bit of the current round is 1, then use the multiplication unit of the previous round's modular exponentiation operation and the plaintext block of the current round's Montgomery field to perform modular multiplication operations in parallel, and obtain the multiplication unit of the current round's modular exponentiation operation for each block;
[0082] If the current round's public key index is 0, then execute S23 directly;
[0083] S23: Using the plaintext blocks of the current round's Montgomery domain, perform modular square operations in parallel, update the plaintext blocks of the current round's Montgomery domain for each block, and execute S22 until all binary bits of the public key exponent have been processed, obtaining the intermediate plaintext result res corresponding to each block. i .
[0084] This invention uses the vrsa.exp instruction to enable multiple blocks to perform modular multiplication and modular squaring operations synchronously, thereby improving the operation speed. Compared with large integer modular exponentiation, the binary fast exponentiation algorithm reduces the complexity of exponentiation operations and reduces the number of operation rounds.
[0085] S3: Process multiple intermediate plaintext results in parallel, and based on the Montgomery algorithm, restore the multiple intermediate plaintext results to ordinary fields to obtain multiple ciphertext blocks; adjust the bit order of the multiple ciphertext blocks and merge them into ciphertext.
[0086] The specific steps are as follows:
[0087] S31: According to the formula: =(res i The function (×R_inv) mod n restores multiple intermediate plaintext results to ordinary fields, resulting in multiple ciphertext blocks.
[0088] In the formula, res i Represents the intermediate plaintext result; The modulo operator represents the plaintext result as a normal field representation, where i = 1, 2, 3, ..., k; mod represents (res) i After dividing (×R_inv) by the modulus n, take the remainder of the result; R_inv is the modulus n inverse of the Montgomery parameter R, and R=2. N .
[0089] S32: Using the vrsa.merge instruction, adjust the bit order of k ciphertext blocks according to the rule of "storing low-order data in low-address blocks and storing high-order data in high-address blocks" to ensure that there is no bit overlap between blocks before splicing them into a complete ciphertext c.
[0090] S33: Store the ciphertext c using the vrsa.store command.
[0091] This invention uses the vrsa.montc instruction to synchronously perform Montgomery field restoration on k intermediate results, adapting to the number of blocks and improving conversion efficiency; it uses the vrsa.merge instruction to determine the bit order adjustment logic, ensuring that the blocks do not overlap and guaranteeing the integrity of the results.
[0092] In one specific embodiment, the plaintext m is a 1024-bit integer, the modulus n = 1024 bits, the public key exponent e = 65537, and the Montgomery parameter R = 2. 1024 The encryption process is as follows:
[0093] First, divide the 1024-bit plaintext m into 64-bit blocks, resulting in k=16 blocks: m1 (lower 64 bits), m2 (second lowest 64 bits), ..., m 16 (High 64 bits).
[0094] Then, using the Montgomery algorithm, the k plaintext blocks m_i in the ordinary field are converted into the corresponding Montgomery fields. (i=1,2,3,...,16), resulting in 16 Montgomery domain blocks. - .
[0095] Next, initialize the result variables for each of the 16 blocks: res1=1, res2=1, ..., res 16=1 (the multiplication unit of modular arithmetic).
[0096] Then, based on the binary fast exponentiation algorithm, the modular multiplication and modular squaring operations are performed in parallel on the 16 blocks in each round, cyclically according to the binary bits of the public key exponent e (from the most significant bit to the least significant bit):
[0097] The binary representation of the public key exponent e=65537 is 10000000000000001, which is 17 bits, i.e., b. 16 b 15 …b0, where: b 16 =1 (most significant bit), b 15 -b1=0 (middle 15 bits), b0=1 (least significant bit). A total of 17 rounds are performed, with 16 blocks processed synchronously in each round. For example, in the first round, b... 16 Since the value of the bit is 1, all 16 blocks are first subjected to modular multiplication in parallel: res i =(res i × Then, perform the modulo-square operation in parallel: =( × ) mod n.
[0098] In the second round, process b 15 Since the value of the bit is 0, none of the 16 blocks perform modular multiplication; only modular squaring is performed in parallel.
[0099] This process is repeated 17 times, resulting in 16 blocks of intermediate plaintext results (res). i The result is then restored from the Montgomery field to a normal field, yielding 16-way ciphertext blocks c1-c. 16 The ciphertext is then combined into a 1024-bit ciphertext c, which is the encrypted result.
[0100] Perform a similar operation to continue decrypting the encrypted result:
[0101] S4: Divide the ciphertext into multiple ciphertext blocks according to the 64-bit word length, process the multiple ciphertext blocks in parallel, and convert each ciphertext block into a Montgomery field based on the Montgomery algorithm to obtain multiple Montgomery field ciphertext blocks.
[0102] The specific steps are as follows:
[0103] S41: Use the vrsa.load command to read N bits of ciphertext c, private key d, and n.
[0104] S42: According to the formula: k=N / 64, the ciphertext c is divided into k ciphertext blocks with a word length of 64 bits, where k is the number of ciphertext blocks and N is the key width of the ciphertext.
[0105] S43: Pre-calculate Montgomery parameters using the vrsa.param command: R=2 N , R_inv, and store.
[0106] S44: Based on Montgomery's algorithm, according to the formula: = ( ×R) mod n, convert each ciphertext block into a Montgomery field, resulting in k Montgomery field ciphertext blocks.
[0107] In the formula, , These represent the ciphertext before and after the Montgomery field transformation, respectively; i = 1, 2, 3, ..., k.
[0108] S5: Based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, multiple Montgomery field ciphertext blocks are processed in parallel in each round according to the order of the most significant bit to the least significant bit of the private key exponent binary bits, resulting in multiple intermediate ciphertext results. The operation is as follows:
[0109] S51: Initialize the multiplication identity of k modular exponentiation operations to 1 for use in k block decryption.
[0110] S52: If the current round private key exponent is 1, then use the multiplication unit of the previous round modular exponentiation and the current round Montgomery field ciphertext blocks to perform modular multiplication in parallel, and obtain the multiplication unit of the current round modular exponentiation for each block.
[0111] If the current round's private key index is 0, then execute S53 directly;
[0112] S53: Using the current round's Montgomery domain ciphertext blocks, perform modulo-square operations in parallel, update the current round's Montgomery domain ciphertext block for each block, and execute S52 until all binary bits of the private key exponent have been processed, obtaining the intermediate ciphertext result corresponding to each block. .
[0113] S6: Process multiple intermediate ciphertext results in parallel, and based on the Montgomery algorithm, restore the multiple intermediate ciphertext results to ordinary fields to obtain multiple plaintext blocks; adjust the bit order of the multiple plaintext blocks and merge them into plaintext.
[0114] The specific steps are as follows:
[0115] S61: According to the formula: =( The function (×R_inv) mod n restores multiple intermediate ciphertext results to ordinary fields, resulting in multiple plaintext blocks.
[0116] In the formula, This represents the intermediate ciphertext result; R_inv represents the intermediate ciphertext result as a normal field representation, where i = 1, 2, 3, ..., k; R_inv is the modulus n inverse of the Montgomery parameter R, and R = 2. N .
[0117] S62: Using the vrsa.merge instruction, adjust the bit order of k plaintext blocks according to the rule of "storing low-order data in low-address blocks and storing high-order data in high-address blocks" to ensure that there is no bit overlap between blocks before splicing them into a complete plaintext m.
[0118] S63: Store the plaintext m using the vrsa.store command.
[0119] This invention uses register bit width as the unit of block to achieve parallel encryption and decryption of multiple data, transforming complex operations such as Montgomery field conversion and binary fast exponentiation into a single instruction, avoiding the repetitive execution of instruction sequences for high-frequency operations, further improving execution efficiency, significantly reducing the total computation cycle, and supporting encryption and decryption requirements of arbitrary bit widths such as 1024 bits, 2048 bits, and 4096 bits. It does not require redesigning the hardware structure for different bit widths and has good flexibility and scalability.
[0120] This invention also provides a register-based parallel data encryption and decryption system, comprising:
[0121] In the encryption system, the plaintext block and Montgomery field conversion module: Based on the register bit width, the plaintext is split into multiple plaintext blocks, and then multiple plaintext blocks are processed in parallel. Based on the Montgomery algorithm, each plaintext block is converted into a Montgomery field, resulting in multiple Montgomery field plaintext blocks.
[0122] Parallel computation module: Based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, it processes multiple Montgomery field plaintext blocks in parallel in each round according to the order of the most significant bit to the least significant bit of the public key exponent, obtaining multiple intermediate plaintext results. The operation is as follows:
[0123] Initialization module: Initializes the multiplication identity of k modular exponentiation operations to 1, for use in k block encryption;
[0124] Modular multiplication module: If the public key exponent bit of the current round is 1, then the modular multiplication operation is performed in parallel using the multiplication unit of the previous round's modular exponentiation operation and the plaintext block of the Montgomery field of the current round, to obtain the multiplication unit of the current round's modular exponentiation operation for each block;
[0125] If the current round's public key index is 0, then the modulo square operation module is executed directly;
[0126] Modular square operation module: Utilize the plaintext blocks of the current round Montgomery domain, perform modular square operations in parallel, update the plaintext blocks of the current round Montgomery domain for each block, and execute the modular multiplication operation module until all binary bits of the public key exponent are processed to obtain the intermediate plaintext result corresponding to each block;
[0127] Domain restoration module: processes multiple intermediate plaintext results in parallel, and restores the multiple intermediate plaintext results to ordinary fields based on the Montgomery algorithm, resulting in multiple ciphertext blocks; adjusts the bit order of multiple ciphertext blocks and merges them into ciphertext.
[0128] In addition, in the decryption system, the ciphertext block and Montgomery field conversion module: according to the register bit width, the ciphertext is split into multiple ciphertext blocks, and multiple ciphertext blocks are processed in parallel. Based on the Montgomery algorithm, each ciphertext block is converted into a Montgomery field to obtain multiple Montgomery field ciphertext blocks.
[0129] Parallel computation module: Based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, it processes multiple Montgomery field ciphertext blocks in parallel in each round according to the order of the most significant bit to the least significant bit of the private key exponent, obtaining multiple intermediate ciphertext results. The operation is as follows:
[0130] Initialization module: Initializes the multiplication identity of k modular exponentiation operations to 1, for use in the decryption of k blocks;
[0131] Modular multiplication module: If the current round's private key exponent is 1, then the modular multiplication operation is performed in parallel using the multiplication unit of the previous round's modular exponentiation operation and the current round's Montgomery field ciphertext blocks to obtain the multiplication unit of the current round's modular exponentiation operation for each block;
[0132] If the current round's private key index is 0, then the modulo square operation module is executed directly;
[0133] Modular square operation module: Utilizes the current round Montgomery domain ciphertext blocks, performs modular square operations in parallel, updates the current round Montgomery domain ciphertext block for each block, and executes the modular multiplication operation module until all binary bits of the private key exponent are processed to obtain the intermediate ciphertext result corresponding to each block;
[0134] Domain restoration module: processes multiple intermediate ciphertext results in parallel, and restores the multiple intermediate ciphertext results to ordinary fields based on the Montgomery algorithm, resulting in multiple plaintext blocks; adjusts the bit order of multiple plaintext blocks and merges them into plaintext.
Claims
1. A register-based parallel data encryption and decryption method, characterized in that, include: S1: Based on the register bit width, the plaintext is split into multiple plaintext blocks, and then the multiple plaintext blocks are processed in parallel. Based on the Montgomery algorithm, each plaintext block is converted into a Montgomery field to obtain multiple Montgomery field plaintext blocks. S2: Using the vrsa.exp command, based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, multiple Montgomery field plaintext blocks are processed in parallel in each round according to the order of the most significant bit to the least significant bit of the public key exponent, resulting in multiple intermediate plaintext results. The operation is as follows: S21: Initialize the multiplication identity of k modular exponentiation operations to 1 for use in k block encryption; S22: If the public key exponent bit of the current round is 1, then use the multiplication unit of the previous round's modular exponentiation operation and the plaintext block of the current round's Montgomery field to perform modular multiplication operations in parallel, and obtain the multiplication unit of the current round's modular exponentiation operation for each block; If the current round's public key index is 0, then execute S23 directly; S23: Utilize the plaintext blocks of the current round Montgomery domain, perform the modulo square operation in parallel, update the plaintext blocks of the current round Montgomery domain for each block, and execute S22 until all binary bits of the public key exponent are processed to obtain the intermediate plaintext result corresponding to each block; The vrsa.exp instruction includes: target register address 1, storing the modular multiplication result; target register address 2, storing the modular square result; source register address 3, storing the plaintext or ciphertext of the Montgomery field; and operation scenario control, where 1 = encryption process and 0 = decryption process. S3: Using the vrsa.montc command, multiple intermediate plaintext results are processed in parallel, and based on the Montgomery algorithm, the multiple intermediate plaintext results are restored to ordinary fields to obtain multiple ciphertext blocks; Adjust the bit order of multiple ciphertext blocks and merge them into a single ciphertext; The vrsa.montc instruction includes: destination register address 1 for storing the Montgomery field conversion result; source register address 1 for storing plaintext or ciphertext; source register address 2 for storing Montgomery parameters R and R_inv; operation scenario control, where 1 = encryption process, 0 = decryption process; and conversion direction control, where 001 = normal field → Montgomery field, 000 = Montgomery field → normal field.
2. The register-based parallel data encryption and decryption method according to claim 1, characterized in that, S1 describes splitting plaintext into multiple plaintext blocks based on the register bit width, which is achieved using the formula: k=N / M; In the formula, k is the number of plaintext blocks; N is the key width of the plaintext; M is the register bit width.
3. The register-based parallel data encryption and decryption method according to claim 1, characterized in that, S1 describes the conversion of each plaintext block into a Montgomery field based on the Montgomery algorithm, according to the formula: =( (×R) mod n, to achieve; In the formula, , These represent the plaintext before and after the Montgomery field transformation, respectively; i = 1, 2, 3, ..., k; mod represents ( After dividing (×R) by the modulus n, take the remainder of the result; R is the Montgomery parameter, and R=2. N N is the key width of the plaintext.
4. The register-based parallel data encryption and decryption method according to claim 1, characterized in that, S3 describes the process of restoring multiple intermediate plaintext results to the ordinary field based on the Montgomery algorithm, according to the formula: =(res i ×R_inv) mod n, implemented; In the formula, res i Represents the intermediate plaintext result; The modulo operator represents the plaintext result as a normal field representation, where i = 1, 2, 3, ..., k; mod represents (res) i After dividing (×R_inv) by the modulus n, take the remainder of the result; R_inv is the modulus n inverse of the Montgomery parameter R, and R=2. N N is the key width of the plaintext.
5. A register-based parallel data encryption and decryption system, characterized in that, include: Plaintext Segmentation and Montgomery Field Conversion Module: Based on the register bit width, the plaintext is split into multiple plaintext blocks, and multiple plaintext blocks are processed in parallel. Based on the Montgomery algorithm, each plaintext block is converted into a Montgomery field, resulting in multiple Montgomery field plaintext blocks. Parallel processing module: Using the vrsa.exp command, based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, it processes multiple Montgomery field plaintext blocks in parallel in each round according to the order of the most significant bit to the least significant bit of the public key exponent, obtaining multiple intermediate plaintext results. The operation is as follows: Initialization module: Initializes the multiplication identity of k modular exponentiation operations to 1, for use in k block encryption; Modular multiplication module: If the public key exponent bit of the current round is 1, then the modular multiplication operation is performed in parallel using the multiplication unit of the previous round's modular exponentiation operation and the plaintext block of the Montgomery field of the current round, to obtain the multiplication unit of the current round's modular exponentiation operation for each block; If the current round's public key index is 0, then the modulo square operation module is executed directly; Modular square operation module: Utilize the plaintext blocks of the current round Montgomery domain, perform modular square operations in parallel, update the plaintext blocks of the current round Montgomery domain for each block, and execute the modular multiplication operation module until all binary bits of the public key exponent are processed to obtain the intermediate plaintext result corresponding to each block; The vrsa.exp instruction includes: target register address 1, storing the modular multiplication result; target register address 2, storing the modular square result; source register address 3, storing the plaintext or ciphertext of the Montgomery field; and operation scenario control, where 1 = encryption process and 0 = decryption process. Domain restoration module: Using the vrsa.montc command, it processes multiple intermediate plaintext results in parallel and restores them to ordinary fields based on the Montgomery algorithm, resulting in multiple ciphertext blocks; Adjust the bit order of multiple ciphertext blocks and merge them into a single ciphertext; The vrsa.montc instruction includes: destination register address 1 for storing the Montgomery field conversion result; source register address 1 for storing plaintext or ciphertext; source register address 2 for storing Montgomery parameters R and R_inv; operation scenario control, where 1 = encryption process, 0 = decryption process; and conversion direction control, where 001 = normal field → Montgomery field, 000 = Montgomery field → normal field.
6. A register-based parallel data encryption and decryption method, characterized in that, include: (1) Based on the register bit width, the ciphertext is split into multiple ciphertext blocks, and the multiple ciphertext blocks are processed in parallel. Based on the Montgomery algorithm, each ciphertext block is converted into a Montgomery field to obtain multiple Montgomery field ciphertext blocks. (2) Using the vrsa.exp command, based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, multiple Montgomery domain ciphertext blocks are processed in parallel in each round according to the order of the most significant bit to the least significant bit of the private key exponent binary bits, to obtain multiple intermediate ciphertext results. The operation is as follows: (21) Initialize the multiplication identity of the k modular exponentiation operations to 1 for use in the k block decryption; (22) If the current round private key exponent is 1, then use the multiplication unit of the previous round modular exponentiation and the current round Montgomery field ciphertext blocks to perform modular multiplication in parallel, and obtain the multiplication unit of the current round modular exponentiation for each block. If the current round private key index is 0, then proceed directly to step (23). (23) Using the current round Montgomery domain ciphertext blocks, perform the modulo square operation in parallel, update the current round Montgomery domain ciphertext blocks of each block, and execute step (22) until all binary bits of the private key index are processed to obtain the intermediate ciphertext result corresponding to each block; The vrsa.exp instruction includes: target register address 1, storing the modular multiplication result; target register address 2, storing the modular square result; source register address 3, storing the plaintext or ciphertext of the Montgomery field; and operation scenario control, where 1 = encryption process and 0 = decryption process. (3) Multiple intermediate ciphertext results are processed in parallel using the vrsa.montc command, and the multiple intermediate ciphertext results are restored to ordinary fields based on the Montgomery algorithm to obtain multiple plaintext blocks; Adjust the bit order of multiple plaintext blocks and merge them into plaintext; The vrsa.montc instruction includes: destination register address 1 for storing the Montgomery field conversion result; source register address 1 for storing plaintext or ciphertext; source register address 2 for storing Montgomery parameters R and R_inv; operation scenario control, where 1 = encryption process, 0 = decryption process; and conversion direction control, where 001 = normal field → Montgomery field, 000 = Montgomery field → normal field.
7. The register-based parallel data encryption and decryption method according to claim 6, characterized in that, Step (1) involves splitting the ciphertext into multiple ciphertext blocks based on the register bit width, which is achieved according to the formula: k=N / M; In the formula, k is the number of ciphertext blocks; N is the key width of the ciphertext; and M is the register width.
8. The register-based parallel data encryption and decryption method according to claim 6, characterized in that, Step (1) involves converting each ciphertext block into a Montgomery field based on the Montgomery algorithm, according to the formula: =( (×R) mod n, to achieve; In the formula, , These represent the ciphertext before and after the Montgomery field transformation, i = 1, 2, 3, ..., k; mod represents ( After dividing (×R) by the modulus n, take the remainder of the result; R is the Montgomery parameter, and R=2. N N is the key width of the ciphertext.
9. The register-based parallel data encryption and decryption method according to claim 6, characterized in that, Step (3) involves restoring multiple intermediate ciphertext results to ordinary fields based on the Montgomery algorithm, according to the formula: =( ×R_inv) mod n, to achieve; In the formula, This represents the intermediate ciphertext result; The modulo operator represents the result of restoring the intermediate ciphertext to its normal field representation, where i = 1, 2, 3, ..., k; mod represents ( After dividing (×R_inv) by the modulus n, take the remainder of the result; R_inv is the modulus n inverse of the Montgomery parameter R, and R=2. N N is the key width of the ciphertext.
10. A register-based parallel data encryption and decryption system, characterized in that, include: Ciphertext Segmentation and Montgomery Field Conversion Module: Based on the register bit width, the ciphertext is split into multiple ciphertext blocks, and multiple ciphertext blocks are processed in parallel. Based on the Montgomery algorithm, each ciphertext block is converted into a Montgomery field to obtain multiple Montgomery field ciphertext blocks. Parallel computation module: Using the vrsa.exp command, based on the binary fast exponentiation algorithm, after initializing the multiplication identity of the modular exponentiation operation to 1, it processes multiple Montgomery field ciphertext blocks in parallel in each round according to the order of the most significant bit to the least significant bit of the private key exponent, obtaining multiple intermediate ciphertext results. The operation is as follows: Initialization module: Initializes the multiplication identity of k modular exponentiation operations to 1, for use in the decryption of k blocks; Modular multiplication module: If the current round's private key exponent is 1, then the modular multiplication operation is performed in parallel using the multiplication unit of the previous round's modular exponentiation operation and the current round's Montgomery field ciphertext blocks to obtain the multiplication unit of the current round's modular exponentiation operation for each block; If the current round's private key index is 0, then the modulo square operation module is executed directly; Modular square operation module: Utilizes the current round Montgomery domain ciphertext blocks, performs modular square operations in parallel, updates the current round Montgomery domain ciphertext block for each block, and executes the modular multiplication operation module until all binary bits of the private key exponent are processed to obtain the intermediate ciphertext result corresponding to each block; The vrsa.exp instruction includes: target register address 1, storing the modular multiplication result; target register address 2, storing the modular square result; source register address 3, storing the plaintext or ciphertext of the Montgomery field; and operation scenario control, where 1 = encryption process and 0 = decryption process. Domain restoration module: Using the vrsa.montc command, it processes multiple intermediate ciphertext results in parallel and restores them to ordinary fields based on the Montgomery algorithm, thus obtaining multiple plaintext blocks; Adjust the bit order of multiple plaintext blocks and merge them into plaintext; The vrsa.montc instruction includes: destination register address 1 for storing the Montgomery field conversion result; source register address 1 for storing plaintext or ciphertext; source register address 2 for storing Montgomery parameters R and R_inv; operation scenario control, where 1 = encryption process, 0 = decryption process; and conversion direction control, where 001 = normal field → Montgomery field, 000 = Montgomery field → normal field.
Citation Information
Patent Citations
Data encryption and decryption processing method and device based on Montgomery modular multiplication operation
CN102207847A
An encryption and decryption hardware system and method based on RSA cryptographic algorithm
CN109039640A