Flexible structure and instructions for Advanced Encryption Standard (AES)
By providing AES functional modules and flexible instruction sets in a general-purpose processor, the problem of degradation of AES algorithm in x86 processors is solved, and high-performance AES encryption and decryption operations are realized, adapting to different application needs, and improving the password Flexibility of key generation.
Patent Information
- Application Number
- CN202011411255.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2007-03-28
- Filing Date
- 2008-03-25
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2028-03-25
AI Technical Summary
Existing AES algorithms in x86 register-based processors may reduce performance due to their dependence on implicit registers, especially in applications requiring high performance, such as network packet processing and disk drive encryption. The need for flexibility in key generation.
Provides a flexible structure and instruction set for performing AES encryption and decryption in a general-purpose processor, including AES functional modules, extraction and decoding units, execution units and micro-operations, storing loop keys through 128-bit registers, supporting different key lengths and Number of cycles, optimize performance to meet different application needs.
It improves the performance of AES algorithm in general-purpose processors, adapts to the performance needs of different applications, reduces memory usage, improves the flexibility of key generation, and enhances the protection of information stored in the computer.
Smart Images

Figure CN112532376B_ABST
Abstract
Description
[0001] This application is a divisional application of a patent application of the same name with application date of March 25, 2008 and application number 201710815893.9. Technical Field
[0002] The present disclosure relates to cryptographic algorithms, and in particular, to the Advanced Encryption Standard (AES) algorithm. Background Art
[0003] Cryptography is a tool that relies on algorithms and keys to protect information. The algorithms are complex mathematical algorithms, while the keys are strings of bits. There are two basic types of cryptographic systems: private key systems and public key systems. A private key system, also known as a symmetric system, has a single key (the "private key") that is shared by two or more parties. This single key is used to both encrypt and decrypt information.
[0004] The Advanced Encryption Standard (AES), published by the National Institute of Standards and Technology (NIST) as Federal Information Processing Standard (FIPS) 197, is a private key system. AES is a symmetric block cipher that can encrypt and decrypt information.
[0005] Cryptography (encryption) uses a private key (encryption key) to perform a series of transformations to convert understandable data called "plaintext" into an unintelligible form called "ciphertext". The transformations in encryption include: (1) adding a round key (a value derived from the encryption key) to a state (a two-dimensional array of bytes) using an exclusive OR (XOR) operation; (2) processing the state using a non-linear byte substitution table (S-Box); (3) circularly shifting the last three rows of the state using different offsets; and (4) taking all columns of the state and (independently) mixing the data of the columns to produce new columns.
[0006] Decryption (reverse encryption) uses the encryption key to perform a series of transformations to convert a "ciphertext" block into a "plaintext" block of the same size. The transformations in reverse encryption are the inverse of the transformations performed in encryption.
[0007] The AES standard specifies that the Rijindael algorithm uses encryption keys of 128, 192, and 256 bits to process 128-bit data blocks. The different key lengths are generally referred to as AES-128, AES-192, and AES-256.
[0008] The AES algorithm converts plaintext to ciphertext or ciphertext to plaintext in 10, 12, or 14 consecutive cycles, where the number of cycles depends on the key length. BRIEF DESCRIPTION OF THE DRAWINGS
[0009] Features of embodiments of the claimed subject matter will become apparent from the following detailed description and by reference to the accompanying drawings, in which like reference numerals represent like parts, and in which:
[0010] Figure 1 is a block diagram of a system including an embodiment of a flexible structure and instructions for performing AES encryption and decryption in a general purpose processor in accordance with the principles of the present invention;
[0011] Figure 2 yes Figure 1 A block diagram of an embodiment of a processor is shown in;
[0012] Figure 3 Yes Figure 2 A block diagram of an embodiment of an execution unit for performing AES encryption and decryption according to the principles of the present invention is shown in FIG.
[0013] Figure 4 It is shown by Figure 3 Flowchart of the AES encryption loop instruction flow of the execution unit shown in;
[0014] Figure 5 It is shown by Figure 3 Flowchart of the last cycle instruction flow of AES encryption of the execution unit shown in;
[0015] Figure 6 It is shown by Figure 3 Flowchart of the AES decryption loop instruction flow of the execution unit shown in;
[0016] Figure 7 It is shown by Figure 3 A flowchart of the last cycle instruction flow of AES decryption of the execution unit shown in FIG. 1 ; and
[0017] Figure 8 An embodiment of an AES round instruction with immediate bytes that may be used to generate round keys and perform encryption and decryption is shown.
[0018] Although the following detailed description will be made with reference to illustrative embodiments of the claimed subject matter, those skilled in the art will appreciate that various substitutions, modifications and variations thereof are apparent. Therefore, the claimed subject matter should be viewed broadly and should be limited only by the appended claims. DETAILED DESCRIPTION
[0019] The Advanced Encryption Standard (AES) algorithm is a computationally intensive algorithm that is typically implemented in software or a dedicated processor. Therefore, encryption operations are typically used to encrypt only a subset of information stored in a computer, for example, information that can be classified as "top secret." However, there is a need to encrypt more information stored in a computer. For example, if all information stored in a mobile computer is encrypted, then even if the mobile computer is stolen, the information can still be protected.
[0020] AES is a block cipher that operates on 128-bit blocks using a key length of 128, 192 or 256 bits. Depending on the key length, a series of operations is repeated for a number of (10, 12 or 14) cycles.
[0021] By using an implicit 128-bit register to store the round key, the key for each round can be generated dynamically (ie, just before each round). However, using an implicit register may reduce the performance of x86-type register-based processors due to dependence on the results of previous instructions.
[0022] There are some applications that benefit from dynamic key generation, for example, applications for processing network packets that may have different keys per flow. There may be other applications that require higher performance using a single key, for example, using a single key to encrypt / decrypt the contents of a disk drive. Therefore, a need for flexibility in key generation has arisen. Embodiments of the present invention provide a flexible structure and instructions for performing AES encryption and decryption in a general purpose processor.
[0023] Figure 1 1 is a block diagram of a system 100 that includes an embodiment of a flexible structure and instructions for performing AES encryption and decryption in a general purpose processor according to the principles of the present invention. The system 100 includes a processor 101, a memory controller hub (MCH) or (graphics memory controller hub (GMCH)) 102, and an input / output (I / O) controller hub (ICH) 104. The MCH 102 includes a memory controller 106 that controls communications between the processor 101 and a memory 108. The processor 101 and the MCH 102 communicate via a system bus 116.
[0024] Processor 101 can be any one of a variety of processors, such as: a single core Pentium Processor, single-core Intel Celeron processor, XScale processors, or such Pentium D, Processor or A multi-core processor such as a Duo processor, or any other type of processor.
[0025] The memory 108 may be dynamic random access memory (DRAM), static random access memory (SRAM), synchronous dynamic random access memory (SDRAM), double data rate 2 (DDR2) RAM, or Rambus dynamic random access memory (RDRAM), or any other type of memory.
[0026] ICH 104 may be coupled to MCH 102 using a high-speed chip-to-chip interconnect 114, such as a direct media interface (DMI). DMI supports a concurrent transfer rate of 2 Gbits / sec via two unidirectional channels.
[0027] The ICH 104 may include a storage I / O controller 110 for controlling communication with at least one storage device 112 coupled to the ICH 104. The storage device may be, for example, a disk drive, a digital video disk (DVD) drive, a compact disk (CD) drive, a redundant array of independent disks (RAID), a tape drive, or other storage device. The ICH 104 may communicate with the storage device 112 over a storage protocol interconnect 118 using a serial storage protocol, such as a Serial Attached Small Computer System Interface (SAS) or a Serial Advanced Technology Attachment (SATA).
[0028] The processor 101 includes an AES function module 103 for performing AES encryption and decryption operations. The AES function module 103 can be used to encrypt or decrypt information stored in the memory 108 and / or the storage device 112.
[0029] Figure 2 yes Figure 1 1. The processor 101 includes a fetch and decode unit 206 for decoding processor instructions received from a first level (L1) instruction cache 202. Data used to execute instructions may be stored in a register file 208. In one embodiment, the register file 208 includes a plurality of 128-bit registers that are used by the AES instructions to store data used by the AES instructions.
[0030] In one embodiment, the register file is a set of 128-bit registers similar to the 128-bit MMX registers provided in the Intel Pentium MMX processor with the Streaming (Single Instruction Multiple Data (SIMD)) Extensions (SSE) instruction set. In a SIMD processor, data is processed in 128-bit blocks, with one 128-bit block loaded at a time.
[0031] The fetch and decode unit 206 fetches macroinstructions from the L1 instruction cache 202, decodes the macroinstructions, and decomposes them into simple operations called micro-operations (μops), which can be stored in a microcode read-only memory (ROM) 214. The execution unit 210 schedules and executes these micro-operations. In the illustrated embodiment, the AES function module 103 in the execution unit 210 includes micro-operations for the AES instruction set. The exit unit 212 writes the results of the executed instructions to a register or memory. The loop key 214 used by the AES instruction can be stored in the L1 data cache 204 and can be loaded into the execution unit 210 for the micro-operation to execute the AES instruction in the AES instruction set. The process of storing the loop key 214 in the data cache 204 protects the loop key from attacks from adjacent channels, for example, attempts to obtain the loop key so that encrypted information stored in the system 100 can be accessed.
[0032] Figure 3 It shows Figure 2 FIG. 2 is a block diagram of an embodiment of an execution unit 210 for performing AES encryption and decryption according to the principles of the present invention. Figure 2 To describe Figure 3 .
[0033] After the AES instruction has been decoded by fetch and decode unit 206 , execution of the AES instruction by execution unit 210 involves executing micro-operations associated with the AES instruction, which may be stored in microcode ROM 214 .
[0034] The flexible AES instruction set according to embodiments of the present invention allows the programmer to trade off performance for the amount of data to be processed and memory bandwidth and capacity.
[0035] Some applications can use the same key all the time. In performance critical applications, a tradeoff can be made between pre-computing the key schedule each time (i.e., the round key for each round) and storing it in memory. Other applications may need to minimize the amount of memory used to store the key schedule and still achieve good performance for multi-block operations. For such applications, the key schedule can be pre-computed for multiple blocks before processing. The memory footprint can be further minimized by storing only the encryption key or the decryption key and deriving the other necessary information later at the expense of some performance.
[0036] In x86-type processors, the area and number of execution ports available for AES round-key operations and AES schedule operations limit the performance of AES instructions. In systems where key expansion is required for each block encryption, performance can be improved by placing the AES schedule operation and the AES round-key operation on separate execution ports. However, in x86-type processors, the use of separate execution ports and the additional area for controlling the separate ports may not be possible.
[0037] In one embodiment, an AES instruction set is provided, which includes a separate AES instruction for performing an encryption cycle, a decryption cycle, encrypting the last cycle, decrypting the last cycle, and for calculating an encryption cycle key or a decryption cycle key. In one embodiment, there are six AES instructions in the AES instruction set. Each AES cycle instruction has a unique opcode. The AES cycle instructions in the AES instruction set for a fixed width cycle key (e.g., 128 bits) according to one embodiment are shown below in Table 1.
[0038] AESENCRYPTRound xmmsrcdst xmm
[0039] Input: data (= target), round key
[0040] Output: Data converted through AES cycle using the cycle key
[0041] AESENCRYPTLastRound xmmsrcdst xmm
[0042] Input: data (= target), round key
[0043] Output: The data after the last round of AES conversion using the round key
[0044] AESDECRYPTRound xmmsrcdst xmm
[0045] Input: data (= target), round key
[0046] Output: Data converted through AES cycle using the cycle key
[0047] AESDECRYPTLastRound xmmsrcdst xmm
[0048] Input: data (= target), round key
[0049] Output: The data after the last round of AES conversion using the round key
[0050] AESNextRoundKey xmmsrc1,2xmm dst(immediate)
[0051] Input: low 128 bits of the key, high 128 bits of the key, indicator of the number of cycles
[0052] Output: Next round key derived from input
[0053] AESPreviousRoundKey xmmsrc1,2xmm dst(immediate)
[0054] Input: low 128 bits of the key, high 128 bits of the key, indicator of the number of cycles
[0055] Output: Previous round key derived from input
[0056] Table 1
[0057] The AES instruction set includes four AES loop instructions (encryption, decryption, encryption last loop and decryption last loop) and two AES loop key instructions (next loop key and previous loop key). The AES loop instruction in the AES instruction set includes multiple single loop operations for performing encryption and decryption loop operations, which are used for all loops except the last loop. For example, in the AES encryption loop (AESENCRYPTRound) single loop instruction of Table 1, the input data is stored in a 128-bit register (xmmsrcdst) and the loop key is stored in another 128-bit register (xmm). The instruction performs an AES loop operation on the input data (source) stored in the 128-bit xmmsrcdst register, and uses the execution result of the loop operation to rewrite the input data stored in the 128-bit xmmsrcdst register. Therefore, xmmsrcdst first stores the input data and then stores the result of the AES loop operation.
[0058] The AES instruction set also includes: an AES decryption instruction for the last decryption cycle, and an AES encryption instruction for the last encryption cycle. For example, in the AES encryption last cycle (AESENCRYPTLastRound) single cycle instruction of Table 1, the input data is stored in a 128-bit register (xmmsrcdst) and the loop key is stored in another 128-bit register (xmm). The instruction performs an AES loop operation on the input data (source) stored in the xmmsrcdst register, and uses the execution result of the loop operation to rewrite the input data stored in the xmmsrcdst register. Therefore, xmmsrcdst first stores the input data and then stores the result of the loop operation. The xmm register stores the loop key for the loop operation.
[0059] In another embodiment, loop instructions such as AESENCRYPTRound and AESENCRYPTLastRound and the last loop instruction may take inputs from memory (m / 128) instead of from the register file 304, for example, an AES loop instruction may be AESENCRYPTRound xmmsrcdst m / 128.
[0060] The other two AES instructions in the AES instruction set generate round keys for AES rounds based on the length of the key (i.e., 128, 192, or 256 bits). One AES round key instruction generates a round key for encryption operations, and another AES round key instruction generates a round key for decryption operations. The immediate field in the AES Next Round Key instruction and the AES Previous Round Key instruction specifies the length of the key {128, 192, 256}.
[0061] In another embodiment, the immediate field is not used, and different key lengths are implemented as separate instructions each with a unique opcode. In this embodiment, the multiple AES round key instructions include three separate instructions for each round key operation, for example, AESNextRoundKey_128, AESNextRoundKey_192, and AESNextRoundKey_256, and there will be a similar instruction set containing three instructions for AES ReviousRoundKey. In this embodiment, the total number of instructions in the instruction set is 10, which is different from the total number of instructions of 6 in the previous embodiment.
[0062] Register file 304 has multiple 128-bit registers, which can be used by the AES instructions in the AES instruction set. The 128-bit registers can store the result of source operands, cycle keys and AES instructions. For the first cycle, the source operand received by the AES instruction can be a 128-bit plain text to be encrypted or a 128-bit ciphertext to be decrypted. The key for the key scheduling for generating 128, 192 or 256-bit keys can be stored in any 128-bit register 308 in register file 304. The cycle key can also be stored in any 128-bit register 308 in the register file. All instructions use the registers in the register file and can also directly obtain input from memory as described above.
[0063] An example of source code using an embodiment of the AES instruction set shown in Table 1 is shown below in Table 2. In this example, performance is optimized in applications where the same key is used to perform encryption on multiple blocks. One such application is to encrypt the contents of a disk using a single key, where all data is encrypted using the same key before being stored on the disk. In this example, AES-128 encryption is performed.
[0064] The key length can be 128 bits, 192 bits, or 256 bits. Depending on the key length, the number of loops to be performed can be 1, 10, 12, or 14, where each loop key has a fixed length (128 bits). In the case of loop count values of 10, 12, 14, the AES micro-operation can perform standard AES encryption and decryption for a key length of 128 bits, 192 bits, or 256 bits.
[0065] When the same key is used for multiple blocks, the round key (key schedule) for each round can be pre-calculated and stored in a memory (e.g., the level 1 data cache 204) so that the same key schedule does not need to be calculated again before encryption / decryption operations are performed on each block.
[0066]
[0067] Table 2
[0068] An array (RK) with 10 elements is used to store the key schedule for the key. The input key for AES-128 encryption is stored in RK[0], and 9 round keys RK[0]-RK[1] are pre-calculated by calling the AESNextRoundKey instruction from the AES instruction set. The AESNextRoundKey instruction calculates the next round based on the current round key. The pre-calculated round keys for key scheduling can be stored in the round keys 214 of the level 1 data cache 204.
[0069] In this example, as part of the key scheduling (expanding the key), before entering the loop to perform the AES loop, the round key for the loop is directly input from the register file 304, and an exclusive OR (XOR) operation is performed on the body and the key. For each of loops 1 to 9, the AESENCRYPTRound instruction is called from the AES instruction set to perform an AES loop operation for one loop. For the last loop (loop 10), the AESNECYRPTLastRound instruction is called from the AES instruction set to perform an AES loop operation for the last loop.
[0070] Before issuing the first AES instruction to start the encryption or decryption operation, the information to be encrypted or decrypted by the AES instruction is loaded into the source / destination register 306 in the register file 304. The key used to encrypt / decrypt the information in the source register 306 is stored in one or more other registers 308 in the register file 304. In the case of a 128-bit key, the entire 128-bit key is stored in any one of the other 128-bit registers in the register file 304. For keys longer than 128 bits, the most significant bits (higher than 128 bits) are stored in another 128-bit register.
[0071] In the example shown in Table 2, the round key for each round is pre-calculated based on the key and stored in the level 1 data cache 204 before loading the round key into any register 308 of the register file 304. The key for each round may also be stored in one or more registers in the register file 304, or may be stored in the round key 214 of the level 1 data cache 204.
[0072] AES has a fixed block length of 128 bits and a key length of 128, 192, or 256 bits, and operates on a 4x4 array of bytes, i.e., 16 bytes (fixed block length of 128 bits), which is called a "body." The AES algorithm converts a 128-bit plaintext block to a 128-bit ciphertext block (encryption) or a 128-bit ciphertext block to a 128-bit plaintext block (decryption) in 10, 12, or 14 consecutive cycles, where the number of cycles depends on the key length (128, 192, or 256 bits).
[0073] Prior to executing each cycle encryption operation or decryption operation, the execution unit 210 receives the body and key stored in the register file 304. Each encryption / decryption cycle operation is performed using micro-operations of the AES instructions stored in the key scheduler 302 of the read-only memory (ROM) 214. In the illustrated embodiment, the body (a block of 128 bits) is stored in registers 306, and the key is stored in one or more other registers 308 of the register file 304. After completing the execution of the AES instruction, the resulting body is stored in registers 306 of the register file 304. The body can be mid-cycle data used by the next AES cycle, or the final result of an AES encryption or decryption operation.
[0074] In the illustrated embodiment, the key scheduler 302 generates a round key for use in an AES round. The key scheduler 302 may be implemented as a plurality of microcode operations and may include microcode operations for performing a sequence of operations for generating round keys for 128-bit, 197-bit, and 256-bit keys as defined in FIPS document 197.
[0075] In another embodiment, the key scheduler may be implemented as a sequence of hardware state machines in execution unit 210. In another embodiment, some portions of the key scheduler may be implemented as microcode operations stored in microcode ROM 214 and the remainder of the key scheduler may be implemented as a sequence of hardware state machines in execution unit 210.
[0076] The key scheduler 302 expands the n bytes of the key into b bytes of an extended key (key schedule), where the first n bytes of the extended key are the original key. For example, for a 128-bit key, the 128-bit key is expanded to an extended key of 176 bytes, i.e., 11x16 bytes (128 bits), where the first 16 bytes are the original 128-bit key, so the number of cycles is 10. The 24 bytes of a 192-bit key are expanded to 208 bytes (13x16 bytes) to provide 12 "round keys", each for one of the 12 cycles, and the 32 bytes of a 256-bit key are expanded to 240 bytes (15x16 bytes) to provide 14 "round keys", each for one of the 14 cycles.
[0077] After decoding the operation code (opcode) in the AES instruction, a number of parameters used to control the flow in the AES instruction for one AES cycle are stored in the control logic 322. These parameters include the type of operation (encryption or decryption) and whether the cycle is the last cycle.
[0078] AES round logic 324 may include micro-operations for the following stages: block 314 , S-box / inverse S-box 316 , shift row 316 and mix inverse, mix column or null (referred to as “mix column”) 320 , and add round key 326 .
[0079] In block 314, the 128-bit input (body) to the AES round logic 324 is added with the key (the 128-bit portion of the extended key associated with that round) using a bitwise XOR to produce a 128-bit intermediate value (body).
[0080] In the S-box / inverse S-box 316, each byte of the 128-bit intermediate value is replaced with another byte value that may be stored in and retrieved from a lookup table, also referred to as a substitution box or "S-Box". An S-box takes some number of input bits m and converts it to some number of output bits n, and is typically implemented as a lookup table. A fixed lookup table is typically used. By using a Galois Field (GF) (2 8 ), which provides nonlinearity. For example, an n-bit output can be found by selecting a row in a lookup table using the outer two bits of an m-bit input and selecting a column using the inner bits of the m-bit input.
[0081] In shift row 318, the result of S-box / inverse S-box 316 is transformed by bit linearization, wherein the bytes in each row of the 4x4 array (a body of 128 bits (16 bytes)) received from the replace byte stage are circularly shifted to the left. For each row in the 4x4 array, the number of bits shifted for each byte is different.
[0082] In the mix column 320, the results from the shift row 320 are transformed bit-linearly, where each column in the 4x4 array (volume) is treated as a binary Galois Field (GF) (2 8 ) and then compare it with the fixed polynomial c(x)=3x 3 +x 2 +x+2 multiplication and x 4 +1 modulo. The last AES cycle differs from the others in that the mix column 320 is omitted.
[0083] For this AES round, the add round key 324 following the mix column stage 320 performs an XOR function on the round key from the expanded key and the result of the shift row 318 or mix column 320 .
[0084] For example, the following AES instructions can be issued to perform one cycle of AES decryption:
[0085] AESDECRYPTRound xmmsrcdst xmm
[0086] This example uses a key to perform a 128-bit AES encryption round operation, where the extended key of the key is represented by (RK[1], RK[2], ... RK
[10] ). The round key can be generated by issuing an AESPreviousRoundKey xmmsrc 1,2xmm dst(immediate) instruction before issuing an AES decryption round (AESDECRYPTRound) instruction. The round key can be loaded directly into the block 314 from the level 1 data cache 204, or the round key can be first stored in a register (xmm) of the register file 304 and then loaded from the register into the block 314.
[0087] When a different key is used to encrypt / decrypt each block, for example, for a network interface controller (NIC) for encrypting / decrypting data packets, the round key for each round can be dynamically calculated before performing encryption / decryption, as shown in the pseudo code for AES-128 encryption in Table 3 below:
[0088]
[0089] Table 3
[0090] In this example, before the round key is used for each of the 10 rounds (ie, rounds 1-9 and round 10 (the last round)) of the key schedule (expanded key) to perform encryption, the round key for that round is generated.
[0091] The AES instruction set including the single AES loop instruction and the single AES loop key generation instruction allows variations of AES with different numbers of loops and key schedules, i.e., variations of AES not defined by FIPS document 197. Therefore, the single loop AES instruction in the AES instruction set provides flexibility in performing AES encryption and decryption.
[0092] Since the number of loops executed by the AES instruction set is not fixed, any number of loops can be executed if necessary. For example, if a new standard for hash or MAC attacks or AES attacks is introduced, the number of loops can be changed to support future encryption / decryption standards.
[0093] Figure 4 It is shown by Figure 3 Flowchart of the AES encryption loop instruction flow of execution unit 210 is shown in FIG.
[0094] At block 400, the execution unit 210 waits for an AES encryption loop instruction. If the fetch and decode unit 206 has already decoded the AES encryption loop instruction, processing continues to block 402. If the fetch and decode unit 206 has not yet decoded the AES encryption loop instruction, processing remains in block 400, waiting for the AES encryption loop instruction.
[0095] At block 402, during instruction decoding by the fetch and decode unit 206, an indication that encryption is to be performed is stored in the control logic 322, and the round key and 128-bit block (source) used in executing the encryption round are loaded from the register file 304 into the execution unit 210. Processing continues to block 404.
[0096] At block 404, a substitution operation is performed on a 128-bit block, i.e., the result from block 406 or 418. Each byte of the 128-bit block is replaced with other byte values that can be stored in and retrieved from a lookup table, which is also referred to as a substitution box or "S-Box". An S-box takes some number of input bits m and converts them into some number of output bits n, and is typically implemented as a lookup table. The result is stored as a 128-bit block. Processing continues to block 406.
[0097] At block 406, the 128-bit block (4x4 array) is bit-linearly transformed, where the bytes in each row of the 4x4 array are cyclically shifted to the left. For each row in the 4x4 array, the number of bits shifted for each byte is different. Processing continues to block 408.
[0098] At block 408, the 128-bit block (4x4 array) is bit-linearly converted, wherein each column in the 4x4 array (block) is treated as GF(2 8 ) and then compare it with the fixed polynomial c(x)=3x 3 +x 2 +x+2 multiplication and x 4 +1 modulo. Processing continues to block 410.
[0099] At block 410, for this AES round, an XOR function is performed on the round key from the expanded key and the result of shifting the row 318 or mixing the column 320. Processing continues to block 412.
[0100] At block 412, the results of the encryption operation for that cycle (128-bit blocks) are stored in the source / destination registers 302 of the register file 304. Processing for the AES encryption instruction ends.
[0101] Table 4 below shows an example of the result of performing AES-128 encryption on a 128-bit block input using a 128-bit key after executing the pseudo code shown in Table 3.
[0102] 128-bit input: 00112233445566778899aabbccddeeff (hexadecimal)
[0103] 128-bit key: 000102030405060708090a0b0c0d0e0f (hexadecimal)
[0104] 128-bit result: 69c4e0d86a7b0430d8cdb78070b4c55a (hexadecimal)
[0105] Table 4
[0106] Figure 5 It is shown by Figure 3 FIG. 4 is a flowchart of the instruction flow of the last cycle of AES encryption of the execution unit 210 shown in FIG.
[0107] At block 500, the execution unit waits for the AES encrypted last loop instruction. If the fetch and decode unit 206 has already decoded the AES encrypted last loop instruction, processing continues to block 502. If the fetch and decode unit 206 has not yet decoded the AES encrypted last loop instruction, processing remains in block 500, waiting for the AES instruction.
[0108] At block 502, in conjunction with block 404 ( Figure 4 ) is performed in a similar manner to the S-box query discussed above. Processing continues to block 504.
[0109] At block 504, combined with block 406 ( Figure 4 The shift row operation of the last cycle is performed in a similar manner as discussed for the other cycles of ). Processing continues to block 506.
[0110] At block 506, for this AES round, an XOR function is performed on the round key from the expanded key and the result of shifting the row 318 or mixing the column 320. Processing continues to block 508.
[0111] At block 508, the result of the encryption last cycle operation is stored in the source / destination registers 306 of the register file 304. The process for the AES instruction ends.
[0112] Figure 6 It is shown by Figure 3Flowchart of the AES decryption loop instruction flow of execution unit 210 is shown in FIG.
[0113] At block 600, the execution unit waits for an AES decryption loop instruction. If the fetch and decode unit 206 has already decoded the AES decryption loop instruction, processing continues to block 602. If the fetch and decode unit 206 has not yet decoded the AES decryption loop instruction, processing remains in block 600, waiting for the AES decryption loop instruction.
[0114] At block 602, during instruction decoding by the fetch and decode unit 206, an indication that decryption is to be performed is stored in the control logic 322, and the round key and source (in 128-bit chunks) used in executing the decryption round are loaded from the register file 304 into the execution unit 210. Processing continues to block 604.
[0115] At block 604, the operation to be performed is decryption. A substitution operation is performed on the 128-bit block by performing an inverse S-box lookup as defined by the AES standard. Processing continues to block 606.
[0116] At block 606, an inverse shift row operation is performed as defined in FIPS document 197. Processing continues to block 608.
[0117] At block 608, an inverse shift row operation is performed as defined in FIPS document 197. Processing continues to block 610.
[0118] At block 610, for an AES round, an XOR function is performed on the round key from the expanded key and the result of shifting the row 318 or mixing the column 320. Processing continues to block 612.
[0119] At block 612, the results (128-bit blocks) of the decryption operation for the loop are stored in the source / destination registers 302 of the register file 304. Processing for the AES decryption loop instruction ends.
[0120] Figure 7 It is shown by Figure 3 FIG. 4 is a flowchart of the instruction flow of the last cycle of AES decryption of the execution unit 210 shown in FIG.
[0121] At block 700, the execution unit 210 waits for the AES decryption last loop instruction. If the fetch and decode unit 206 has already decoded the AES decryption last loop instruction, processing continues to block 702. If the fetch and decode unit 206 has not yet decoded the AES decryption last loop instruction, processing remains in block 700, waiting for the AES decryption last loop instruction.
[0122] At block 702, the last cycle of substitution operations is performed on the 128-bit block by performing an inverse S-box lookup as defined by FIPS document 197. Processing continues to block 704.
[0123] At block 704, an inverse shift row operation is performed for the last cycle as defined in FIPS document 197. Processing continues to block 706.
[0124] At block 706, for an AES round, an XOR function is performed on the round key from the expanded key and the result of shifting the row 318 or mixing the column 320. Processing continues to block 708.
[0125] At block 708, the result of the decrypt last cycle operation is stored in the source / destination registers 306 of the register file 304. The process for the AES decrypt last cycle instruction ends.
[0126] In one embodiment, Figure 4-Figure 7 The blocks in the flowchart of can be implemented as a sequence of hardware state machines in the execution unit 210. In another embodiment, part of the blocks can be implemented as a microprogram that can be stored in a read-only memory (ROM) 214. The embodiment in which the blocks are implemented as a sequence of hardware state machines can provide higher performance.
[0127] Figure 8 An embodiment of an AES loop instruction with an immediate byte that can be used to generate a loop key and perform encryption and decryption is shown. Instead of the AES instruction set shown in Table 1, a single AES loop instruction for performing the functions of the AES instruction set is provided. The specific function performed by the single AES instruction is encoded in the bits of the immediate byte (key_select_modifier). The immediate byte allows the AES loop instruction to be extended to add new features, instead of creating multiple new instructions each with a unique opcode.
[0128] The AES loop instructions can be symbolically defined as:
[0129] dest:=AES_key_round(source2,source 1),key_select_modifier
[0130] According to the port number, the AES_key_round instruction is sent to a specific execution unit 210 to perform an AES encryption or decryption operation. In the illustrated embodiment, port number 4 is a designated execution port for the AES round instruction. The execution unit 210 is divided into a plurality of parallel ports (superscalar). However, not all ports are equal. Some ports have specific resources, such as: large integer multipliers or floating point multipliers or dividers. Simpler and more common instructions, such as addition, subtraction and XOR, are supported at multiple ports to maximize performance. Therefore, for each instruction or micro-operation, the issuing control logic determines the port for issuing micro-operation / instruction. In this embodiment, the AES instruction is always sent to port number 4. However, in other embodiments, other port numbers can be used.
[0131] refer to Figure 8 , the destination field (dest) stores the 128-bit extended key for round N, the source 2 (source2) field stores the 128-bit extended key for round N-1, and the source 1 (source1) field stores the 128-bit extended key for round N-2. key_select_modifier is an 8-bit immediate value that provides the current round number (N), the direction of operation (encryption / decryption), and the AES key length. For AES-128, source1 is not required and can be omitted. The execution unit is an AES unit and does not use flags (integer or floating point).
[0132] In one embodiment, the bit encoding of the four least significant bits of the immediate value indicates the number of cycles, for example, cycle numbers 1-10 for AES-128, cycle numbers 1-12 for AES-192, and cycle numbers 2-14 for AES-256. For AES-128 and AES-192, cycle number 0 is invalid because the first cycle uses the unmodified input key. For AES-256, cycle numbers 0 and 1 are invalid because the unmodified 256-bit input key is used for the first two 128-bit cycles.
[0133] Bit 4 of the immediate byte indicates the direction of operation (encryption or decryption), for example, in one embodiment, 0=encryption and 1=decryption, and in another embodiment, 1=encryption and 0=decryption. Bits 5 and 6 of the immediate byte indicate the AES key length. In one embodiment, the AES key length is defined as shown in Table 5 below:
[0134]
[0135] Table 5
[0136] In another embodiment, bits [6:5] with a value of 11 are also an indicator of a 128-bit key length. In this embodiment, all values of bits [6:5] are valid and can be interpreted.
[0137] Those skilled in the art will appreciate that the methods involved in embodiments of the present invention may be implemented in a computer program product including a computer-usable medium. For example, such a computer-usable medium may include a read-only memory device, such as a compact disk read-only memory (CD-ROM) disk or a conventional ROM device, or a computer floppy disk storing computer-readable program code.
[0138] While embodiments of the invention have been particularly shown and described with reference to embodiments thereof, it will be understood by those skilled in the art that various changes in form and details may be made therein without departing from the scope of the embodiments of the invention as defined in the following claims.
Claims
1. A method for processing data, include: decoding a single-cycle encryption instruction to perform an Advanced Encryption Standard (AES) single-cycle encryption operation, wherein the single-cycle encryption instruction is from an AES instruction set, the instruction set including separate AES instructions for performing an encryption cycle, a decryption cycle, an encryption last cycle, a decryption last cycle, and for calculating an encryption cycle key or a decryption cycle key, wherein the single-cycle encryption instruction specifies a destination register for storing input data and a source register for storing a cycle key, wherein the destination register is a 128-bit register, the source register is a 128-bit register, and the input data is a 128-bit value, and the cycle key is a 128-bit value; and The decoded single-round encryption instruction is executed, wherein an execution unit is configured to receive the input data and the round key, and wherein the execution unit is configured to perform the AES single-round encryption operation on the input data using the round key and store result data in the destination register.
2. The method according to claim 1, in, The specified destination register is also the source register.
3. The method according to any one of claims 1 to 2, in, Executing the decoded single-loop encryption instruction to perform the AES single-loop encryption operation includes: replacing bytes of the input data to generate a first intermediate value; shifting a row of the first intermediate values to generate second intermediate values; blending the columns of the second intermediate values to generate a third intermediate value; The third intermediate value and the round key are XORed.
4. A computer readable medium having associated instructions, wherein the instructions, when executed, cause a computer to perform the steps of the method of any one of claims 1 to 3.
5. A device for processing data, include: Register file; a fetch and decode unit for decoding a single-cycle encryption instruction, wherein the single-cycle encryption instruction is from an AES instruction set, the instruction set including separate AES instructions for performing an encryption cycle, a decryption cycle, an encryption last cycle, a decryption last cycle, and for calculating an encryption cycle key or a decryption cycle key, wherein the single-cycle encryption instruction specifies a destination register in the register file to store input data and specifies a source register in the register file to store a cycle key, wherein the destination register is a 128-bit register, the source register is a 128-bit register, and the input data is a 128-bit value, and the cycle key is a 128-bit value; An execution unit, configured to execute the decoded single-cycle encryption instruction to perform an Advanced Encryption Standard AES single-cycle encryption operation; The execution unit is configured to receive the input data and the round key, and the execution unit is configured to perform the AES single-round encryption operation on the input data using the round key and store result data generated by executing the single-round encryption instruction in the destination register.
