Data encryption round key expansion device
By designing interleaved key word processing circuits and mutually exclusive OR gates in the AES encryptor, we solve the problem of erroneous operations in the AES encryptor under malicious attacks or environmental defects, achieve more efficient error detection and management, and reduce costs. Data loss.
Patent Information
- Application Number
- CN202310268864.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-20
- Publication Date
- 2024-09-20
AI Technical Summary
Existing AES encryptors are prone to erroneous operation results due to malicious attacks, chip defects, or harsh environments, resulting in unrecoverable user data and huge losses.
A round key expansion device for data encryption is designed, which includes a register, a key word processing circuit and a mutually exclusive OR gate. It calculates the corresponding intermediate operation results in different modes through interleaved operation, and performs bit-by-bit logical mutually exclusive OR operations. to reduce the occurrence of errors.
It effectively reduces the area of the data encryption round key expansion device, improves the efficiency of error detection and management, and reduces data loss caused by erroneous operations.
Smart Images

Figure CN118677599A
Abstract
Description
Technical Field
[0001] The present invention relates to data encryption, and in particular to a round key expansion device for data encryption. Background Art
[0002] Since current storage devices (e.g., NAND flash memory) are often used to store system program code, application code, drivers, and user privacy data, data security is a major issue. The Advanced Encryption Standard (AES) is a block encryption standard currently adopted by the U.S. federal government and has been verified and widely adopted by multiple parties. However, AES may be subject to malicious attacks during operation, causing the AES encoder to produce incorrect calculation results. Alternatively, there may be some defects in the chip manufacturing process, causing the AES encoder to produce unexpected calculation results after running for a period of time. Alternatively, the storage device may be in a harsh environment, causing some components in the AES encoder to fail and produce unexpected calculation results. An incorrect encryption process will make the original user data unrecoverable, resulting in huge losses. Summary of the Invention
[0003] In view of this, how to alleviate or eliminate the deficiencies in the above-mentioned related fields is indeed a problem to be solved.
[0004] The present invention relates to a round key expansion device for data encryption, comprising: a register; a key processing circuit; and first to fourth exclusive OR gates. The register includes components for storing eight double words, wherein the outputs of the components of the fourth to seventh double words are coupled to the inputs of the components of the zeroth to third double words, respectively. The key processing circuit is coupled to the output of the component of the last double word of the register and is configured to operate in a first mode and a second mode in an alternating manner. In the first mode, a first intermediate operation result corresponding to an even-numbered round key is calculated based on the last double word; and in the second mode, a second intermediate operation result corresponding to an odd-numbered round key is calculated based on the last double word. The first exclusive OR gate is configured to perform a bit-by-bit logical exclusive OR operation on the zeroth double word and the output of the key processing circuit, and output the first operation result to the component of the register for storing the fourth double word. The second exclusive OR gate is configured to perform a bit-by-bit logical exclusive OR operation on the first double word and the output of the first exclusive OR gate, and output the second operation result to the component of the register for storing the fifth double word. A third exclusive OR gate is configured to perform a bit-by-bit logical exclusive OR operation on the second doubleword and the output of the second exclusive OR gate, and output the third operation result to the component of the register for storing the sixth doubleword. A fourth exclusive OR gate is configured to perform a bit-by-bit logical exclusive OR operation on the third doubleword and the output of the third exclusive OR gate, and output the fourth operation result to the component of the register for storing the seventh doubleword.
[0005] One of the advantages of the above embodiment is that, by configuring the key processing circuit, the area of the round key expansion device for data encryption can be reduced compared to the previous embodiment.
[0006] Other advantages of the present invention will be explained in more detail with reference to the following description and accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0007] The drawings described herein are used to provide further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application.
[0008] Figure 1 FIG. 4 is a system architecture diagram of an electronic device according to an embodiment of the present invention.
[0009] Figure 2 FIG. 1 is a schematic diagram of a flash memory module according to an embodiment of the present invention.
[0010] Figure 3 A high-level diagram of the algorithm using 10 rounds with a 128-bit key.
[0011] Figure 4 A block diagram of an Advanced Encryption Standard (AES) encoder according to some embodiments.
[0012] Figure 5 FIG. 4 is a block diagram of an AES encoder according to an embodiment of the present invention.
[0013] Figure 6 Schematic diagram of a body, intra-body parity check bits, and 9-bit cross-body parity check according to an embodiment of the present invention.
[0014] Figure 7 Schematic diagram of a small key, parity bits within a small key, and 9 bits of parity across small keys according to an embodiment of the present invention.
[0015] Figure 8 FIG. 4 is a block diagram of an AES encoder according to an embodiment of the present invention.
[0016] Figure 9 FIG. 4 is a block diagram of an AES data processing circuit according to an embodiment of the present invention.
[0017] Figure 10 FIG. 4 is a block diagram of a parity prediction circuit according to an embodiment of the present invention.
[0018] Figure 11 FIG. 4 is a block diagram of an intra-body parity bit prediction circuit according to an embodiment of the present invention.
[0019] Figure 12 FIG. 4 is a block diagram of an intra-body parity bit generation circuit according to an embodiment of the present invention.
[0020] Figure 13 FIG. 4 is a block diagram of a 9-bit prediction circuit for cross-body parity check according to an embodiment of the present invention.
[0021] Figure 14 FIG. 4 is a block diagram of an enhanced byte replacement circuit according to an embodiment of the present invention.
[0022] Figure 15 FIG. 4 is a block diagram of an enhanced look-up table circuit according to an embodiment of the present invention.
[0023] Figure 16 FIG. 4 is a block diagram of an alternative verification circuit according to an embodiment of the present invention.
[0024] Figure 17 4 is a block diagram of an AES key scheduling circuit according to an embodiment of the present invention.
[0025] Figure 18 FIG. 4 is a block diagram of a key processing circuit according to an embodiment of the present invention.
[0026] Figure 19 FIG. 4 is a block diagram of a replacement key circuit according to an embodiment of the present invention.
[0027] Figure 20 FIG. 4 is a schematic diagram of a circuit for truncating constants according to an embodiment of the present invention.
[0028] Figure 21 FIG. 4 is a block diagram of a key processing circuit according to an embodiment of the present invention.
[0029] Figure 22 FIG. 4 is a block diagram of an enhanced look-up table circuit according to an embodiment of the present invention.
[0030] Figure 23 and Figure 24 FIG. 1 is a schematic diagram of an 8-bit to 14-bit lookup table according to an embodiment of the present invention.
[0031] Figure 25 4 is a block diagram of an AES key scheduling circuit according to an embodiment of the present invention.
[0032] Figure 26 FIG. 4 is a block diagram of a dual-mode key processing circuit according to an embodiment of the present invention.
[0033] Description of reference numerals:
[0034] 10 Electronic devices
[0035] 110 Host side
[0036] 130 Flash Memory Controller
[0037] 131 Host Interface
[0038] 132 bus
[0039] 134 processing units
[0040] 136 Random Access Memory
[0041] 137 Advanced Encryption Standard Encoder
[0042] 138 Direct Memory Access Controller
[0043] 139 Flash memory interface
[0044] 150 Flash Memory Module
[0045] 151 Interface
[0046] 153#0~153#15 NAND flash memory unit
[0047] CH#0~CH#3 channels
[0048] CE#0~CE#3 start signal
[0049] R#0 Initial Round
[0050] R#1~R#9 middle round
[0051] R#10 Final Round
[0052] S310#1~S310#10 byte replacement steps
[0053] S320#1~S320#10 shift steps
[0054] S330#1~S330#9 mixed column steps
[0055] S340#1~S340#10 plus round key steps
[0056] S350 Extended Key Steps
[0057] w[0,3] base key
[0058] w[4,7], w[36,39], w[40,43] expanded keys
[0059] 400AES encoder
[0060] 410, 430AES encoding circuit
[0061] 450 Comparator
[0062] 500 AES encoder
[0063] 510 AES encoding circuit
[0064] 530 Error Detection Circuit
[0065] 550 Redundant data generation circuit
[0066] 570 Redundant Key Generation Circuit
[0067] S0~S 15 body
[0068] P0~P 15 Internal parity bits
[0069] Q0~Q3 span parity check 9 bits
[0070] k0~k 31 small key
[0071] R0~R 31 Parity bits in the small key
[0072] V0~V7 span small key parity check 9 bits
[0073] 810 AES data processing circuit
[0074] 813 encoding circuit
[0075] 815 Encoding Error Checking Circuit
[0076] 830 AES key scheduling circuit
[0077] 833 key generation circuit
[0078] 835 Key Error Check Circuit
[0079] 850 OR Gate
[0080] 870 Controller
[0081] 912 Data Register
[0082] 914 Parity check code register
[0083] 920 Enhanced Byte Replacement Circuit
[0084] 930 Shift Line Circuit
[0085] 940 Hybrid Column Circuit
[0086] 950 plus round key circuit
[0087] 960 Parity Check Circuit
[0088] 970 Parity Prediction Circuit
[0089] 980 Multiplexer
[0090] Parity bit prediction circuit in 1010 body
[0091] 1030 cross-body parity check 9-bit prediction circuit
[0092] 1110 internal parity bit generation circuit
[0093] 1120 Shift row prediction circuit
[0094] 1130 Hybrid Column Prediction Circuit
[0095] 1140 Multiplexer
[0096] 1150 plus round key prediction circuit
[0097] 1160 Shift Line Circuit
[0098] 1210 Multiplexer
[0099] 1230 Mutually exclusive OR gate in the body
[0100] 1310 cross-body parity byte generation circuit
[0101] 1330 Cross-key parity byte splitting circuit
[0102] 1350 cross-body parity byte prediction circuit
[0103] 1370 cross-body parity check 1-bit prediction circuit
[0104] 1390 cross-body parity check 9-bit merging circuit
[0105] 1410 cross-body parity byte splitting circuit
[0106] 1430#0~1430#15 Enhanced lookup table circuit
[0107] 1450 cross-body parity byte merging circuit
[0108] 1510, 2210 search circuit
[0109] 1530, 2230 alternative verification circuit
[0110] 1610 Computing Circuit
[0111] 1630 Multiplier
[0112] 1650 Comparator
[0113] 1710, 1750 key splitting circuit
[0114] 1712, 1714 registers
[0115] 1720, 1730 key word processing circuit
[0116] 1725, 1727, 1729 Mutually Exclusive OR Gates
[0117] 1742, 1744 key parity code generation circuit
[0118] Registers 1752, 1754, 1782, and 1784
[0119] 1762, 1764 Key Parity Check Circuit
[0120] 1772, 1774 Key Parity Prediction Circuit
[0121] 1810 Key word division circuit
[0122] 1820 Rotating Key Circuit
[0123] 1830 Replacement Key Circuit
[0124] 1840 Constant-Discarding Circuit
[0125] 1850 Keyword Merging Circuit
[0126] 1860 Key word parity generation circuit
[0127] 1870 Key word parity prediction circuit
[0128] 1880 key word cross parity check prediction circuit
[0129] 1890 key word parity check 9-bit merging circuit
[0130] 1930#0~1930#3 Enhanced lookup table circuit
[0131] 2010 Mutually Exclusive OR Gate
[0132] 2110 Key word division circuit
[0133] 2130 Substitute Keyword Circuit
[0134] 2150 Keyword Merging Circuit
[0135] 2160 Key word parity generation circuit
[0136] 2180 key word cross parity check prediction circuit
[0137] 2190 key word parity check 9-bit merging circuit
[0138] 2300, 2400 8 to 14-bit lookup table
[0139] 2500 AES key scheduling circuit
[0140] 2520 key word processing circuit
[0141] 2521, 2523, 2525, 2527 mutually exclusive OR gates
[0142] 2610 Key word division circuit
[0143] 2620 Rotating Key Circuit
[0144] 2630, 2680 multiplexers
[0145] 2640 Substitute Key Circuit
[0146] 2650 Demultiplexer
[0147] 2662, 2664 Parity Compensation Circuit
[0148] 2670 Constant Discarding Circuit
[0149] 2690 Keyword Merging Circuit DETAILED DESCRIPTION
[0150] The embodiments of the present invention will be described below with reference to the accompanying drawings. In these drawings, the same reference numerals represent the same or similar components or method flows.
[0151] It must be understood that the words "comprise", "include" and the like used in this specification are used to indicate the existence of specific technical features, values, method steps, work processes, elements and / or components, but do not exclude the addition of more technical features, values, method steps, work processes, elements, components, or any combination thereof.
[0152] The terms "first", "second", "third", etc. used in the present invention are used to modify the components in the claims and are not used to indicate a priority order or a precedence relationship between them, or that one component precedes another, or the temporal order of executing method steps. They are only used to distinguish components with the same name.
[0153] It should be understood that when a component is described as being "connected" or "coupled" to another component, it can be directly connected or coupled to the other component, and intervening components may be present. Conversely, when a component is described as being "directly connected" or "directly coupled" to another component, there are no intervening components. Other words used to describe the relationship between components should be interpreted in a similar manner, for example, "between" versus "directly between," or "adjacent" versus "directly adjacent," etc.
[0154] reference Figure 1. The electronic device 10 includes: a host side (Host Side) 110, a flash memory controller 130 and a flash memory module 150, and the flash memory controller 130 and the flash memory module 150 can be collectively referred to as the device side (Device Side). The electronic device 10 can be implemented in electronic products such as personal computers, laptop computers (Laptop PCs), tablet computers, mobile phones, digital cameras, digital video cameras, smart TVs, smart refrigerators, and automotive electronic systems. The host side 110 and the host interface (Host Interface) 131 of the flash memory controller 130 can communicate with each other using communication protocols such as Universal Serial Bus (USB), Advanced Technology Attachment (ATA), Serial Advanced Technology Attachment (SATA), Peripheral Component Interconnect Express (PCI-E), Universal Flash Storage (UFS), and Embedded Multi-Media Card (eMMC). The flash memory interface (Flash Interface) 139 of the flash memory controller 130 and the flash memory module 150 can communicate with each other using a double data rate (DDR) communication protocol, such as an open NAND flash interface (ONFI), a double data rate switch (DDR Toggle), or other communication protocols. The flash memory controller 130 includes a processing unit 134, which can be implemented in a variety of ways, such as using general-purpose hardware (e.g., a single processor, a multi-processor with parallel processing capabilities, a graphics processor, or other processor with computing capabilities), and provides the functions described below when executing software and / or firmware instructions. The processing unit 134 receives host commands, such as read commands, write commands, discard commands, erase commands, etc., through the host interface 131, and schedules and executes these commands.The flash controller 130 also includes a random access memory (RAM) 136, which can be implemented as dynamic random access memory (DRAM), static random access memory (SRAM), or a combination of the two. This memory is used to configure space as a data buffer to store host data read from the host 110 and to be written to the flash memory module 150, as well as host data read from the flash memory module 150 and to be output to the host 110. The RAM 136 can also store data required during execution, such as variables, data tables, host-to-flash (H2F) tables, and flash-to-host (F2H) tables. The flash interface 139 includes a NAND flash controller (NFC) that provides functions required for accessing the flash memory module 150, such as a command serializer and low-density parity check (LDPC).
[0155] Flash memory controller 130 may be configured with a shared bus architecture 132 for coupling components to transmit data, addresses, and control signals. These components include a host interface 131, a processing unit 134, RAM 136, an Advanced Encryption Standard (AES) encoder 137, a direct memory access (DMA) controller 138, and a flash memory interface 139. Based on instructions from processing unit 134, DMA controller 138 can move data between components via bus architecture 132. For example, data from a specific data buffer in RAM 136 can be moved to a specific register in AES encoder 137, or data from a specific register in AES encoder 137 can be moved to a specific data buffer in RAM 136.
[0156] Flash memory module 150 provides a large amount of storage space, typically hundreds of gigabytes (GB) or even multiple terabytes (TB), for storing large amounts of user data, such as high-resolution images and videos. Flash memory module 150 includes control circuitry and a memory array. The memory cells in the memory array can be configured as single-level cells (SLCs), multiple-level cells (MLCs), triple-level cells (TLCs), quad-level cells (QLCs), or any combination thereof after erasure. Processing unit 134 writes user data to a specified address (destination address) in flash memory module 150 and reads user data from a specified address (source address) in flash memory module 150 via flash memory interface 139. Flash memory interface 139 coordinates the transfer of data and commands between flash memory controller 130 and flash memory module 150 using multiple electronic signals, including data lines, clock signals, and control signals. The data lines can be used to transmit commands, addresses, read and write data; the control signal lines can be used to transmit control signals such as chip enable (CE), address latch enable (ALE), command latch enable (CLE), and write enable (WE).
[0157] refer to Figure 2The interface 151 in the flash memory module 150 may include four input / output channels (I / O channels, hereinafter referred to as channels) CH#0 to CH#3, each of which connects to four NAND flash memory cells. For example, channel CH#0 connects to NAND flash memory cells 153#0, 153#4, 153#8, and 153#12, and so on. Each NAND flash memory cell may be packaged as an independent chip (die). The flash memory interface 139 may activate NAND flash memory cells 153#0 to 153#3, 153#4 to 153#7, 153#8 to 153#11, or 153#12 to 153#15 by sending one of the activation signals CE#0 to CE#3 via the interface 151, and then read user data from or write user data to the activated NAND flash memory cells in parallel. Those skilled in the art may change the design of the flash memory module 150 according to system requirements, configure more or fewer channels in the flash memory module 150, and / or connect more or fewer NAND flash memory cells to each channel, and the present invention is not limited thereto.
[0158] The AES encoder 137 implements a variant of Rijndael that uses a fixed 128-bit block size and a base key size of 128, 192, or 256 bits. The AES encoder 137 operates on the bytes of a 4×4 column-major order array, each byte of which is called a state. Most AES calculations are performed in a specific finite field. For example, the 16 states S0, S1 to S 15 It can be represented by the following two-dimensional array:
[0159]
[0160] The key size used in AES encryption determines the number of transformation rounds used to transform the input information (called plaintext) into the final output (called ciphertext). For example, a 128-bit key uses 10 rounds (n=10), a 192-bit key uses 12 rounds (n=12), and a 256-bit key uses 14 rounds (n=14). Each round consists of several processing steps (or operations), including one step that depends on the encryption key itself. Figure 3The following is a high-level diagram of the algorithm using 10 rounds with a 128-bit key. The algorithm uses a key expansion step S350 (also known as the AES key schedule) to expand the keys required for multiple rounds based on the 128-bit root key w[0,3]. The initial round includes an Add-Round-Key step S340#0, which adds the round key. Each cell is combined with the corresponding byte from the root key w[0,3] using a bit-by-bit XOR operation. The next nine rounds each include a Substitute-Bytes step S310#i, a Shift-Rows step S320#i, a Mix-Columns step S330#i, and an Add-Round-Key step S340#i, where i is any positive integer between 1 and 9. Step S310#i is a nonlinear substitution step that replaces the value of each cell with another value based on a lookup table (also known as a Rijndael S-box). The lookup table is constructed using the following formula:
[0161] SB i =Affine((i) -1 )
[0162] SB i Represents the output result of i, Affine() represents the Affine conversion function, and i is a positive integer from 0 to 127. Step S320#i is a position swapping step, which shifts each of the following three rows to the left or right by a specified number of steps. Step S330#i performs a linear mixing operation on the column to merge the four bodies of each column. Step S340#i is used to add the round key, and each body uses a bit-by-bit XOR operation to merge the corresponding bytes in the base key w[i*4,i*4+3]. The last round (that is, the 10th round) includes steps S310#10, S320#10, and S340#10, whose functions are similar to steps S310#i, S320#i, and S340#i, respectively. Although Figure 3 Only the algorithm using 10 rounds for a 128-bit key is described. Those skilled in the art will understand that the technical details of the algorithm using 12 rounds for a 192-bit key and 14 rounds for a 256-bit key can be obtained from the standard documents published by the National Institute of Standards and Technology (NIST).
[0163] Due to malicious attacks, chip defects, harsh environments, etc., errors may occur during the AES encryption process, causing serious damage to user data that cannot be recovered. Figure 4In some embodiments, the AES encoder 400 includes two identical AES encoding circuits 410 and 430 for implementing the algorithm described above. The AES encoder 400 also includes a comparator 450 for receiving the ciphertext C#1 of each body from the AES encoding circuit 410 and the ciphertext C#2 of each body from the AES encoding circuit 430, and comparing the two to see if they are identical. If they are identical, the comparator 450 outputs the ciphertext C#1 and a message indicating successful encryption. If they are different, the comparator 450 outputs a message indicating failed encryption, which notifies the firmware running in the processing unit that an error management routine needs to be executed. However, the area of the AES encoder 400 in the above embodiment is larger than the area of the two AES encoding circuits, resulting in increased manufacturing costs.
[0164] In order to make the area of the AES encoder smaller than the area of two sets of AES encoding circuits, from one aspect, reference Figure 5 In an embodiment of the present invention, in addition to the AES encoding circuit 510 for implementing the algorithm described above, the AES encoder 500 also includes an error detection circuit 530, which is smaller in area than a complete AES encoding circuit 510, to detect errors during the encryption process. During the encryption of each entity, the error detection circuit 530 uses less information than the 16 entities and their corresponding round keys to determine whether an error occurred during the entire encryption process. If it is determined that no errors occurred, the error detection circuit 530 may output an encryption success message. If it is determined that an error occurred, the error detection circuit 530 may output an encryption failure message, which notifies the firmware running in the processing unit that an error management routine needs to be executed.
[0165] The redundant data generating circuit 550 can add redundant data to the 16 units to allow the error detection circuit 530 to determine whether an error occurs during the encryption process. The redundant data is a prediction result based on the value of the 16 units or the intermediate encryption result and the AES encryption algorithm. Figure 6 In some embodiments, the redundant-data generation circuitry 550 can predict an in-state parity bit and append the in-state parity bit (as the 8th bit) after the body (bits 0 to 7). It should be noted that those skilled in the art should not interpret the above-mentioned appending operation as meaning that the 8-bit body and the 1-bit in-state parity bit are actually stored in a 9-bit continuous space. Different but equivalent data structures are allowed. For example, the redundant-data generation circuitry 550 can predict the in-state parity bit P0 of body S0, the in-state parity bit P1 of body S1, and so on. The matching between the body and the corresponding in-state parity bit can be expressed using the following example formula:
[0166]
[0167] P i represents the value of the intra-body parity bit of the i-th individual, S i,j Represents the value of the jth bit in the i-th individual, where i is a positive integer from 0 to 15. When both sides of the formula are equal, it means that the i-th individual and the i-th intra-parity bits are matched. Otherwise, it means that there is no match between the two. The redundant data generation circuit 550 can predict a cross-body parity 9-bit (Across-state Parity 9-bit) corresponding to the value of the body and its intra-body parity bits in each column. For example, the redundant data generation circuit 550 can predict the cross-body parity 9-bit Q0 corresponding to body S0 and its intra-body parity bit P0, body S1 and its intra-body parity bit P1, body S2 and its intra-body parity bit P2, and body S3 and its intra-body parity bit P3, and so on. The matching between multiple bodies of each column and their intra-body parity bits and corresponding cross-body parity 9 bits can be expressed using the following example formula:
[0168]
[0169]
[0170]
[0171]
[0172] Q 0,j represents the value of the jth bit of the 9-bit span parity check of the 0th span, Q 1,j represents the value of the jth bit of the first span parity check 9 bits, Q 2,j represents the value of the jth bit of the second span parity check 9 bits, Q 3,j represents the value of the jth bit of the third span parity check 9 bits, S i,j Represents the value of the jth bit in the i-th body, where j is an integer from 0 to 8. When each bit in the i-th span parity 9 bits is equal to the sum of the corresponding bits in the i-th column (or the result of an exclusive OR operation), the i-th column's body and intrabody parity bits and the i-th span parity 9 bits match. Otherwise, there is a mismatch between the two.
[0173] In one aspect, the AES encoding circuit 510 and the redundant data generation circuit 550 operate independently and in parallel, with no data or information exchanged between them. The redundant data generation circuit 550 generates predicted redundant data using a redundant data update algorithm derived from the AES encryption algorithm. This algorithm ensures that the intermediate encrypted result generated by the AES encoding circuit 510 and the redundant data predicted by the redundant data generation circuit 550 maintain a specified mathematical relationship at each specific intermediate point in the plaintext encryption process, without error.
[0174] The Redundant-key Generation Circuitry 570 adds redundant data to each base key or round key to allow the Error Detection Circuitry 530 to determine whether an error occurred during the key generation process. The redundant data is a prediction result based on the value in the base key or round key and the AES key scheduling algorithm. Figure 7 , taking the 256-bit basic key as an example, the redundant key generation circuit 570 can first divide the basic key into 32 bytes in sequence (each byte can be called a small key, Subkey), and organize it into a matrix of 8 columns and 4 rows. The redundant key generation circuit 570 can predict a small key intra-parity bit (In-subkey Parity Bit) and append the small key intra-parity bit (as the 8th bit) after the small key (bits 0 to 7). It should be noted that those skilled in the art cannot interpret the above-mentioned additional operation as the 8-bit small key and the 1-bit small key intra-parity bit actually being stored in a 9-bit continuous space. Different but equivalent data structures are allowed. For example, the redundant key generation circuit 570 can predict the small key intra-parity bit R0 of the small key K0, predict the small key intra-parity bit R1 of the small key S1, and so on. The matching between the small key and the small key intra-parity bit can be expressed using the following example formula:
[0175]
[0176] R i represents the value of the parity check bit in the small key of the i-th small key, K i,jRepresents the value of the jth bit in the i-th small key, where i is a positive integer from 0 to 15. When both sides of the formula are equal, it means that the i-th small key and the i-th small key intra-parity bit are matched. Otherwise, it means that there is no match between the two. The redundant key generation circuit 570 can predict a cross-subkey parity 9-bit (Across-subkey Parity 9-bit) corresponding to the value of the small key in each column and its intra-subkey parity bit. For example, the redundant key generation circuit 570 can predict the cross-subkey parity 9-bit V0 corresponding to the small key k0 and its intra-subkey parity bit R0, the small key k1 and its intra-subkey parity bit R1, the small key k2 and its intra-subkey parity bit R2, and the small key k3 and its intra-subkey parity bit R3, and so on. The matching between multiple small keys in each column and their intra-subkey parity bits and the corresponding cross-subkey parity 9 bits can be expressed using the following example formula:
[0177]
[0178]
[0179]
[0180]
[0181]
[0182]
[0183]
[0184]
[0185] V 0,j represents the value of the jth bit of the 9-bit parity check across the 0th small key, V 1,j represents the value of the jth bit of the first 9-bit parity check across the small key, V 2,j represents the value of the jth bit of the second cross-key parity check 9 bits, V 3,j represents the value of the jth bit of the third cross-key parity check 9 bits, V 4,j represents the value of the jth bit of the 4th cross-key parity check 9 bits, V 5,j represents the value of the jth bit of the 5th cross-key parity check 9 bits, V 6,j represents the value of the jth bit of the 9-bit parity check across the sixth small key, V 7,j represents the value of the jth bit of the 7th cross-key parity check 9 bits, k i,jRepresents the value of the jth bit in the i-th minor key, where j is an integer from 0 to 8. When each bit in the i-th inter-minor parity check equals the sum of the corresponding bits in the i-th column (or the result of an exclusive OR operation), the i-th minor key and parity bits in the i-th column match the i-th inter-minor parity check 9 bits. Otherwise, they do not match.
[0186] In one aspect, the AES encoding circuit 510 and the redundant key generation circuit 570 operate independently and in parallel, with no data or information exchanged between them. The redundant key generation circuit 570 generates predicted redundant data using a redundant key update algorithm derived from the AES key schedule in the AES encryption algorithm. This ensures that the round key generated by the AES encoding circuit 510 and the redundant data predicted by the redundant key generation circuit 570 maintain a specified mathematical relationship at each specific intermediate point in the round key generation process, provided no errors occur.
[0187] Although Figure 5 The AES encoding circuit 510, the error detection circuit 530, the redundant data generation circuit 550, and the redundant key generation circuit 570 are represented by different blocks, but this is only for the convenience of the reader. Those skilled in the art may integrate the AES encoding circuit 510, the error detection circuit 530, the redundant data generation circuit 550, and the redundant key generation circuit 570 together in an appropriate manner during actual implementation, and the present invention is not limited thereto.
[0188] On the other hand, reference Figure 8 The embodiment of the present invention proposes to set an AES data processing circuit (AES Data Processing Circuitry) 810 and an AES key scheduling circuit (AES Key Schedule Circuitry) 830 in the AES encoder 137. The AES key scheduling circuit 830 includes a key generation circuit 833 for completing the following steps: Figure 3 The controller 870 sends a control signal to the AES key scheduling circuit 830 to drive the AES key scheduling circuit 830 to perform the key expansion according to the basic key K0 or the previous round key K i Generate a new round key and output the round key K of the specified round iThe AES data processing circuit 810 receives the corresponding redundant data (e.g., the intra-small-key parity bits R and the 9-bit inter-small-key parity bits V) from the AES key scheduling circuit 830. The AES key scheduling circuit 830 includes a key error checking circuit 835 configured to calculate redundant data corresponding to each round key and, if a mismatch is detected between any round key and the corresponding redundant data at a designated intermediate point in the key expansion process, issue an error signal ERR_KEY = 1. The round key can be divided into 16 small keys and organized as a 4×4 byte array, with each small key being 1 byte. The redundant data includes the intra-small-key parity bits corresponding to each small key and the 9-bit inter-small-key parity bits corresponding to each column. The key error checking circuit 835 issues an error signal ERR_KEY = 1 if a mismatch is detected between any small key and the corresponding intra-small-key parity bits, or if the small key corresponding to any column plus the 4 corresponding intra-small-key parity bits do not match the corresponding 9-bit inter-small-key parity bits at a designated intermediate point in the key expansion process.
[0189] The AES data processing circuit 810 includes an encoding circuit 813, which is configured to implement the following Figure 3 The AES algorithm shown includes the following steps: replace bytes (S310), shift rows (S320), mix columns (S330), and add round key (S340). The AES algorithm includes multiple rounds, and in each round, the plaintext or intermediate encrypted result is encoded using the round key. The controller 870 sends a control signal to the AES data processing circuit 810, driving the AES data processing circuit 810 to arrange the execution order of the above steps to conform to the round configuration of the AES algorithm. The AES data processing circuit 810 includes an encoding error checking circuit 815, which is configured to calculate redundant data corresponding to the plaintext or intermediate encrypted result. If a mismatch between the intermediate encrypted result and the redundant data is detected at a specified intermediate point in the encryption process, an encoding error signal ERR_ENC = 1 is issued. The plaintext can be divided into 16 blocks and organized into a 4×4 array, with each block containing 1 byte. The secondary redundant data includes intra-block parity bits corresponding to each block and 9 inter-block parity bits corresponding to each column in the plaintext. When the encoding error checking circuit 815 finds at a specified time point in the encryption process that the intermediate encryption result of any of the bodies does not match the corresponding intra-body parity bits, or when it finds that the intermediate encryption result corresponding to any column in the plaintext plus the 4 corresponding intra-body parity bits do not match the corresponding cross-body parity 9 bits, it issues an encoding error signal ERR_ENC=1.
[0190] OR gate 850 is coupled to the output terminals of encoding error checking circuit 815 and key error checking circuit 835. When encoding error checking circuit 815 outputs encoding error signal ERR_ENC = 1 and / or key error checking circuit 835 outputs key error signal ERR_KEY = 1, OR gate 850 outputs AES error signal ERR_AES = 1 to processing unit 134.
[0191] refer to Figure 9 The block diagram of the AES data processing circuit 810 is shown in FIG. The data register 912 is used to store the intermediate or final result of 16 bytes (i.e., 128 bits) generated during the AES encryption process, and the parity register (Parity Registers) 914 is used to store the intra-body parity bits and the inter-body parity 9 bits corresponding to the intermediate or final result of 16 bytes generated during the AES encryption process. The shift-row circuitry 930 is used to perform the following operations: Figure 3 The structure of the row shift step S320 is well known to those skilled in the art and will not be described in detail for the sake of brevity. Figure 3 The structure of the mixing column S330 is well known to those skilled in the art and will not be described in detail for the sake of brevity. Figure 3 The step S340 of adding the round key is shown, and its structure is well known to those skilled in the art, and will not be described in detail for the sake of brevity.
[0192] The controller 870 can issue a selection signal R_sel to the multiplexer 980 and the parity prediction circuitry 970 during each round to control the data flow through the specified circuitry. The multiplexer 980 includes three input terminals I0, I1, and I2, and one output terminal O. Input terminal I0 is coupled to the input pin of the AES encoder 137 to receive 16-byte plaintext, input terminal I1 is coupled to the output of the column mix circuit 940 to receive the 16-byte operation result, input terminal I2 is coupled to the output of the row shift circuit 930 to receive the 16-byte operation result, and output terminal O is coupled to the input of the round key addition circuit 950. Specifically, in the initial round, the controller 870 can use the control signal R_sel to control the multiplexer 980 to connect input terminal I0 to output terminal O, allowing the 16-byte plaintext S received from the input pin of the AES encoder 137 to be fed into the round key addition circuit 950. In the intermediate rounds (e.g., the 1st to 13th rounds using a 256-bit key), the controller 870 may use the control signal R_sel to control the multiplexer 980 to connect the input terminal I1 to the output terminal O, so that the output of the column mixing circuit 940 can be fed into the round key addition circuit 950. In the final round (e.g., the 14th round using a 256-bit key), the controller 870 may use the control signal R_sel to control the multiplexer 980 to connect the input terminal I2 to the output terminal O, so that the output of the row shift circuit 930 can be fed into the round key addition circuit 950. In addition, in the initial round, the controller 870 may use the control signal R_sel to control the parity prediction circuit 970 so that the 16-byte plaintext S received from the input pin of the AES encoder 137 can be fed into the parity prediction circuit 970 for generating intra-body parity bits P and trans-body parity 9 bits Q corresponding to the plaintext. In the intermediate and final rounds, the controller 870 can use the control signal R_sel to control the parity prediction circuit 970, so that the output of the enhanced replacement byte circuit 920 can be fed into the parity prediction circuit 970 to generate the intra-body parity bits P and the inter-body parity 9 bits Q corresponding to the intermediate encryption result.
[0193] refer to Figure 10The block diagram of the parity prediction circuit 970 is shown. The parity prediction circuit 970 includes an intra-state parity-bit prediction circuit 1010 and an across-state parity-9-bit prediction circuit 1030. The intra-state parity-bit prediction circuit 1010 selects input plaintext S (corresponding to the initial round) or intermediate encryption result S' (corresponding to the intermediate or final round) based on the control signal R_sel, and generates intra-state parity bits P based on the plaintext S / intermediate encryption result S' and the intra-key parity bits R. The across-state parity-9-bit prediction circuit 1030 selects input plaintext S (corresponding to the initial round) or intermediate encryption result S' (corresponding to the intermediate or final round) based on the control signal R_sel, and generates across-state parity 9 bits Q based on the plaintext S / intermediate encryption result S' and the across-key parity 9 bits V.
[0194] refer to Figure 11The block diagram of the intra-parity bit prediction circuit 1010 is shown. The controller 870 can send a selection signal R_sel to the multiplexer 1140 and the intra-parity bit generation circuit 1110 in each round to control the data flow through the specified circuit. The multiplexer 1140 includes three input terminals I0, I1, and I2, and an output terminal O. The input terminal I0 is coupled to the output of the intra-parity bit generation circuit 1110 to receive the 16-bit intra-parity code corresponding to the plaintext. The input terminal I1 is coupled to the output of the mixed column prediction circuit 1130 to receive the 16-bit operation result. The input terminal I2 is coupled to the output of the shift row prediction circuit 1120 to receive the 16-bit operation result. The output terminal O is coupled to the input of the round key prediction circuit 950. Specifically, in an initial round, the controller 870 may use the control signal R_sel to drive the intra-body parity bit generation circuit 1110 to receive 16 bytes of plaintext from the input pin of the AES encoder 137, and control the multiplexer 1140 to connect the input terminal I0 to the output terminal O, so that the 16-bit intra-body parity code corresponding to the plaintext S received from the output of the intra-body parity bit generation circuit 1110 can be fed into the round key prediction circuit 1150. In intermediate rounds (e.g., the 1st to 13th rounds using a 256-bit key), the controller 870 may use the control signal R_sel to drive the intra-body parity bit generation circuit 1110 to obtain a 16-byte intermediate encryption result S′ from the data register 912, and control the multiplexer 1140 to connect the input terminal I1 to the output terminal O, so that the 16-bit intra-body parity code corresponding to the intermediate encryption result S′ received from the output of the mixed column prediction circuit 1130 can be fed into the round key prediction circuit 1150. In the final round (for example, the 14th round using a 256-bit key), the controller 870 can use the control signal R_sel to drive the internal parity bit generation circuit 1110 to obtain the 16-byte intermediate encryption result S' from the data register 912, and control the multiplexer 1140 to connect the input terminal I2 to the output terminal O, so that the 16-bit internal parity code corresponding to the intermediate encryption result S' received from the output of the shift row prediction circuit 1120 can be fed into the round key prediction circuit 1150.
[0195] refer to Figure 12The block diagram of the intra-body parity bit generation circuit 1110 is shown. The controller 870 can send a selection signal R_sel to the multiplexer 1210 in each round to control the data flow through the specified circuit. The multiplexer 1210 includes two input terminals I0 and I1 and an output terminal O. Specifically, in the initial round, the controller 870 can use the control signal R_sel to control the multiplexer 1210 to connect the input terminal I0 to the output terminal O, so that the 16-byte plaintext S received from the input pin of the AES encoder 137 can be fed into the intra-body exclusive OR gate 1230. In the intermediate and final rounds (for example, the 1st to 14th rounds using a 256-bit key), the controller 870 can use the control signal R_sel to control the multiplexer 1210 to connect the input terminal I1 to the output terminal O, so that the 16-byte intermediate encryption result S' obtained from the data register 912 can be fed into the intra-body exclusive OR gate 1230. The internal exclusive OR gate 1230 includes multiple exclusive OR gates arranged to generate the following according to the received 16-byte plaintext S or the intermediate encryption result S': Figure 6 The intrabody parity bits P0 to P 15 .
[0196] Reference Figure 11 , the plaintext S or the intermediate encryption result S' is organized into a 4×4 array. The row shift circuit 1160 is used to shift each of the following three rows to the left by a specified number of steps. For example, the plaintext S is represented as follows:
[0197]
[0198] The row shift circuit 1160 is used to shift the first row left by one bit, the second row left by two bits, and the third row left by three bits. The shift results are shown below:
[0199]
[0200] The intra-bit parity bytes corresponding to the plaintext S or the intermediate encryption result S' are woven into a 4×4 bit array. The shift row prediction circuit 1120 is used to cyclically shift each of the following three rows to the left by a specified number of steps. For example, the intra-bit parity bits corresponding to the plaintext S are represented as follows:
[0201]
[0202] The shifted row prediction circuit 1120 is used to cyclically shift the first row to the left by one bit, the second row to the left by two bits, and the third row to the left by three bits. The shift results are as follows:
[0203]
[0204] The mixed column prediction circuit 1130 is coupled to the outputs of the shift row prediction circuit 1120 and the shift row circuit 1160, and uses 16 formulas known to those skilled in the art. Each formula adds up the values of a specified portion of the 4×4 byte array of the shifted plaintext S or the intermediate encryption result S' and the 4×4 bit array of the shifted internal parity bits to generate a specified value in the matrix of the mixed internal parity bits.
[0205] The round key prediction circuit 1150 calculates the encrypted result of the body parity bits using the following formula:
[0206] P (out) i =P (in) i +R i
[0207] P (out) i represents the parity bit of the output of the i-th individual, P (in) i represents the parity bit of the i-th input, R i represents the parity check bit in the i-th small key, i is any integer from 0 to 15. It should be noted that at this time P (in) i and P (out) i The corresponding position in the matrix refers to the position in the matrix output by the hybrid column prediction circuit 1130 , not the position in the matrix output by the intra-body parity bit generation circuit 1110 .
[0208] refer to Figure 13 The block diagram of the 9-bit span parity prediction circuit 1030 is shown. The controller 870 may send a selection signal R_sel to the span parity byte generation circuit 1310 in each round to control the data flow input to the span parity byte generation circuit 1310. Specifically, in the initial round, the controller 870 may use the control signal R_sel to drive the span parity byte generation circuit 1310 to receive 16 bytes of plaintext from the input pin of the AES encoder 137, so that the span parity byte generation circuit 1310 generates span parity bytes based on the 16 bytes of plaintext S. In the intermediate rounds (for example, the 1st to 13th rounds using a 256-bit key) or the final round (for example, the 14th round using a 256-bit key), the controller 870 can use the control signal R_sel to drive the cross-body parity byte generation circuit 1310 to obtain the 16-byte intermediate encryption result S' from the data register 912, so that the cross-body parity byte generation circuit 1310 generates a cross-body parity byte based on the 16 bytes of the intermediate encryption result S'.
[0209] The cross-body parity byte generation circuit 1310 includes a plurality of exclusive OR gates, which are arranged in the initial round to complete the following steps according to the received 16-byte plaintext S: Figure 6 The span parity byte shown (excluding the 8th bit corresponding to the intra-body parity bit) Q 0,0..7 To Q 3,0..7 In the middle round or the final round, the intermediate encryption result S' of 16 bytes is received, and the cross-body parity byte (excluding the 8th bit corresponding to the body parity bit) Q is calculated using the following formula: 0,0..7 To Q 3,0..7 :
[0210] Q 0,j =S′ 0,j +S′ 5,j +S′ 10,j +S′ 15,j , for j=0~7
[0211] Q 1,j =S′ 4,j +S′ 9,j +S′ 14,j +S′ 3,j , for j=0~7
[0212] Q 2,j =S′ 8,j +S′ 13,j +S′ 2,j +S′ 7,j , for j=0~7
[0213] Q 3,j =S′ 12,j +S′ 1,j +S′ 6,j +S′ 11,j , for j=0~7
[0214] Q 0,j to Q 3,j Represents the value of the jth bit of the 0th to 3rd span parity bytes, S' 0,j to S' 15,j Respectively represent the values of the j-th bit in the 0th to 15th intermediate encryption results.
[0215] The Across-subkey Parity-byte Split Circuitry 1330 removes the 8th bit of each 9-bit cross-subkey parity to form a cross-subkey parity byte, and feeds the cross-subkey parity byte into the cross-body parity byte prediction circuit 1350.
[0216] The span parity byte prediction circuit 1350 calculates the prediction result of each span parity byte using the following formula:
[0217]
[0218]
[0219]
[0220]
[0221] Q (out) 0,j Represents the value of the jth bit of the 0th span parity byte output, Q (out) 1,j Represents the value of the jth bit of the first span parity byte output, Q (out) 2,j Represents the value of the jth bit of the second span parity byte output, Q (out) 3,j Represents the value of the jth bit of the third span parity byte output, Q (in) i,j represents the value of the jth bit of the i-th span parity byte of the input, V i,j Represents the value of the jth bit in the i-th cross-key parity byte.
[0222] The span parity 1-bit prediction circuit 1370 calculates the prediction result of the 8th bit of each span parity 9-bit using the following formula:
[0223]
[0224]
[0225]
[0226]
[0227] Q 0,8 Represents the value of the 8th bit of the 9-bit span parity of column 0, Q 1,8Represents the value of the 8th bit of the 9-bit span parity of the first column, Q 2,8 Represents the value of the 8th bit of the 9-bit span parity of the 2nd column, Q 3,8 represents the value of the 8th bit of the 9-bit span parity check of the 3rd column, P i,8 Represents the value of the intra-body parity bit (i.e., the 8th bit) corresponding to the i-th individual.
[0228] The Across-state Parity-9-bit Concatenation Circuit 1390 adds the corresponding 8th bit output from the cross-state parity 1-bit prediction circuit 1370 to each cross-state parity byte output from the cross-state parity byte prediction circuit 1350 to form a complete cross-state parity 9-bit.
[0229] Reference Figure 9 Parity check circuitry 960 checks whether an error occurred in the previous round of execution. Parity check circuitry 960 obtains the intermediate encryption result S' from data register 912 and the intra-body parity bits P and the inter-body parity 9-bit Q corresponding to the intermediate encryption result S' from parity code register 914. Parity check circuitry 960 determines whether the intermediate encryption result S' and the intra-body parity bits P match. If they do not match, it issues a linear error signal err_L = 1 to processing unit 134, causing processing unit 134 to execute any management procedures for AES encryption errors. Parity check circuitry 960 also determines whether the intermediate encryption result S', the intermediate intra-body parity bits P, and the inter-body parity 9-bit Q match. If they do not match, it issues a linear error signal err_L = 1 to processing unit 134.
[0230] In addition to completing the byte substitution step S310 in the algorithm, the enhanced substitute-byte circuitry 920 also checks whether the result of this step is correct. Figure 14The block diagram of the enhanced byte replacement circuit 920 is shown. The cross-parity byte splitting circuit 1410 retrieves the 128-bit intermediate result S' from the data register 912, divides it into 16 bytes, and feeds these 16 bytes into enhanced lookup table circuits 1430#0 through 1430#15, respectively. Each of the enhanced lookup table circuits 1430#0 through 1430#15 performs the byte replacement step S310 and determines whether the operation is correct. If any of the enhanced lookup table circuits 1430#0 through 1430#15 detects an error in the operation, it outputs a nonlinear error signal err_nl_i = 1, where i is a positive integer between 0 and 15. If any of the enhanced lookup table circuits outputs the nonlinear error signal err_nl_i, the enhanced byte replacement circuit 920 outputs a nonlinear error signal err_nL = 1 to the processing unit 134, causing the processing unit 134 to execute any management procedures for AES encryption errors. The cross-body parity byte merging circuit 1450 collects the table lookup results of the enhanced table lookup circuits 1430 # 0 to 1430 # 15 and outputs the converted 128 bits to the row shift circuit 930 .
[0231] In some embodiments, reference Figure 15 The block diagram of the enhanced table lookup circuit 1430#i is shown, where i is a positive integer from 0 to 15. The search circuit 1510 converts the input 1 byte S' into (in) Convert 1 byte S' (out) The substitution check circuit 1530 receives the converted byte S' from the search circuit 1510. (out) , and use the formula corresponding to the lookup table to determine S' (in) Convert to S' (out) If an error is found, the alternative check circuit 1530 outputs a nonlinear error signal err_nl_i=1.
[0232] refer to Figure 16 The block diagram of the replacement check circuit 1530 is shown. The calculation circuit 1610 obtains the converted byte S' from the search circuit 1510 (out) i , calculate Affine(S' (out) ) -1 , Affine() -1 represents the inverse function of Affine transformation, and outputs the calculation result to the multiplier 1630 and the comparator 1650. The multiplier 1630 converts S' (in) Multiply Affine(S' (out) ) -1 To generate S' (mul)The comparator 1650 implements the following logical expression to generate the judgment result:
[0233] err_nl_i=0,if(S' (mul) = = 1) & & (S' (in) i =0)&&(Affine(S' (out) ) -1 ! =0)
[0234] err_nl_i=0,if(S' (mul) = = 0) & & (S' (in) i = = 0)&&(Affine(S' (out) ) -1 = =0)
[0235] err_nl_i=1,otherwise
[0236] When err_nl_i is equal to 1, it indicates that a nonlinear error signal has occurred.
[0237] In other embodiments, step S310 may use an 8-to-K bit lookup table (8-to-K S-box) to replace the value of each cell with another value, where K is a positive integer between 10 and 15. The most significant 8 bits of each cell in the lookup table are established using the following formula:
[0238] SB i =Affine((i) -1 )
[0239] SB i Represents the output result of i, Affine() represents the Affine conversion function, and i is a positive integer from 0 to 127. The other bits of each cell in the lookup table are Hamming parity codes. These K-8 bits are generated using K-8 different formulas based on the corresponding highest 8 bits. Figure 22 The block diagram of the enhanced table lookup circuit 1430#i is shown in FIG. 14 , where i is a positive integer from 0 to 15. For example, the search circuit 2210 converts the input byte S' into a byte S' according to the 8-to-14-bit table. (in) Convert 1 byte S' (out) The replacement check circuit 2230 receives the converted 1 byte S' from the search circuit 2210. (out) and 6-bit Hamming parity check code Hm, and use the 6 formulas corresponding to the lookup table to determine S' (in) Convert to S' (out)If an error is found, the alternative check circuit 1530 outputs a nonlinear error signal err_nl_i=1.
[0240] Two examples are given below to illustrate the operation of the alternative verification circuit 2230. In the first example, reference Figure 23 8-bit to 14-bit lookup table 2300 is shown. For ease of explanation, each cell in 8-bit to 14-bit lookup table 2300 contains 4 hexadecimal digits, but bits 1 to 0 are false values, always "0b00". In actual operation, search circuit 2210 will only output a 14-bit result. For example, in theory, according to 8-bit to 14-bit lookup table 2300, search circuit 2210 will convert byte S' (in) "0b00000000" is converted to 14 bits "0b01100011010111" ( Figure 23 The hexadecimal representation in is "0x635C"), and the byte S' (in) "0b00000001" is converted to 14 bits "0b01111100110001" ( Figure 23 The hexadecimal representation in the number is "0x7CC8"), and so on, wherein the 13th to 6th bits after conversion are the most significant byte, consistent with the above formula, and the 5th to 0th bits after conversion are the Hamming parity check code. If an error occurs during the conversion process, the replacement check circuit 2230 finds that the most significant byte (i.e., the 13th to 6th bits) after conversion is S' (out) There is a mismatch between the converted Hamming parity check code Hm of the 5th to 0th bits.
[0241] Response Figure 23 8 to 14 bit lookup table 2300, the replacement check circuit 2230 can be based on the highest byte S' after conversion (out) , use the following six formulas to check the six bits of the Hamming parity check code Hm respectively:
[0242] Hm5==S' (out) 7+S' (out) 6+S' (out) 5+S' (out) 4+S' (out) 3+S' (out) 2+S' (out) 1+S' (out) 0
[0243] Hm4==S' (out) 7+S' (out) 4+S' (out) 0
[0244] Hm3==S' (out)6+S' (out) 5+S' (out) 1+S' (out) 0
[0245] Hm2==S' (out) 4+S' (out) 2+S' (out) 1
[0246] Hm1==S' (out) 5+S' (out) 3+S' (out) 2
[0247] Hm0==S' (out) 7+S' (out) 6+S' (out) 3
[0248] Among them, Hm5 to Hm0 represent the 5th to 0th bits in the Hamming parity check code, S' (out) 7 to S' (out) 0 represents the 7th to 0th bits of the highest byte after conversion. When the replacement check circuit 2230 detects that any one or more of the above formulas are not true, the highest byte S' after conversion is determined. (out) There is a mismatch between the converted Hamming parity check code Hm and an error is detected.
[0249] In the second example, refer to Figure 24 8-bit to 14-bit lookup table 2400 is shown. For ease of explanation, each cell in 8-bit to 14-bit lookup table 2400 contains 4 hexadecimal digits, but bits 1 to 0 are false values, always "0b00". Similarly, in actual operation, search circuit 2210 will only output a 14-bit result. For example, in theory, search circuit 2210 will convert byte S' according to 8-bit to 14-bit lookup table 2400. (in) "0b00000000" is converted to 14 bits "0b01100011011000" ( Figure 24 The hexadecimal representation in is "0x6360"), and the byte S' (in) "0b00000001" is converted to 14 bits "0b01111100110001" ( Figure 24 The hexadecimal representation in the code is "0x7CC8"), and so on, wherein the converted bits 13 to 6 also conform to the above formula, and the converted bits 5 to 0 are Hamming parity check codes. If an error occurs during the conversion process, the replacement check circuit 2230 finds that the converted highest byte (i.e., bits 13 to 6) S' (out) There is a mismatch between the converted Hamming parity check code Hm of the 5th to 0th bits.
[0250] Response Figure 24 8 to 14 bit lookup table 2400, the replacement check circuit 2230 can be based on the converted highest byte S' (out) , use the following six formulas to check the six bits of the Hamming parity check code Hm respectively:
[0251] Hm5==S' (out) 7+S' (out) 6+S' (out) 5+S' (out) 4+S' (out) 3+S' (out) 2+S' (out) 1+S' (out) 0
[0252] Hm4==S' (out) 7+S' (out) 4+S' (out) 0
[0253] Hm3==S' (out) 5+S' (out) 2+S' (out) 1+S' (out) 0
[0254] Hm2==S' (out) 6+S' (out) 4+S' (out) 1
[0255] Hm1==S' (out) 6+S' (out) 5+S' (out) 3
[0256] Hm0==S' (out) 7+S' (out) 3+S' (out) 2
[0257] Among them, Hm5 to Hm0 represent the 5th to 0th bits in the Hamming parity check code, S' (out) 7 to S' (out) 0 represents the 7th to 0th bits of the highest byte after conversion. When the replacement check circuit 2230 detects that any one or more of the above formulas are not true, the highest byte S' after conversion is determined. (out) There is a mismatch between the converted Hamming parity check code Hm and an error is detected.
[0258] Data register 912, search circuit 1510, row shift circuit 930, column mix circuit 940, multiplexer 980, and round key addition circuit 950 can be considered an AES encoding circuit. Parity code register 914, replacement check circuit 1530, parity check circuit 960, and parity prediction circuit 970 can be considered an error checking circuit.
[0259] refer to Figure 17 The block diagram of the AES key scheduling circuit 830 is shown in FIG. The key splitting circuit 1750 splits the 256-bit base key K0 into two keys K#0 and K#1. The length of each key is 128 bits, which is the same as the length of a body. The key parity generation circuit 1742 includes multiple exclusive OR gates arranged to generate the following according to the received key K#0: Figure 7 The parity bits R0 to R 15 (collectively referred to as R#0), and the 9 bits V0 to V3 of the cross-small key parity check, and the small key intra-parity check bit R#0 and the cross-small key parity check 9 bits V#0 are stored in register 1752. The key parity check code generation circuit 1744 includes a plurality of exclusive OR gates, which are arranged to generate the following according to the received key K#1: Figure 7 The parity bit R in the small key is shown 16 to R 31 The 9-bit parity bit V4 to V7 of the inter-small key (collectively referred to as V#1) is stored in register 1754. Registers 1752 and 1754 are also referred to as the Current Cycle Parity Registers.
[0260] Key parity check circuits 1762 and 1764, respectively, check whether errors occurred in the generation of keys K#0 and K#1. Key parity check circuit 1762 obtains key K#0 from key split circuit 1750 and obtains the small key intra-parity bits R#0 and the nine-bit inter-small key parity bits V#0 corresponding to key K#0 from register 1752. Key parity check circuit 1762 determines whether key K#0 and small key intra-parity bits R#0 match. If they do not match, it issues a key error signal, err_kc = 1. Key parity check circuit 1762 also determines whether key K#0, small key intra-parity bits R#0, and nine-bit inter-small key parity bits V#0 match. If they do not match, it issues a key error signal, err_kc = 1. Key parity check circuit 1764 receives key K#1 from key splitting circuit 1750 and the intra-small-key parity bits R#1 and the inter-small-key parity 9 bits V#1 corresponding to key K#1 from register 1754. Key parity check circuit 1764 determines whether key K#1 and intra-small-key parity bits R#1 match. If not, key error signal err_kd = 1 is issued. Key parity check circuit 1764 also determines whether key K#1, intra-small-key parity bits R#1, and inter-small-key parity 9 bits V#1 match. If not, key error signal err_kd = 1 is issued. Key error signal err_kc = 1 or err_kd = 1 triggers processing unit 134 to execute any AES key error management procedures.
[0261] The key division circuit 1710 divides the 256-bit basic key K0 into 8 key words W 0,0 To W 0,3 and W 1,0 To W 1,3 , each key word is 4 bytes long, and the 8 key words are stored in register 1712. The key word processing circuit 1720 processes the last key word W according to the 1,3 Generate an intermediate operation result of a key word, which is used to combine with the first key word W 0,0 Perform a bitwise logical exclusive OR operation to generate the first key word W of key K#2 2,0 In addition to generating intermediate operation results, the key processing circuit 1720 can also check whether an error occurred during the generation of the intermediate operation results. If so, the key processing circuit 1720 outputs a key error signal err_ka = 1. The key error signal err_ka = 1 triggers the processing unit 134 to execute any management procedures in response to the AES key error.
[0262] refer to Figure 18 The key word segmentation circuit 1810 reads the last key word W from the register 1712. 1,3 , and is divided into four small keys, each of which is 1 byte. Rotate-Word Circuit 1820 shifts these four small keys left by one small key. Substitute-Word Circuit 1830 replaces each shifted small key value with another value based on a lookup table (also known as a Rijndael S-box). The lookup table is established using the following formula:
[0263] SB i =Affine((i) -1 ), for i=0~127
[0264] SB i represents the output result of i, Affine() represents the Affine conversion function, and i is a positive integer from 0 to 127. In addition to completing the conversion of the value of each input byte, the replacement key circuit 1830 also checks whether the conversion result is correct.
[0265] refer to Figure 19 The block diagram of the replacement key circuit 1830 is shown. Each of the enhanced table lookup circuits 1930#0 to 1930#3 completes the replacement operation of the value of the corresponding byte and determines whether this operation is correct. If any one of the enhanced table lookup circuits 1930#0 to 1930#3 finds that this operation is wrong, it outputs the table lookup error signal err_w_i=1, where i is a positive integer from 0 to 3. As long as any one of the enhanced table lookup circuits outputs the table lookup error signal err_w_i, the replacement key circuit 1830 outputs the key error signal err_ka=1 to the processing unit 134, so that the processing unit 134 executes any management program in response to the AES encryption error. Since the circuit structure, function and operation details of any one of the enhanced table lookup circuits 1930#0 to 1930#3 are similar to those of the enhanced table lookup circuit 1430#i, the reader can refer to Figure 15 and Figure 16 For the sake of brevity, I will not elaborate on the description.
[0266] Reference Figure 18 , round-constant circuitry 1840 will be the key word w#0 (in) Performs a bitwise exclusive OR (XOR) operation with the constant C. Figure 20The XOR gate 2010 is set to convert the key word w#0 into a constant. (in) Each bit of performs a logical exclusive OR operation with the corresponding bit of the constant C.
[0267] The word concatenation circuit 1850 obtains the four small keys w#0 to w#3 from the constant discarding circuit 1840 and combines the small keys w#0 to w#3 into a complete word key W (out) , and output the keyword W (out) To the exclusive OR gate 1725.
[0268] Word Parity Generation Circuitry 1860 includes an intra-small-key parity generation circuit and an inter-small-key parity generation circuit. The intra-small-key parity generation circuit includes a plurality of exclusive OR gates arranged to generate four intra-small-key parity bits rt10 to rt13 based on the small keys w#0 to w#3 received from the substitute word word circuit 1830. The inter-small-key parity generation circuit includes a plurality of exclusive OR gates arranged to generate one inter-small-key parity byte vt1 based on the small keys w#0 to w#3 received from the substitute word word circuit 1830. 0..7 .
[0269] The word parity prediction circuit 1870 includes an intra-small-key parity prediction circuit and an inter-small-key parity prediction circuit. The intra-small-key parity prediction circuit uses the following formula to predict the intra-small-key parity code rt10: (out) , and output to the word cross-parity prediction circuit (Word Cross-parity Prediction Circuit) 1880 and the key parity prediction circuit (Key Parity Prediction Circuit) 1772:
[0270]
[0271] rt10 (out) Represents the parity check code of the 0th small key after calculation, rt10 (in) represents the parity code of the 0th small key received from the key word parity generation circuit 1860, C irepresents the i-th bit in the constant C used in the discarded constant circuit 1840. Furthermore, the intra-small-key parity prediction circuit directly outputs the intra-small-key parity codes rt11 to rt13 received from the word parity generation circuit 1860 to the word parity prediction circuit 1880 and the key parity prediction circuit 1772. The inter-small-key parity prediction circuit predicts the inter-small-key parity byte using the following formula and outputs it to the word parity 9-bit concatenation circuit 1890:
[0272] vt1 0..7 (out) =vt1 0..7 (in) +C
[0273] vt1 0..7 (out) Represents the output cross-key parity byte, vt1 0..7 (in) represents the cross-small key parity byte received from the key word parity generation circuit 1860, and C represents the constant used in the discard constant circuit 1840.
[0274] The key word cross parity prediction circuit 1880 calculates the last bit of the 9-bit cross small key parity vt using the following formula:
[0275]
[0276] vt18 represents the last bit of the 9-bit vt cross-key parity check, rt1 i Represents the parity bit in the i-th small key.
[0277] The key word parity check 9-bit merging circuit 1890 converts the calculation result vt1 of the key word parity check prediction circuit 1870 into 0..7 Combined with the calculation result vt18 of the key word cross parity prediction circuit 1880, it becomes the cross key word parity 9-bit vt1 0..8 , and output to the key parity check circuit 1772.
[0278] Reference Figure 17 The key processing circuit 1730 generates a key according to the operation result of the exclusive OR gate 1727 (that is, the key W 2,3 ) generates an intermediate operation result of a key word, which is used to sum the key word W 1,0 Perform bit-by-bit logical exclusive OR operation to generate the first key word W of key K#3 3,0In addition to generating intermediate operation results, the key processing circuit 1730 can also check whether an error occurred during the generation of the intermediate operation results. If so, the key processing circuit 1730 outputs a key error signal err_kb = 1. The key error signal err_kb = 1 triggers the processing unit 134 to execute any management procedures for responding to AES key errors.
[0279] refer to Figure 21 The key word segmentation circuit 2110 reads the operation result (ie, the key word W) from the exclusive OR gate 1727. 2,3 ), and is divided into 4 bytes. The replacement key circuit 2130 replaces the value of each byte with another value according to the lookup table, wherein the lookup table is established using the following formula:
[0280] SB i =Affine((i) -1 ), for i=0~127
[0281] SB i represents the output result of i, Affine() represents the Affine conversion function, and i is a positive integer from 0 to 127. In addition to completing the conversion of the value of each input byte, the replacement key circuit 2130 also checks whether the conversion result is correct. Since the circuit structure, function and operation result of the replacement key circuit 2130 are similar to those of the replacement key circuit 1830, readers can refer to Figure 15 、 Figure 16 、 Figure 19 and Figure 22 For the sake of brevity, the description is omitted. Whenever any of the enhanced lookup table circuits in the replacement key circuit 2130 outputs the table lookup error signal err_w_i, the replacement key circuit 2130 outputs the key error signal err_kb=1 to the processing unit 134, causing the processing unit 134 to execute any management procedures for responding to AES encryption errors.
[0282] The key merging circuit 2150 obtains the replaced four small keys w#0 to w#3 from the replacement key circuit 2130 and merges the small keys w#0 to w#3 into a complete key W (out) , and output the keyword W (out) To the exclusive OR gate 1729.
[0283] The key parity generation circuit 2160 includes an intra-small key parity generation circuit and an inter-small key parity generation circuit. The intra-small key parity generation circuit includes a plurality of exclusive OR gates arranged to generate four intra-small key parity bits rt20 to rt23 corresponding to the small keys w#0 to w#3 received from the replacement key circuit 2130. These four intra-small key parity bits rt20 to rt23 are output to the key inter-parity prediction circuit 2180 and the key parity prediction circuit 1774. The inter-small key parity generation circuit includes a plurality of exclusive OR gates arranged to generate a inter-small key parity byte vt2 corresponding to the small keys w#0 to w#3 received from the replacement key circuit 2130. 0..7 (That is, the 8th bit of the 9-bit cross-key parity byte vt2 is missing.) 0..7 Output to the key word parity 9-bit merging circuit 2190.
[0284] The key word cross parity prediction circuit 2180 calculates the last bit of the 9-bit cross small key parity corresponding to small keys w#0 to w#3 using the following formula:
[0285]
[0286] vt28 represents the last bit of a cross-key parity byte corresponding to the small keys w#0 to w#3, rt2 i Represents the parity bits within the small key corresponding to the small key w#i.
[0287] The key word parity check 9-bit merging circuit 2190 converts the calculation result vt2 of the key word parity check generating circuit 2160 into 0..7 Combine the calculation result vt28 of the key word cross parity prediction circuit 2180 as the cross key word parity 9-bit vt2 0..8 , and output to the key parity prediction circuit 1774.
[0288] Reference Figure 17 The key parity prediction circuit 1772 includes a plurality of adders arranged to calculate the parity bits R#20 to R#2 in the small key corresponding to the key K#2 using the following formula: 15 :
[0289] R#2 i =rt1 i +R#0 i , for i=0~3
[0290] R#2 i=R#0 i-4 +R#0 i , for i=4~15
[0291] R#2 i represents the parity bit in the i-th small key corresponding to key K#2, rt1 i represents the parity bit in the i-th small key obtained from the key processing circuit 1720, R#0 i represents the parity bit in the i-th small key corresponding to key K#0 read from register 1752, R#0 i-4 represents the i-4th intra-minor parity bit corresponding to key K#0 read from register 1752. The key parity prediction circuit 1772 further includes a plurality of adders arranged to calculate the 9-bit inter-minor parity V#20 to V#23 corresponding to key K#2 using the following formula:
[0292] V#2 i =vt1+V#0 i , for i=0
[0293] V#2 i =V#0 i-1 +V#0 i , for i=1~3
[0294] V#2 i represents the 9-bit cross-small key parity corresponding to the key K#2, vt1 represents the 9-bit cross-small key parity obtained from the key processing circuit 1720, V#0 i represents the 9 bits of the i-th cross-key parity corresponding to the key K#0 read from register 1752, V#0 i-1 represents the 9-bit parity of the (i-1)th cross-minor key corresponding to key K#0 read from register 1752. Key parity prediction circuit 1772 stores the prediction results R#2 and V#2 in register 1782 for checking by key parity check circuit 1762 in the next iteration.
[0295] The key parity prediction circuit 1774 includes a plurality of adders arranged to calculate the parity bits R#30 to R#30 corresponding to the key K#3 using the following formula: 15 :
[0296] R#3 i =rt2 i +R#1 i , for i=0~3
[0297] R#3 i =R#1 i-4 +R#1i , for i=4~15
[0298] R#3 i represents the parity bit in the i-th small key corresponding to key K#3, rt2 i represents the parity bit in the i-th small key obtained from the key processing circuit 1730, R#1 i represents the parity bit in the i-th small key corresponding to key K#1 read from register 1754, R#1 i-4 represents the i-4th intra-minor parity bit corresponding to key K#1 read from register 1754. The key parity prediction circuit 1774 further includes a plurality of adders arranged to calculate the 9-bit inter-minor parity V#30 to V#33 corresponding to key K#3 using the following formula:
[0299] V#3 i =vt2+V#1 i , for i=0
[0300] V#3 i =V#1 i-1 +V#1 i , for i=1~3
[0301] V#3 i represents the 9-bit cross-small key parity check corresponding to the key K#3, vt2 represents the 9-bit cross-small key parity check obtained from the key processing circuit 1730, V#1 i represents the 9 bits of the i-th cross-key parity corresponding to the key K#1 read from register 1754, V#1 i-1 represents the 9-bit cross-minor parity of key K#1 read from register 1752. Key parity prediction circuit 1774 stores the prediction results R#3 and V#3 in register 1784 for checking by key parity prediction circuit 1764 in the next iteration.
[0302] Although Figure 17 Only the generation of keys K#2 and K#3 and error detection of their generation process are described. However, because keys K#2 and K#3 are the keys used to generate keys K#4 and K#5 (that is, the keys used in the next iteration), and so on, technical personnel in the relevant technical field can refer to the above technical content to deduce the generation of keys for other rounds and error detection of their generation process.
[0303] In some embodiments, registers 1712 and 1714 may be physically different registers. In other embodiments, registers 1712 and 1714 may refer to the same register, but store the base key and subsequently generated round keys sequentially in a specified time order.
[0304] In some embodiments, registers 1752 and 1782 may be physically different registers. In other embodiments, registers 1752 and 1782 may refer to the same register, but store the first intra-small-key parity bit R#0 and the inter-small-key parity 9 bits V#0, and subsequently generated intra-small-key parity bits and inter-small-key parity 9 bits, in a specified time sequence.
[0305] In some embodiments, registers 1754 and 1784 may be physically different registers. In other embodiments, registers 1754 and 1784 may refer to the same register, but store the first intra-small key parity bit R#1 and the inter-small key parity 9 bits V#1, as well as subsequently generated intra-small key parity bits and inter-small key parity 9 bits, in a specified time sequence.
[0306] Figure 17 The AES key scheduling circuit 830 shown can be more compact to save area. Figure 25 The block diagram of the AES key scheduling circuit 2500 is shown in FIG. The AES key scheduling circuit 2500 includes a register 1712, and the register 1712 includes components for storing 8 double words for storing 2 round keys. Initially, the key splitting circuit 1710 splits the 256-bit base key K0 into 8 key words W. 0,0 To W 0,3 and W 1,0 To W 1,3 , each key word is 4 bytes long, and 8 key words are stored in register 1712. Key word W 0,0 To W 0,3 Forming the round key K#0, and the key word W 1,0 To W 1,3 The outputs of the 4th to 7th doubleword components in the round key K#0 register 1712 are respectively coupled to the inputs of the 0th to 3rd doubleword components in the register 1712, so that the AES key scheduling circuit 2500 migrates the round key stored in the last 4 doublewords in the register 1712 to the first 4 doublewords in each clock cycle after startup. The key processing circuit 2520 couples the last doubleword (i.e., key W) in the register 1712 to the round key K#1. 1,3 ) is used to calculate the intermediate operation result W of a key word based on the last double word stored in register 1712tmp , and outputs it to exclusive OR gate 2521. The two input terminals of exclusive OR gate 2521 are respectively coupled to the output of the 0th key word in register 1712 and the output of the key word processing circuit 2520. Exclusive OR gate 2521 is configured to perform a bit-by-bit logical exclusive OR operation on the 0th key word in register 1712 and the output of the key word processing circuit 2520, and output the operation result to the component in register 1712 used to store the fourth double word. The two input terminals of exclusive OR gate 2523 are respectively coupled to the output of the 1st key word in register 1712 and the output of exclusive OR gate 2521. Exclusive OR gate 2523 is configured to perform a bit-by-bit logical exclusive OR operation on the 1st key word in register 1712 and the output of exclusive OR gate 2521, and output the operation result to the component in register 1712 used to store the fifth key word. The two input terminals of exclusive OR gate 2525 are respectively coupled to the output of the second key word in register 1712 and the output of exclusive OR gate 2523. Exclusive OR gate 2525 is configured to perform a bit-by-bit logical exclusive OR operation on the second key word in register 1712 and the output of exclusive OR gate 2523, and output the operation result to the component in register 1712 for storing the sixth key word. The two input terminals of exclusive OR gate 2527 are respectively coupled to the output of the third key word in register 1712 and the output of exclusive OR gate 2525. Exclusive OR gate 2527 is configured to perform a bit-by-bit logical exclusive OR operation on the third key word in register 1712 and the output of exclusive OR gate 2525, and output the operation result to the component in register 1712 for storing the seventh key word.
[0307] For example, in the zeroth clock cycle, the AES key scheduling circuit 2500 outputs the round key K#0 (including the key word W 0,0 To W 0,3 ) to the AES data processing circuit 810, so that the AES data processing circuit 810 can encrypt the plaintext according to the round key K#0. In the first clock cycle, the AES key scheduling circuit 2500 outputs the round key K#1 (including the key word W 1,0 To W 1,3 ) to the AES data processing circuit 810, allowing the AES data processing circuit 810 to encrypt the plaintext based on the round key K#1. Starting from the second clock cycle, the AES key scheduling circuit 2500 updates the 8 key words in the register 1712 in each clock cycle and outputs the last 4 key words stored in the components in the register 1712 to the AES data processing circuit 810 as the round key until all round keys are generated. In the second clock cycle, the value of the last 128 bits in the register 1712 (that is, the round key K#1) is updated to the first 128 bits in the register 1712, and the key processing circuit 2520 generates the round key based on the last key word W. 1,3 Generate an intermediate operation result W of a key word tmpThe 4th to 7th double words (ie, 32 bits) stored in register 1712 are the calculation results of the following formula (ie, the key word W 2,0 To W 2,3 ):
[0308] DW4=W tmp ⊕W 0,0
[0309] DW5=W tmp ⊕W 0,0 ⊕W 0,1
[0310] DW6=W tmp ⊕W 0,0 ⊕W 0,1 ⊕W 0,2
[0311] DW7=W tmp ⊕W 0,0 ⊕W 0,1 ⊕W 0,2 ⊕W 0,3
[0312] The AES key scheduling circuit 2500 outputs the round key K#2 (including the key word W 2,0 To W 2,3 ) to the AES data processing circuit 810. In the third clock cycle, the value of the last 128 bits in the register 1712 (that is, the round key K#2) is updated to the first 128 bits in the register 1712, and the key processing circuit 2520 updates the last key W according to the last key W. 2,3 Generate an intermediate operation result W of a key word tmp The 4th to 7th double words (ie, 32 bits) stored in register 1712 are the calculation results of the following formula (ie, the key word W 3,0 To W 3,3 ):
[0313] DW4=W tmp ⊕W 1,0
[0314] DW5=W tmp ⊕W 1,0 ⊕W 1,1
[0315] DW6=W tmp ⊕W 1,0 ⊕W 1,1 ⊕W 1,2
[0316] DW7=W tmp ⊕W 1,0 ⊕W 1,1 ⊕W 1,2⊕W 1,3
[0317] The AES key scheduling circuit 2500 outputs the round key K#3 (including the key W 3,0 To W 3,3 ) is given to the AES data processing circuit 810. The round key K#4 and subsequent round keys can be deduced in the same way and are not described in detail for the sake of brevity.
[0318] refer to Figure 26 The block diagram of the key processing circuit 2520 is shown. Starting from the second clock cycle, the key processing circuit 2520 can operate in two alternating modes: even round key and odd round key. In the even round key mode, the key processing circuit 2520 generates the intermediate operation result W of the last key of the previous round key for the even round key (e.g., round key K#2, K#4, K#6, etc.). tmp In the odd-numbered round key mode, the key processing circuit 2520 generates the intermediate operation result W of the last key of the previous round key for the odd-numbered round key (e.g., round key K#3, K#5, K#7, etc.). tmp .
[0319] The key word splitting circuit 2610 obtains the value of the 7th double word (i.e., the last key word) from the register 1712 and splits it into 4 small keys, each of which is 1 byte. The structures, functions, and operations of the key word rotation circuit 2620, the key word substitution circuit 2640, the constant discarding circuit 2670, and the key word merging circuit 2690 can be referred to in the corresponding FIG. Figure 18 The description of the rotation key circuit 1820, the replacement key circuit 1830, the constant discarding circuit 1840 and the key merging circuit 1850 is omitted for brevity. Figure 18 The key word parity check generating circuit 1860, the key word parity check predicting circuit 1870, the key word cross parity check predicting circuit 1880 and the key word parity check 9-bit merging circuit 1890 are used to generate the cross key word parity check 9-bit vt1 0..8 , and output to the key parity prediction circuit 1772. The technical details of the parity compensation circuit 2662 can be found in Figure 18 The description of the corresponding circuit in is omitted for brevity. The parity check compensation circuit 2664 includes Figure 21 The key word parity check generating circuit 2160, the key word cross parity check predicting circuit 2180 and the key word parity check 9-bit merging circuit 2190 are used to generate the cross key word parity check 9-bit vt2 0..8 , and output to the key parity prediction circuit 1774. The technical details of the parity compensation circuit 2664 can be found in Figure 21The description of the corresponding circuit in will not be repeated for the sake of brevity.
[0320] Key processing circuit 2520 further includes multiplexers 2630 and 2680, and a demultiplexer 2650, which allow controller 870 to arrange data streams in even-round key mode and odd-round key mode. Input terminal I0 of multiplexer 2630 is coupled to the output of rotate key circuit 2620, input terminal I1 of multiplexer 2630 is coupled to the output of key segmentation circuit 2610, and output terminal O of multiplexer 2630 is coupled to the input of substitute key circuit 2640. Input terminal I0 of multiplexer 2680 is coupled to the output of constant truncation circuit 2670, input terminal I1 of multiplexer 2630 is coupled to the output of substitute key circuit 2640, and output terminal O of multiplexer 2630 is coupled to the input of key merging circuit 2690. The input terminal I of the demultiplexer 2650 is coupled to the output of the replacement key circuit 2640, the output terminal O0 of the demultiplexer 2650 is coupled to the input of the parity compensation circuit 2662, and the output terminal O1 of the demultiplexer 2650 is coupled to the input of the parity compensation circuit 2664. When the key processing circuit 2520 is activated, the controller 870 may send a mode selection signal M_sel of the even-numbered round key mode to the multiplexer 2620 in each even-numbered clock cycle starting from the second clock cycle to connect the input terminal I0 of the multiplexer 2620 to the output terminal O of the multiplexer 2620, and send a mode selection signal M_sel to the multiplexer 2680 to connect the input terminal I0 of the multiplexer 2680 to the output terminal O of the multiplexer 2680, so that the key W i,3 (in) The intermediate operation result W can be processed in sequence by the key word division circuit 2610, the key word rotation circuit 2620, the key word substitution circuit 2640, the constant discard circuit 2670 and the key word merging circuit 2690 to generate the intermediate operation result W tmp (That is, the keyword W i,3 (out) ), i is an odd number greater than or equal to 1. Furthermore, the controller 870 may send a mode selection signal M_sel for the even-round key mode to the multiplexer 2680 in each even-numbered clock cycle starting from the second clock cycle, thereby connecting the input terminal I of the demultiplexer 2680 to the output terminal O0 of the demultiplexer 2680, and allowing the operation result of the replacement key circuit 2640 to be output to the parity check compensation circuit 2662 to generate a 9-bit cross-key parity check vt1. 0..8, i is an odd number greater than or equal to 1. When the key processing circuit 2520 is started, the controller 870 may send a mode selection signal M_sel of the odd-numbered round key mode to the multiplexer 2620 in each odd-numbered clock cycle starting from the third clock cycle to connect the input terminal I1 of the multiplexer 2620 to the output terminal O of the multiplexer 2620, and send a mode selection signal M_sel to the multiplexer 2680 to connect the input terminal I1 of the multiplexer 2680 to the output terminal O of the multiplexer 2680, so that the key W i,3 (in) can be processed in sequence by the key word segmentation circuit 2610, the key word substitution circuit 2640 and the key word merging circuit 2690 to generate an intermediate operation result W tmp (That is, the keyword W i,3 (out) ), i is an even number greater than or equal to 2. Furthermore, the controller 870 may send a mode selection signal M_sel for the odd-round key mode to the multiplexer 2680 in each odd-numbered clock cycle starting from the third clock cycle, thereby connecting the input terminal I of the demultiplexer 2680 to the output terminal O1 of the demultiplexer 2680, and allowing the operation result of the replacement key circuit 2640 to be output to the parity check compensation circuit 2664 to generate a 9-bit cross-key parity check vt2. 0..8 , i is an even number greater than or equal to 2.
[0321] Although Figures 1 to 2 、 Figure 5 、 Figures 8 to 26 The components described above are included, but it does not exclude the use of more additional components to achieve better technical effects without violating the spirit of the invention.
[0322] The above description is only a preferred embodiment of the present invention, but it is not intended to limit the scope of the present invention. Any person skilled in the art may make further improvements and changes on this basis without departing from the spirit and scope of the present invention. Therefore, the scope of protection of the present invention shall be based on the scope defined by the claims of this application.
Claims
1. A round key expansion device for data encryption, characterized in that: include: a register comprising components arranged to store eight double words, wherein outputs of components of the fourth through seventh double words in the register are coupled to inputs of components of the zeroth through third double words, respectively; a key word processing circuit coupled to the output of the last double word of the register and configured to operate in a first mode and a second mode in an alternating manner; in the first mode, a first intermediate operation result corresponding to the even-numbered round key is calculated based on the last double word; and in the second mode, a second intermediate operation result corresponding to the odd-numbered round key is calculated based on the last double word; a first exclusive OR gate coupled to the output of the element of the zeroth double word in the register and the output of the key word processing circuit, configured to perform a bit-by-bit logical exclusive OR operation on the zeroth double word and the output of the key word processing circuit, and output a first operation result to the component in the register for storing the fourth double word; a second exclusive OR gate coupled to the output of the element of the first double word in the register and the output of the first exclusive OR gate, configured to perform a bit-by-bit logical exclusive OR operation on the first double word and the output of the first exclusive OR gate, and output a second operation result to the component in the register for storing the fifth double word; a third exclusive OR gate coupled to the output of the element of the second double word in the register and the output of the second exclusive OR gate, configured to perform a bit-by-bit logical exclusive OR operation on the second double word and the output of the second exclusive OR gate, and output a third operation result to the component in the register for storing the sixth double word; and A fourth exclusive OR gate is coupled to the output of the element of the third double word in the register and the output of the third exclusive OR gate, and is configured to perform a bit-by-bit logical exclusive OR operation on the third double word and the output of the third exclusive OR gate, and output a fourth operation result to the component in the register for storing the seventh double word.
2. The round key expansion device for data encryption according to claim 1, characterized in that: The zeroth to fourth double words constitute a first round key, the fifth to seventh double words constitute a second round key, the first round key is 128 bits, and the second round key is 128 bits.
3. The round key expansion device for data encryption according to claim 1, characterized in that: The first operation result to the fourth operation result are expressed as the following formula: DW4=W tmp ⊕W i,0 DW5=W tmp ⊕W i,0 ⊕W i,1 DW6=W tmp ⊕W i,0 ⊕W i,1 ⊕W i,2 DW7=W tmp ⊕W i,0 ⊕W i,1 ⊕W i,2 ⊕W i,3 DW4 represents the first operation result, DW5 represents the second operation result, DW6 represents the third operation result, DW7 represents the fourth operation result, and W tmp represents the intermediate operation result output by the key word processing circuit, W i,0 represents the 0th key word of the i-th round key, W i,1 represents the first key word of the i-th round key, W i,2 represents the second key word of the i-th round key, W i,3 Represents the third key word of the i-th round key, where i is any integer from 1 to 12.
4. The round key expansion device for data encryption according to claim 1, characterized in that: The key word processing circuit comprises: A key word segmentation circuit, coupled to the output of the last double word of the register, configured to segment the last double word into four first bytes; a key word rotation circuit, coupled to the output of the key word segmentation circuit, configured to cyclically shift the four first bytes received from the key word segmentation circuit to the left by one byte to form four second bytes; A first multiplexer, comprising a first input terminal, a second input terminal and a first output terminal, wherein the first input terminal is coupled to the output of the rotation key circuit, and the second input terminal is coupled to the output of the rotation key circuit; a replacement key word circuit, coupled to the first output terminal of the first multiplexer, configured to replace each of the four first bytes or the four second bytes received from the first output terminal of the first multiplexer with a third byte according to a lookup table; a constant discarding circuit, coupled to the output of the key substitution circuit, configured to perform a bit-by-bit exclusive OR operation on each of the third bytes and the constant to generate a fourth byte; A second multiplexer comprising a third input terminal, a fourth input terminal and a second output terminal, wherein the third input terminal is coupled to the output of the constant discarding circuit, and the fourth input terminal is coupled to the output of the key replacement circuit; as well as a key word merging circuit, coupled to the second output terminal of the second multiplexer, configured to merge the four fourth bytes received from the second output terminal of the second multiplexer into the first intermediate operation result; Alternatively, the four third bytes received from the second output terminal of the second multiplexer are combined into the second intermediate operation result.
5. The round key expansion device for data encryption as claimed in claim 4, characterized in that: Include: a controller coupled to the first multiplexer and the second multiplexer, configured to send a first mode selection signal to the first multiplexer to connect the first input terminal to the first output terminal, and send the first mode selection signal to the second multiplexer to connect the third input terminal to the second output terminal in every even clock cycle starting from the second clock cycle; And in each odd clock cycle starting from the third clock cycle, a second mode selection signal is sent to the first multiplexer to connect the second input terminal to the first output terminal, and a second mode selection signal is sent to the second multiplexer to connect the fourth input terminal to the second output terminal.
6. The round key expansion device for data encryption as claimed in claim 4, characterized in that: The key word processing circuit comprises: a demultiplexer comprising a fifth input terminal, a third output terminal and a fourth output terminal, wherein the fifth input terminal is coupled to the output of the replacement key circuit; A first parity check compensation circuit, coupled to the third output terminal, configured to generate a first cross-key word parity check 9 bits corresponding to the odd-numbered round key according to the four second bytes; as well as The second parity check compensation circuit is coupled to the fourth output terminal and is configured to generate a second cross-key word parity check 9 bits corresponding to the even-numbered round key according to the four second bytes.
7. The round key expansion device for data encryption according to claim 6, characterized in that: Include: a controller coupled to the first multiplexer and the second multiplexer, configured to send a first mode selection signal to the demultiplexer in every even clock cycle starting from the second clock cycle to connect the fifth input terminal to the third output terminal; And in each odd clock cycle starting from the third clock cycle, a second mode selection signal is sent to the demultiplexer to connect the fifth input terminal to the fourth output terminal.
8. The round key expansion device for data encryption as claimed in claim 4, characterized in that: The replacement key word circuit includes four enhanced table lookup circuits, and each of the enhanced table lookup circuits includes: A search circuit is configured to convert a first value of the first byte or the second byte into a second value of K bits according to an 8-to-K bit lookup table, wherein K is a positive integer between 10 and 15, and the second value includes a Hamming parity check code of K-8 bits; and An alternative check circuit is coupled to the search circuit and is configured to use a formula corresponding to the 8-to-K bit lookup table to determine whether an error occurs during the conversion of the first value to the second value, and to send an error signal when an error is found, wherein the number of the formulas is K-8.
9. The round key expansion device for data encryption as claimed in claim 8, characterized in that: The most significant 8 bits in each cell of the 8-to-K bit lookup table are built using the following formula: SB i =Affine((i) -1 ) SB i Represents the output result of i, Affine() represents the Affine conversion function, and i is a positive integer from 0 to 127.
10. The round key expansion device for data encryption according to claim 8, characterized in that: K is 14.
11. The round key expansion device for data encryption according to claim 10, characterized in that: The alternative check circuit is configured to check the Hamming parity check code in the second value using the following 6 formulas according to the most significant byte in the second value: Hm5==S’ (out) 7+S’ (out) 6+S’ (out) 5+S’ (out) 4+S’ (out) 3+S’ (out) 2+S’ (out) 1+S’ (out) 0 Hm4==S’ (out) 7+S’ (out) 4+S’ (out) 0 Hm3==S’ (out) 5+S’ (out) 2+S’ (out) 1+S’ (out) 0 Hm2==S’ (out) 6+S’ (out) 4+S’ (out) 1 Hm1==S’ (out) 6+S’ (out) 5+S’ (out) 3 Hm0==S’ (out) 7+S’ (out) 3+S’ (out) 2 Wherein, Hm5 to Hm0 represent the 5th to 0th bits in the Hamming parity check code respectively, S' (out) 7 to S' (out) 0 represents the 7th to 0th bits of the most significant byte in the second value, respectively; and When it is detected that any one or more of the formulas are not true, the error signal is issued.
12. The round key expansion device for data encryption according to claim 10, characterized in that: The alternative check circuit is configured to check the Hamming parity check code in the second value using the following 6 formulas according to the most significant byte in the second value: Hm5==S’ (out) 7+S’ (out) 6+S’ (out) 5+S’ (out) 4+S’ (out) 3+S’ (out) 2+S’ (out) 1+S’ (out) 0 Hm4==S’ (out) 7+S’ (out) 4+S’ (out) 0 Hm3==S’ (out) 5+S’ (out) 2+S’ (out) 1+S’ (out) 0 Hm2==S’ (out) 6+S’ (out) 4+S’ (out) 1 Hm1==S’ (out) 6+S’ (out) 5+S’ (out) 3 Hm0==S’ (out) 7+S’ (out) 3+S’ (out) 2 Wherein, Hm5 to Hm0 represent the 5th to 0th bits in the Hamming parity check code respectively, S' (out) 7 to S' (out) 0 represents the 7th to 0th bits of the most significant byte in the second value, respectively; and When it is detected that any one or more of the formulas are not true, the error signal is issued.
13. The round key expansion device for data encryption according to claim 4, characterized in that: The replacement key word circuit includes four enhanced table lookup circuits, and each of the enhanced table lookup circuits includes: A search circuit configured to convert a first value of the first byte or the second byte into a second value according to a lookup table; and A replacement check circuit is coupled to the search circuit and is configured to use a formula corresponding to the lookup table to determine whether an error occurs during the conversion of the first value into the second value, and to issue an error signal when an error is found.
14. The round key expansion device for data encryption according to claim 13, characterized in that: The lookup table is built using the following formula: SB i =Affine((i) -1 ) SB i Represents the output result of i, Affine() represents the Affine conversion function, and i is a positive integer from 0 to 127.
15. The round key expansion device for data encryption according to claim 14, characterized in that: The alternative verification circuit comprises: A calculation circuit, coupled to the search circuit, is configured to obtain the second value and calculate Affine(S' (out) ) -1 And produce the third value, where S' (out) Represents the second value, Affine() -1 Represents the inverse function of Affine transformation; a multiplier coupled to the search circuit and the calculation circuit, configured to multiply the second value by the third value to generate a fourth value; and A comparator, coupled to the search circuit and the multiplier, is configured to implement the following logical expression to generate a judgment result: err_nl=0,if(S’ (mul) ==1)&&(S’ (in) !=0)&&(Affine(S’ (out) ) -1 !=0) err_nl=0,if(S’ (mul) ==0)&&(S’ (in) ==0)&&(Affine(S’ (out) ) -1 ==0) err_nl=1,otherwise When err_nl is equal to 1, it means an error is found, S' (mul) represents the fourth value, S' (in) represents the first value, S' (out) represents the second value.
