AES Advanced Encryption Standard
Advanced Encryption Standard Adopted by National Institute of Standards and Technology (NIST) on May 26, AES is a simple design, a high speed algorithm, with low memory costs. AES is a symmetric block cipher. –The same key is used to encrypt and decrypt the message. –The plain text and the cipher text are the same size.
AES Block AES has a fixed block size of 128 bits called a state ABCDEFGHIJKLMNOP A E I M D B F J N A 4E C G K O B 4F D H L P C 50 (ASCII)
AES Key AES key is either 128 bits, 192 bits or 256 bits 128 bits (4 words): AA BB CC DD EE FF AA BB CC DD EE FF
AES Key or 192 bits (6 words) AABBCCDDEEFF AA BB CC DD EE FF or 256 bits (8 words) AABBCCDDEEFF AABBCCDDEEFF AA BB CC DD EE FF AA BB CC DD EE FF
Comparisons
Security The key security feature is the size of the key. Assuming that one could build a machine that could recover a DES key in a second (i.e., try 2 55 keys per second), then it would take that machine approximately 149 thousand-billion (149 trillion) years to crack a 128-bit AES key. To put that into perspective, the universe is believed to be less than 20 billion years old. Accepting Moore's Law, doubling processor speed every 18 months, AES will be secure for another years.
AES Operations AES Operates on the binary field GF(2 8 ). –This can be represented as a polynomial b(x) with binary coefficients b {0,1}: b 7 x 7 + b 6 x 6 + b 5 x 5 + b 4 x 4 + b 3 x 3 + b 2 x 2 + b 1 x + b 0 Multiplication in GF(2 8 ) consists of multiplying two polynomials modulo an irreducible polynomial of degree 8. –AES uses the following irreducible polynomial m(x) = x 8 + x 4 + x 3 + x + 1
AES Algorithm
AES Algorithm Key Expansion –Sample Key: AABBCCDDEEFF The first 4 (N k ) words are set equal to the key w[0] w[1] w[2] 9900AABB w[3] CCDDEEFF
AES Algorithm Key Expansion For words 4 through 43 i = N k // N k = 4 while (i < N b *(N r +1)) { // N b *(N r +1)= 4*(10+1)= 44 temp = w[ i – 1 ] If ( i%N k == 0 ) rotate word left 1 byte process each byte through sbox XOR with RCON[i/N k -1] // just first byte of w[i] w[ i ] = w[ i-4 ] XOR temp i++}
i = N k // N k = 4 while (i < N b *(N r +1)) { // N b *(N r +1)= 4*(10+1)= 44 temp = w[ i - 1 ] AES Algorithm Key Expansion w[0] w[1] w[2] 9900AABB w[3] CCDDEEFF i = 4 temp = w[3] = CC DD EE FF
AES Algorithm Key Expansion If ( i%N k == 0 ) rotate word left 1 byte process each byte through sbox XOR with RCON[i/N k -1] temp = CC DD EE FF temp = DD EE FF CC temp = sbox[DD] sbox[EE] sbox[FF] sbox[CC] = C B RCON[0] = 01 temp = (C1 01) B temp = C B
rCon – round Constants rCon can be implemented with a look-up-table 2 i in GF(2 8 ) Removes symmetry and linearity from key expansion.
AES Algorithm Key Expansion For words 4 through 43 i = N k // N k = 4 while (i < N b *(N r +1)) {// N b *(N r +1)= 4*(10+1)= 44 temp = W[i-1] If (i%N k == 0) rotate word left 1 byte process each byte through sbox XOR with RCON[i] // just first element of w w[i] = w[i-4] XOR temp i++} i = 4 temp = C B w[i] = w[i-4] XOR temp
AES Algorithm Key Expansion i = 4 temp = C B w[i] = w[i-4] XOR temp w[0] w[1] w[2] 9900AABB w[3] CCDDEEFF w[4] = (11 C0) (22 28) (33 16) (44 4B) w[4] = D1 0A 25 0F w[4] D1 0A 25 0F
AES Algorithm Key Expansion For words 4 through 43 i = N k // Nk = 4 i = 5 while (i < N b *(N r +1)) { // N b *(N r +1)= 4*(10+1)= 44 temp = w[i-1] If (i%N k == 0) rotate word left 1 byte process each byte through sbox XOR with RCON[i/N k -1] // just first element of W w[i] = w[i-4] XOR temp i++} temp = w[4] = D1 0A 25 0F
AES Algorithm Key Expansion i = 5 temp = D1 0A 25 0F w[i] = w[i-4] XOR temp w[0] w[1] w[2] 9900AABB w[3] CCDDEEFF w[5] = (55 D1) (66 0A) (77 25) (88 0F) w[4] D1 0A 25 0F w[5] = 84 C
AES Algorithm
AES Algorithm AddRoundKey State Expanded Key w[0] w[4] After AddRoundKey
AES Algorithm
AES Algorithm SubBytes SubBytes is the SBOX for AES This make AES a non-linear cryptographic system. For every value of b there is a unique value for b –It is faster to use a substitution table (and easier). x is the inverse value of the byte b + =
AES Algorithm SubBytes
State
AES Algorithm
AES Algorithm ShiftRows Simple routine which performs a left shift rows 1, 2 and 3 by 1, 2 and 3 bytes respectively Before Shift RowsAfter Shift Rows
AES Algorithm
AES Algorithm - MixColumns This with shift rows provides diffusion The columns are considered polynomials over GF(2 8 ) and multiplied modulo x 4 +1 with a(x) where a(x) = {03}x 3 + {01}x 2 + {01}x + {02} NOTE: x 4 +1 is relatively prime to a(x) a j (a j *a(x))mod(x 4 +1) This can also be written as matrix multiplication a0a0 a1a1 a2a2 a3a3 a 0 a 1 a 2 a 3 =
AES Algorithm - MixColumns a0a0 a1a1 a2a2 a3a3 a 0 a 1 a 2 a 3 = a 0 = 2a 0 + 3a 1 + a 2 + a 3 a 1 = a 0 + 2a 1 + 3a 2 + a 3 a 2 = a 0 + a 1 + 2a 2 + 3a 3 a 3 = 3a 0 + a 1 + a 2 + 2a 3 Addition is easy in GF(2 8 ) : Addition is just the XOR operation Multiplication by 1 is easy in GF(2 8 ) : Multiplication by one is the identity Multiplication by 2 in GF(2 8 ) takes some work:. If multiplying by a value < 0x80 just shift all the bits left by 1. If multiplying by a value 0x80 shift left by 1 and XOR with 0x1b. This prevents overflow and keeps the values within range To Multiply by 3 in GF(2 8 ) : a * 0x03 = a * (0x02 + 0x01) = (a * 0x02) (a * 0x01) a 0 = 2a 0 3a 1 a 2 a 3 a 1 = a 0 2a 1 3a 2 a 3 a 2 = a 0 a 1 2a 2 3a 3 a 3 = 3a 0 a 1 a 2 2a 3
AES Algorithm KeyExpansion(byte key[4*Nk], word w[Nb*(Nr+1)],Nk) Cipher(byte in[4*Nb],byte out[4*Nb],word w[Nb*(Nr+1)]) begin byte state[4,Nb] state = in AddRoundKey(state, w[0, Nb-1]) for round = 1 step 1 to Nr–1 SubBytes(state) ShiftRows(state) MixColumns(state) AddRoundKey(state,w[round*Nb,(round+1)*Nb-1]) end for SubBytes(state) ShiftRows(state) AddRoundKey(state, w[Nr*Nb, (Nr+1)*Nb-1]) out = state end
Sample Conversions
AES Algorithm AddRoundKey SubBytes ShiftRows MixColumns AddRoundKey SubBytes ShiftRows AddRoundKey 1 st Round Repeat N r -1 Round Last Round AddRoundKey InvShiftRows InvSubBytes AddRoundKey InvMixColumns InvShiftRows InvSubBytes AddRoundKey 1 st Round Repeat N r -1 Round Last Round PlainText Cipher Text Plain Text EncryptionDecryption RoundKey * RoundKey RoundKey * * RoundKey Added in reverse order
Larger Plain Texts How to avoid frequency analysis? Cipher Block Chaining
Padding If plaintext messages are not divisible by 16 bytes. Padding may be a solution. An easy method is to add a single 1 bit at the end of the message followed by enough 0s to fill the block. –If the block is filled, encode one more block with a 1 followed by 0s.
Attacks on AES Differential Cryptanalysis – Study of how differences in input affect differences in output. –Greatly reduced due to high number of rounds. Linear Cryptanalysis – Study of correlations between input and output. –SBOX & Mix Columns are designed to frustrate Linear Analysis
Attacks on AES Side Channel Attacks – Attacks based on studying and measuring the actual implementation of the code. –For some implementations of AES the key has been obtained in under 100 minutes. Computer running AES was 850MHz, Pentium III running FreeBSD 4.8
Types of Side Channel Attacks Timing Attacks – Watches movement of data in and out of the CPU or memory. –It is difficult to retrieve an array element in a time that is not dependent on the index value. Power Attacks – Watches power consumption by CPU or memory. –Changing one bit requires considerably less power than changing all bits in a byte.
Attack Precautions Avoid use of arrays. Compute values in SBOX and rCon. Design algorithms and devices to work with constant time intervals. (independent of key and plaintext.) –Hidden CPU timing data is a threat. Use same memory throughout, Cache is faster than DRAM Compute Key Expansion on the fly. Utilize pipelining to stabilize CPU power consumption.
Joan Daemen & Vincent Rijmens AES Selling Points Extremely fast compared to other block ciphers. (tradeoff between size and speed) The round transformation is parallel by design. Important in dedicated hardware. Amenable to pipelining The cipher does not use arithmetic operations so has no bias towards big or little endian architectures.
Joan Daemen & Vincent Rijmens AES Selling Points Fully Self-supporting. Does not use Sboxes of other ciphers, bits from Rand tables, digits of or any other such jokes. Is not based on obscure or not well understood processes The tight cipher design does not leave enough room to hide a trap door.
Joan Daemen & Vincent Rijmens AES Limitations The inverse cipher is less suited to smart cards, as it takes more codes and cycles. The cipher and inverse cipher make use of different codes and/or tables. In hardware, The inverse cipher can only partially re-use circuitry which implements the cipher.
References About AES AES Proposal : Rijndael Joan Daemen, Vincent Rijmen, 2nd version of document to NIST Polynomials in the Nations Service: Using Algebra to Design the Advanced Encryption Standard Susan Landau The Mathmatical Association of America, Monthly 111 Feb 2004 Page(s): Selecting the Advanced Encryption Standard Burr, W.E.; Security & Privacy Magazine, IEEE Volume 1, Issue 2, Mar-Apr 2003 Page(s): Title: Introduction to Cryptography Author: Johannes A Buchman Publisher: Springer; 2 edition (July 13, 2004)
References Security and Attacking AES Power-analysis attack on an ASIC AES implementation Ors, S.B.; Gurkaynak, F.; Oswald, E.; Preneel, B.;Information Technology: Coding and Computing, Proceedings. ITCC International Conference onVolume 2, 2004 Page(s): Vol.2 Algebraic attacks on cipher systems Penzhorn, W.T.; AFRICON, th AFRICON Conference in Africa Volume 2, 2004 Page(s): Vol.2 Cache-Timing attacks on AES Daniel J Bernstein Preliminary version of report to National Science Foundation, grant CCR
References Applications / Implementations: AES A high throughput low cost AES processor Chih-Pin Su; Tsung-Fu Lin; Chih-Tsiun Huang; Cheng-Wen Wu; Communications Magazine, IEEE Volume 41, Issue 12, Dec Page(s): An efficient FPGA implementation of advanced encryption standard algorithm Shuenn-Shyang Wang; Wan-Sheng Ni; Circuits and Systems, ISCAS '04. Volume 2, May 2004 Page(s):II Vol.2 High-speed VLSI architectures for the AES algorithm Xinmiao Zhang; Parhi, K.K.; Very Large Scale Integration (VLSI) Systems Volume 12, Issue 9, Sept Page(s):957 – 967 Fast implementation of AES cryptographic algorithms in smart cards Chi-Feng Lu; Yan-Shun Kao; Hsia-Ling Chiang; Chung-Huang Yang; Security Technology, Oct Page(s):
References Applications / Implementations : AES A new VLSI implementation of the AES algorithm Liang Deng; Hongyi Chen; Communications, Circuits and Systems and West Sino Expositions, IEEE 2002 International Conference on Volume 2, 29 June-1 July 2002 Page(s): vol.2