<<

International Journal of Scientific & Research Volume 3, Issue 3, March -2012 1 ISSN 2229-5518 Implementation of Advanced Standard

M.Pitchaiah, Philemon Daniel, Praveen

Abstract—Cryptography is the study of mathematical techniques related to aspects of security such as , data integrity, entity and data origin authentication. In data and telecommunications, cryptography is necessary when communicating over any unreliable medium, which includes any network particularly the . In this paper, a 128 AES encryption and Decryption by using Rijndael algorithm (Advanced Encryption Standard algorithm) is been made into a synthesizable using Verilog which can be easily implemented on to FPGA. The algorithm is composed of three main parts: , inverse cipher and Expansion. Cipher converts data to an unintelligible form called . Key Expansion generates a that is used in cipher and inverse cipher procedure. Cipher and inverse cipher are composed of special number of rounds. For the AES algorithm, the number of rounds to be performed during the execution of the algorithm uses a round function that is composed of four different byte-oriented transformations: Sub Bytes, Shift Rows, Mix columns and Add Round Key.

Index Terms—Advanced Encryption Standard, Cryptography, Decryption, Encryption.

I. INTRODUCTION standard explicitly defines the allowed values for the key T HE Cryptography plays an important role in the security of length (Nk), block size (Nb), and number of rounds (Nr). data transmission [1]. This paper addresses efficient hardware B. AES Algorithm Specification implementation of the AES (Advanced Encryption Standard) algorithm and describes the design and performance testing of For the AES algorithm, the length of the input block, the Rijndael algorithm [3]. A strong focus is placed on high output block and the State is 128 . This is represented by throughput implementations, which are required to support Nb = 4, which reflects the number of 32-bit words (number of security for current and future high bandwidth applications columns) in the State. [5][6][7][8][9]. This implementation will be useful in wireless security like military and mobile telephony where there is a gayer emphasis on the speed of communication [5]. This standard specifies the Rijndael algorithm, a symmetric that can process data blocks of 128 bits, using cipher keys with lengths of 128,192, and 256 bits [2]. Throughout the remainder of this standard, the algorithm specified herein will be referred to as ―the AES algorithm.‖ The algorithm may be used with the three different key lengths indicated above, and therefore these different ―flavors‖ may be referred to as ―AES-128‖, ―AES- 192‖, and ―AES-256‖. A. AES Algorithm AES is short for Advanced Encryption Standard and is a encryption standard defined in Federal

Information Processing Standard (FIPS) 192. AES is the most Fig 1: General structure of AES algorithm recent of the four current approved for federal us in the United States. AES is a symmetric encryption algorithm An implementation of the AES algorithm shall support at least processing data in block of 128 bits. AES is one of the three key lengths: 128, 192, or 256 bits (i.e., Nk = 4, 6, symmetric since the same key is used for encryption and the or 8, respectively). Implementations may optionally support reverse transformation, decryption [2]. The only secret two or three key lengths, which may promote the necessary to keep for security is the key. AES may configured interoperability of algorithm implementations. For the AES to use different key-lengths, the standard defines 3 lengths algorithm, the length of the Cipher Key, K, is 128, 192 or 256 and the resulting algorithms are named AES-128, AES-192 bits. The key length is represented by Nk = 4, 6, or 8which and AES-256 respectively to indicate the length in bits of the reflects the number of 32-bit words (number of columns) in key. The older standard, DES or . the Cipher Key. For the AES algorithm, the number of rounds DES is upto 56bits only [4]. To overcome the disadvantages of to be performed during the execution of the algorithm is des algorithm, the new standard is AES algorithm. This dependent on the . The number of rounds is represented by Nr, where Nr = 10 when Nk = 4, Nr = 12 when

IJSER © 2012 http://www.ijser.org

International Journal of Scientific & Engineering Research Volume 3, Issue 3, March -2012 2 ISSN 2229-5518 Nk = 6, and Nr = 14 when Nk = 8. The only Key-Block-Round  Mix Columns—a mixing operation which operates on combinations that conform to this standard are given in Table the columns of the state, combining the four bytes in 1. each column

Bit Key Length Block Size No Of  Add Round Key—each byte of the state is combined pattern (NK Words) (NB Words) Rounds with the round key; each round key is derived from (NR Words) the cipher key using a key schedule AES- 4 4 10 B. Sub bytes Transformation 128 AES- 6 4 12 The Sub Bytes transformation is a non-linear byte substitution 192 that operates independently on each byte of the State using a AES- 8 4 14 substitution table (S-box). This S-box which is invertible is 256 constructed by composing two transformations: 1. Take the multiplicative inverse in the finite GF (28), the Table 1. Key-Block-Round Combinations. element {00} is mapped to itself. 2. Apply the following affine transformation (over GF (2)): For both its Cipher and Inverse Cipher, the AES algorithm For 0

II. ENCRYPTION In encryption mode, the initial key is added to the input value at the very beginning, which is called an initial round. This is followed by 9 iterations of a normal round and ends with a slightly modified final round, as one can see in Figure 2. During one normal round the following operations are performed in the following order: Sub Bytes, Shift Rows, Mix Columns, and Add Round key. The final round is a normal round without the Mix Columns stage. Fig 3: Affine transformation

63 7C 77 7B CA 82 C9 7D B7 FD 93 26 04 C7 23 C3

Fig 4: S-BOX

Fig 2: General structure of Encryption.

A. Steps in AES Encryption  Sub Bytes—a non-linear substitution step where each Fig.5 Effect of the Sub Bytes () transformation on the State. byte is replaced with another according to a lookup table.

 Shift Rows—a transposition step where each row of C. Shift Rows Transformation the state is shifted cyclically a certain number of steps. In the Shift Rows transformation, the bytes in the last three rows of the State are cyclically shifted over different numbers

IJSER © 2012 http://www.ijser.org

International Journal of Scientific & Engineering Research Volume 3, Issue 3, March -2012 3 ISSN 2229-5518 of bytes (offsets). The first row is not shifted at all, the second row is shifted by one the third row by two, and the fourth row by three bytes to the left. Specifically, the Shift Rows transformation proceeds as follows: E. Add round Key Transformation The shift value shift(r,Nb) depends on the row number, r, as In the Add Round Key transformation, a Round Key is added to follows (recall that Nb = 4): shift(1,4) 1; shift(2,4) 2 ; shift(3,4) 3 the .This has the effect of moving bytes to ―lower‖ positions in the State by a simple bitwise XOR operation. Each Round Key row (i.e., lower values of c in a given row), while the ―lowest‖ consists bytes wrap around into the ―top‖ of the row (i.e., higher of Nb words from the key schedule.Those Nb words are each values of c in a given row) added into the columns of the State, such that [wi] are the key schedule words, and round is a value in the range 0 round Nr. In the Cipher, the initial Round Key addition occurs when round = 0, prior to the first application of the round function. The application of the Add Round Key transformation to the Nr rounds of the Cipher

occurs Fig.6 .Shift Rows cyclically shifts the last three rows in the when 1

D. MixColumns Transformation The Mix Columns transformation operates on the State column-by-column, treating each column as a four-term polynomial. ' s0,c  02 03 01 01 s0,c   '    s 01 02 03 01 s  1,c      1,c   '    s2,c 01 01 02 03 s2,c       ' s3,c  03 01 01 02 s3,c    Fig.8. AddRoundKey XORs each column of the State with a word from the key schedule.

(0  c < Nb)

As a result of this multiplication, the four bytes in a column F. Key Expansion are replaced by the following: The AES algorithm takes the Cipher Key, K, and performs a Key Expansion routine to generate a key schedule. The Key  S’0,c = ({02} • s0,c) + ({03} • s1,c) + s2,c + s3,c Expansion generates a total of Nb (Nr + 1) words: the  S’1,c = s0,c + ({02} • s1,c) + ({03} • s2,c) + s3,c algorithm requires an initial set of Nb words, and each of the Nr rounds requires Nb words of key data. The resulting key  S’2,c = s0,c + s1,c + ({02} • s2,c) + ({03} • s3,c) schedule consists of a linear array of 4-byte words, denoted  S’3,c = ({03} • s0,c) + s1,c + s2,c + ({02} • s3,c) [wi ], with i in the range 0 < i < Nb(Nr + 1). The expansion of the input key into the key schedule proceeds according to the pseudo code. SubWord is a function that takes a four-byte input word and applies the S-box to each of the four bytes to produce an output word. The function Rot Word takes a word [a0,a1,a2,a3] as input, performs a cyclic , and returns the word [a1,a2,a3,a0]. The round constant word array, Rcon[i], contains the values given by [xi-1,{00},{00},{00}], with x i-1 being powers of x (x is denoted as {02}) in the field GF(28). The first Nk words of the expanded key are filled with Fig.7. Mix Columns operates on the State column-by-column. the Cipher Key. Every following word, w[i], is equal to the

IJSER © 2012 http://www.ijser.org

International Journal of Scientific & Engineering Research Volume 3, Issue 3, March -2012 4 ISSN 2229-5518 XOR of the previous word, w[i-1], and the word Nk positions shifted by Nb - shift(r, Nb) bytes, where the shift value earlier, w[i-Nk]. For words in positions that are a multiple of shift(r,Nb) depends on the row number. Nk, a transformation is applied to w[i-1] prior to the XOR, followed by an XOR with a round constant, Rcon[i]. This transformation consists of a cyclic shift of the bytes in a word (RotWord), followed by the application of a table lookup to all four bytes of the word (SubWord). It is important to note that the Key Expansion routine for 256-bit Cipher Keys (Nk = 8) is slightly different than for 128- and 192-bit Cipher Keys. If Nk = 8 and i-4 is a multiple of Nk, then SubWord () is applied to w [i-1] prior to the XOR.

Fig.11.InvShiftRows transformation B. Inv Subbytes Transformation InvSubBytes is the inverse of the byte substitution transformation, in which the inverse Sbox is applied to each byte of the State. This is obtained by applying the inverse of the affine transformation followed by taking the multiplicative inverse in GF (28).The inverse S-box used in the InvSubBytes () transformation is presented in Fig 12.

52 09 6A D5 7C E3 39 82

Fig.9.key expansion 54 7B 94 32 08 2E A1 66

III. DECRYPTION Fig 12: Inverse S-BOX In decryption mode, the operations are in reverse order C. Inv MixColumns Transformation compared to their order in encryption mode. Thus it starts InvMixColumns is the inverse of the MixColumns with an initial round, followed by 9 iterations of an inverse transformation. InvMixColumns operates on the State normal round and ends with an AddRoundKey. An inverse column-by-column, treating each column as a four term normal round consists of the following operations in this polynomial. The columns are considered as polynomials over order: AddRoundKey, InvMixColumns, InvShiftRows, and GF (28) and multiplied modulo x4 + 1 with a fixed polynomial InvSubBytes. An initial round is an inverse normal round a-1(x), given by a-1(x) = {0b} x3 + {0d} x2 + {09} x + {0e}, this without the InvMixColumns. can be written as a matrix multiplication. Let As a result of this multiplication, the four bytes in a column are replaced by the following:

' s0,c  0e 0b 0d 09 s0,c   '      s1,c 09 0e 0b 0d s1,c         '  s2,c 0d 09 0e 0b s2,c   '      s Fig 10: General structure of Decryption. s3,c  0b 0d 09 0e  3,c  A. Inv Shift rows Transformation  S’0,c = ({0e} • s0,c) + ({0b} • s1,c) + ({0d} • s2,c) + ({09} • InvShiftRows is the inverse of the ShiftRows transformation. The bytes in the last three rows of the State are cyclically s3,c) shifted over different numbers of bytes (offsets). The first row,  S’1,c = ({09} • s0,c) + ({0e} • s1,c) + ({0b} • s2,c) + ({0d} • r = 0, is not shifted. The bottom three rows are cyclically

IJSER © 2012 http://www.ijser.org

International Journal of Scientific & Engineering Research Volume 3, Issue 3, March -2012 5 ISSN 2229-5518

s3,c)

 S’2,c = ({0d} • s0,c) + ({09} • s1,c) + ({0e} • s2,c) + ({0b} •

s3,c)

 S’3,c = ({0b} • s0,c) + ({0d} • s1,c) + ({09} • s2,c) + ({0e} •

s3,c)

D. Inverse of the Addroundkey Transformation AddRoundKey is its own inverse, since it only involves an application of the XOR operation. Equivalent Inverse Cipher transformations differ from that of the Cipher, while the form of the key schedules for encryption and decryption remains the same. However, several properties of the AES algorithm Fig 13.Encryption Result allow for an Equivalent Inverse Cipher that has the same Encryption simulation was successfully completed by the use sequence of transformations as the Cipher (with the of key expansion and transformations of shift Rows, sub transformations replaced by their inverses). This is bytes, mix columns, add round keys. accomplished with a change in the key schedule. The two properties that allow for this Equivalent Inverse Cipher are as follows: The Sub Bytes and Shift Rows transformations commute; that is, a Sub Bytes transformation immediately followed by a Shift Rows transformation is equivalent to a Shift Rows transformation immediately followed by a Sub Bytes transformation. The same is true for their inverses, InvSubBytes and InvShiftRows. The column mixing operations - MixColumns and InvMixColumns – are linear with respect to the column input, which means Inv MixColumns(state XOR Round Key) =InvMixColumns(state)XORInvMixColumns(RoundKey).The se properties allow the order of InvSubBytes and InvShiftRows transformations to be reversed. The order of the AddRoundKey and InvMixColumns transformations can also be reversed, provided that the columns (words) of the decryption key schedule are modified using the InvMixColumns transformation. The equivalent inverse Fig 14.Decryption Result cipher is defined by reversing the order of the InvSubBytes and InvShiftRows transformations and by reversing the order Decryption simulation was successfully completed by the use of the AddRoundKey and InvMixColumns transformations of key expansion and transformations of inverse shift Rows, used in the ―round loop‖ after first modifying the decryption inverse sub bytes, inverse mix columns, inverse add round key schedule for round = 1 to Nr-1 using the InvMixColumns keys. transformation. The first and last Nb words of the decryption key schedule shall not be modified in this manner. V. CONCLUSION AND FUTURE WORK IV. IMPLEMENTATION RESULTS AND This paper was successfully completed with the implementation of DISCUSSION AES algorithm on 128 bit message. The encrypted cipher text and This paper was successfully completed with the the decrypted text are analyzed and proved to be correct. The implementation of Encryption and decryption for AES encryption efficiency of the proposed AES algorithm was studied algorithm. We implemented different sub modules for AES and met with satisfactory results. The following can be considered algorithm by using Verilog code. This implementation will be for the future works of this paper: useful in wireless security like military communication and mobile telephony where there is a gayer emphasis on the  An extra modification to be used for 192 bit and speed of communication. 256 bit key AES which is an extension of the paper.

IJSER © 2012 http://www.ijser.org

International Journal of Scientific & Engineering Research Volume 3, Issue 3, March -2012 6 ISSN 2229-5518  Power reduction and area minimization for the National Institute of Standards and , proposed AES algorithm is to be device. November 1999. [2] J. Daemen and V. Rijmen, The block cipher Rijndael, Smart  LCD can be used for display. Card research and Applications, LNCS 1820, Springer- Verlag, pp. 288-296. [3] J. Nechvatal, et. al., Report on the Development of the VI. AES APPLICATIONS Advanced Encryption Standard (AES), National Institute of Standards and Technology, October 2, 2000. AES Encryption and Decryption has many applications. It is used [4] in cases where data is too sensitive that only the authorized people ―Specification for the Advanced Encryption Standard are supposed to know and not to the rest. The following are the (AES),‖ Federal Information Processing Standards various applications Publication 197, Nov. 2001 [5] A. Menezes, P. van Oorschot, and S. Vanstone, Handbook of Applied Cryptography, CRC Press, New York, 1997, p. - Smart Cards 81-83. - RFID. [6] C.-P. Su, T.-F. Lin, C.-T. Huang, and C.-W. Wu, ―A high- - ATM networks. throughput low-cost AES processor,‖ IEEE Commun. - Image encryption Mag., vol. 41, no. 12, pp.86–91, Dec. 2003. [7] C.-P. Su, C.-L. Horng, C.-T. Huang, and C.-W. Wu, ―A configurable AES processor for enhanced security,‖ in Secure Storage Proc. ASP-DAC, Shanghai, , Jan. 2005, pp. 361–366. - Confidential Cooperate Documents [8] Rachh, R.R.; Anami, B.S.; Ananda Mohan, P.V. ―Efficient - Government Documents implementations of S-box and inverse S-box for AES - FBI Files algorithm,‖ in TENCON 2009 - 2009 IEEE Region 10 - Personal Storage Devices Conference , Nov. 2009, pp. 1–6. - Person Information Protection [9] Kaur, Swinder; Vig, Renu , ‖ Efficient Implementation of AES Algorithm in FPGA Device‖ in Conference on Computational Intelligence and Multimedia Applications, REFERENCES Nov 2007,pp. 179-187 [1] A. Lee, NIST Special Publication 800-21, Guideline for Implementing Cryptography in the Federal Government,

IJSER © 2012 http://www.ijser.org