A VHDL Implemetation of the Advanced Encryption Standard-Rijndael Algorithm. Rajender Manteena



Similar documents
Implementation and Design of AES S-Box on FPGA

IJESRT. [Padama, 2(5): May, 2013] ISSN:

Implementation of Full -Parallelism AES Encryption and Decryption

Modern Block Cipher Standards (AES) Debdeep Mukhopadhyay

Design and Verification of Area-Optimized AES Based on FPGA Using Verilog HDL

The Advanced Encryption Standard (AES)

Cryptography and Network Security. Prof. D. Mukhopadhyay. Department of Computer Science and Engineering. Indian Institute of Technology, Kharagpur

F3 Symmetric Encryption

The Advanced Encryption Standard (AES)

ELECTENG702 Advanced Embedded Systems. Improving AES128 software for Altera Nios II processor using custom instructions

Rijndael Encryption implementation on different platforms, with emphasis on performance

FPGA IMPLEMENTATION OF AN AES PROCESSOR

Enhancing Advanced Encryption Standard S-Box Generation Based on Round Key

The Advanced Encryption Standard: Four Years On

SeChat: An AES Encrypted Chat

Area Optimized and Pipelined FPGA Implementation of AES Encryption and Decryption

Efficient Software Implementation of AES on 32-bit Platforms

Survey on Enhancing Cloud Data Security using EAP with Rijndael Encryption Algorithm

Network Security. Chapter 3 Symmetric Cryptography. Symmetric Encryption. Modes of Encryption. Symmetric Block Ciphers - Modes of Encryption ECB (1)

Design and Implementation of Asymmetric Cryptography Using AES Algorithm

Secret File Sharing Techniques using AES algorithm. C. Navya Latha Garima Agarwal Anila Kumar GVN

Improving Performance of Secure Data Transmission in Communication Networks Using Physical Implementation of AES

Note on naming. Note on naming

FPGA IMPLEMENTATION OF AES ALGORITHM

The implementation and performance/cost/power analysis of the network security accelerator on SoC applications

Polymorphic AES Encryption Implementation

International Association of Scientific Innovation and Research (IASIR) (An Association Unifying the Sciences, Engineering, and Applied Research)

Hardware Implementation of AES Encryption and Decryption System Based on FPGA

Design and Analysis of Parallel AES Encryption and Decryption Algorithm for Multi Processor Arrays

Switching between the AES-128 and AES-256 Using Ks * & Two Keys

Efficient Software Implementation of AES on 32-Bit Platforms

CSCE 465 Computer & Network Security

How To Encrypt With A 64 Bit Block Cipher

Performance Evaluation of AES using Hardware and Software Codesign

Area optimized in storage area network using Novel Mix column Transformation in Masked AES

Parallel AES Encryption with Modified Mix-columns For Many Core Processor Arrays M.S.Arun, V.Saminathan

Pavithra.S, Vaishnavi.M, Vinothini.M, Umadevi.V

Advanced Encryption Standard by Example. 1.0 Preface. 2.0 Terminology. Written By: Adam Berent V.1.7

Advanced Encryption Standard by Example. 1.0 Preface. 2.0 Terminology. Written By: Adam Berent V.1.5

AES Power Attack Based on Induced Cache Miss and Countermeasure

CS 758: Cryptography / Network Security

Side-Channel Analysis Resistant Implementation of AES on Automotive Processors

Combining Mifare Card and agsxmpp to Construct a Secure Instant Messaging Software

AES (Rijndael) IP-Cores

A PPENDIX H RITERIA FOR AES E VALUATION C RITERIA FOR

Multi-Layered Cryptographic Processor for Network Security

A PPENDIX G S IMPLIFIED DES

AStudyofEncryptionAlgorithmsAESDESandRSAforSecurity

A DA Serial Multiplier Technique based on 32- Tap FIR Filter for Audio Application

AES implementation on Smart Card

Cryptography and Network Security

EXAM questions for the course TTM Information Security May Part 1

AESvisual: A Visualization Tool for the AES Cipher

1 Data Encryption Algorithm

A New 128-bit Key Stream Cipher LEX

Network Security - ISA 656 Introduction to Cryptography

10.1 Systems of Linear Equations: Substitution and Elimination

Automata Designs for Data Encryption with AES using the Micron Automata Processor

7! Cryptographic Techniques! A Brief Introduction

Network Security. Abusayeed Saifullah. CS 5600 Computer Networks. These slides are adapted from Kurose and Ross 8-1

A HARDWARE IMPLEMENTATION OF THE ADVANCED ENCRYPTION STANDARD (AES) ALGORITHM USING SYSTEMVERILOG

FPGA Implementation of RSA Encryption Engine with Flexible Key Size

Lecture 4 Data Encryption Standard (DES)

Cryptography and Network Security Prof. D. Mukhopadhyay Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Intel Advanced Encryption Standard (AES) New Instructions Set

CCMP Advanced Encryption Standard Cipher For Wireless Local Area Network (IEEE i): A Comparison with DES and RSA

AES Cipher Modes with EFM32

Separable & Secure Data Hiding & Image Encryption Using Hybrid Cryptography

White Paper. Shay Gueron Intel Architecture Group, Israel Development Center Intel Corporation


Hardware Encryption for Embedded Systems

Non-Linear Regression Samuel L. Baker

Number Who Chose This Maximum Amount

Cryptography and Network Security Department of Computer Science and Engineering Indian Institute of Technology Kharagpur

KALE: A High-Degree Algebraic-Resistant Variant of The Advanced Encryption Standard

Network Security. Omer Rana

Overview of Cryptographic Tools for Data Security. Murat Kantarcioglu

ECE 842 Report Implementation of Elliptic Curve Cryptography

Computer Networks. Network Security 1. Professor Richard Harris School of Engineering and Advanced Technology

synthesizer called C Compatible Architecture Prototyper(CCAP).

Lecture 8: AES: The Advanced Encryption Standard. Lecture Notes on Computer and Network Security. by Avi Kak

Basic Algorithms In Computer Algebra

A Study of New Trends in Blowfish Algorithm

Cyber Security Workshop Encryption Reference Manual

CHAPTER 13 SIMPLE LINEAR REGRESSION. Opening Example. Simple Regression. Linear Regression

Cryptography and Network Security: Summary

Developing and Investigation of a New Technique Combining Message Authentication and Encryption

QUADRATIC EQUATIONS EXPECTED BACKGROUND KNOWLEDGE

AES-CBC Software Execution Optimization

AN IMPLEMENTATION OF HYBRID ENCRYPTION-DECRYPTION (RSA WITH AES AND SHA256) FOR USE IN DATA EXCHANGE BETWEEN CLIENT APPLICATIONS AND WEB SERVICES

Continued Fractions and the Euclidean Algorithm

Transcription:

A VHDL Implemetation of the Advanced Encryption Standard-Rijndael Algorithm y Rajender Manteena A thesis sumitted in partial fulfillment of the requirements for the degree of Master of Science in Electrical Engineering Department of Electrical Engineering College of Engineering University of South Florida Major Professor: Wilfrido Moreno, Ph.D. James Leffew, Ph.D. Wei Qian, Ph.D. Date of Approval: March 23, 24 Keywords: decryption, state, cipher. Copyright 24, Rajender Manteena

ACKNOWLEDGEMENTS I would like to thank Dr. Moreno, my major professor, for his guidance. Dr. Moreno deserves my deepest gratitude for supporting me financially throughout my master degree program. I would like to thank Dr. Leffew who helped me to uild this thesis. I also acknowledge with gratitude the contriution of journals, papers, organizations and ooks, which I have referred to in the pages of the references. My parents and my wife play an important role in my life. To them I dedicate my thesis. Without their love, affection, motivation and support this thesis would not have een possile. Last ut not the least I would like to thank my friends Narender, Nikhil,Bhasker who have always een with me throughout the work of this thesis.

TABLE OF CONTENTS LIST OF FIGURES ABSTRACT iii v CHAPTER INTRODUCTION.. Background of the Algorithm.2. Notation and Conventions 2.2.. Inputs and Outputs 2.2.2. Bytes 3.2.3. Arrays of Bytes 4.2.4. The State 4.2.5. The State as an Array of Columns 6.3. Mathematical Background 6.3.. Addition 6.3.2. Multiplication 7.3.3. Multiplication y x 9.3.4. Polynomials with Coefficients in GF (2 8 ) i

CHAPTER 2 ENCRYPTION 3 2.. Encryption Process 3 2.2. Bytes Sustitution Transformation 4 2.3. Shift Rows Transformation 6 2.4. Mixing of Columns Transformation 7 2.5. Addition of Round Key Transformation 8 2.6. Key Schedule Generation 9 CHAPTER 3 DECRYPTION 2 3.. Decryption Process 2 3.2. Inverse Bytes Sustitution Transformation 22 3.3. Inverse Shift Rows Transformation 23 3.4. Inverse Mixing of Columns Transformation 24 CHAPTER 4 IMPLEMENTATION AND RESULTS 26 4.. Encryption Implementation 26 4.2. Decryption Implementation 3 4.3. Hardware Implementation 32 4.4. Conclusions 33 REFERENCES 34 APPENDICES 35 Appendix A: Terms and Definitions 36 Appendix B: Cipher Example 38 Appendix C: Example Vectors 4 Appendix D: VHDL Design Code 56 ii

LIST OF FIGURES Figure. Hexadecimal Representation of Bit Patterns 3 Figure 2. Indices for Bytes and Bits 4 Figure 3. State Array Input and Output 5 Figure 4. Encryption Process 3 Figure 5. Matrix Notation of S-ox 5 Figure 6. Application of the S-ox to Each Byte of the State 5 Figure 7. S-ox Values for All 256 Cominations in Hexadecimal Format 6 Figure 8. Cyclic Shift of the Last Three Rows of the State 7 Figure 9. Mixing of Columns of the State 8 Figure. Exclusive-OR Operation of State and Cipher Key Words 9 Figure. Key-Block- Round Cominations 2 Figure 2. Decryption Process 2 Figure 3. Application of the Inverse S-ox to Each Byte of the State 22 Figure 4. Inverse S-ox Values for All 256 Cominations in Hexadecimal Format 23 iii

Figure 5. Inverse Cyclic Shift of the Last Three Rows of the State 24 Figure 6. Inverse Mix Column Operation on State 25 Figure 7. Basic Characteristics of the ACEXK Family Devices 27 Figure 8. Waveforms of 8-it Byte Sustitution 28 Figure 9. Waveforms of Shift Row Transformation 28 Figure 2. Waveforms of Mix Column Transformation 29 Figure 2. Waveforms of Key Schedule Generation 29 Figure 22. Waveforms of 8-it Inverse Byte Sustitution 3 Figure 23. Waveforms of Inverse Shift Row Transformation 3 Figure 24. Waveforms of Inverse Mix Column Transformation 3 Figure 25. Block Diagram of AES Hardware Implementation 32 iv

A VHDL IMPLEMENTATION OF THE ADVANCED ENCRYPTION STANDARD-RIJNDAEL ALGORITHM Rajender Manteena ABSTRACT The National Institute of Standards and Technology (NIST) has initiated a process to develop a Federal information Processing Standard (FIPS) for the Advanced Encryption Standard (AES), specifying an Advanced Encryption Algorithm to replace the Data Encryption standard (DES) the Expired in 998. NIST has solicited candidate algorithms for inclusion in AES, resulting in fifteen official candidate algorithms of which Rijndael was chosen as the Advanced Encryption Standard. The Advanced Encryption Standard can e programmed in software or uilt with pure hardware. However Field Programmale Gate Arrays (FPGAs) offer a quicker, more customizale solution. This research investigates the AES algorithm with regard to FPGA and the Very High Speed Integrated Circuit Hardware Description language (VHDL). Altera Max+plus II software is used for simulation and optimization of the synthesizale VHDL code. All the transformations of oth Encryptions and Decryption are simulated using an iterative design approach in order to minimize the hardware consumption. Altera ACEXK Family devices are utilized for hardware evaluation. v

CHAPTER INTRODUCTION.. Background of the Algorithm The National Institute of Standards and Technology, (NIST), solicited proposals for the Advanced Encryption Standard, (AES). The AES is a Federal Information Processing Standard, (FIPS), which is a cryptographic algorithm that is used to protect electronic data. The AES algorithm is a symmetric lock cipher that can encrypt, (encipher), and decrypt, (decipher), information. Encryption converts data to an unintelligile form called cipher-text. Decryption of the cipher-text converts the data ack into its original form, which is called plaintext. The AES algorithm is capale of using cryptographic keys of 28, 92, and 256 its to encrypt and decrypt data in locks of 28 its. Many algorithms were originally presented y researchers from twelve different nations. Fifteen, (5), algorithms were selected from the first set of sumittals. After a study and selection process five, (5), were chosen as finalists. The five algorithms selected were MARS, RC6, RIJNDAEL, SERPENT and TWOFISH. The conclusion was that the five Competitors showed similar characteristics. On Octoer 2 nd 2, NIST announced that the Rijndael Algorithm was the winner of the contest. The Rijndael Algorithm was chosen since it had the est overall scores in security, performance, efficiency, implementation aility and flexiility, [NIS]. The Rijndael algorithm was

developed y Joan Daemen of Proton World International and Vincent Fijmen of Katholieke University at Leuven. The Rijndael algorithm is a symmetric lock cipher that can process data locks of 28 its through the use of cipher keys with lengths of 28, 92, and 256 its. The Rijndael algorithm was also designed to handle additional lock sizes and key lengths. However, the additional features were not adopted in the AES. The hardware implementation of the Rijndael algorithm can provide either high performance or low cost for specific applications. At ackone communication channels or heavily loaded servers it is not possile to lose processing speed, which drops the efficiency of the overall system while running cryptography algorithms in software. On the other side, a low cost and small design can e used in smart card applications, which allows a wide range of equipment to operate securely. [6].2. Notation and Conventions.2.. Inputs and Outputs The input and output for the AES algorithm consists of sequences of 28 its. These sequences are referred to as locks and the numers of its they contain are referred to as their length. The Cipher Key for the AES algorithm is a sequence of 28, 92 or 256 its. Other input, output and Cipher Key lengths are not permitted y this standard. The its within such sequences are numered starting at zero and ending at one less than the sequence length, which is also termed the lock length or key length. The numer i attached to a it is known as its index and will e in one of the ranges i < 28, i < 92 or i < 256 depending on the lock length or key length specified. 2

.2.2. Bytes The asic unit of processing in the AES algorithm is a yte, which is a sequence of eight its treated as a single entity. The input, output and Cipher Key it sequences descried in Section. are processed as arrays of ytes that are formed y dividing these sequences into groups of eight contiguous its to form arrays of ytes. For an input, output or Cipher Key denoted y a, the ytes in the resulting array are referenced using one of the two forms, a n or a[n], where n will e in a range that depends on the key length. For a key length of 28 its, n lies in the range n < 6. For a key length of 92 its, n lies in the range n < 24. For a key length of 256 its, n lies in the range n < 32. All yte values in the AES algorithm are presented as the concatenation of the individual it values, ( or ), etween races in the order { 7, 6, 5, 4, 3, 2,, }. These ytes are interpreted as finite field elements using a polynomial representation x 7 + x 6 5 4 3 2 + x i + x + x + x + x + = x () i 7 6 5 4 3 2 6 5 For example, {} identifies the specific finite field element x + x + x +. It is also convenient to denote yte values using hexadecimal notation with each of two groups of four its eing denoted y a single hexadecimal character. The hexadecimal notation scheme is depicted in Figure.. 7 i= Figure. Hexadecimal Representation of Bit Patterns [] 3

Hence the element {} can e represented as {63}, where the character denoting the four-it group containing the higher numered its is again to the left. Some finite field operations involve one additional it { 8 } to the left of an 8-it yte. When the 8 it is present, it appears as {} immediately preceding the 8-it yte. For example, a 9-it sequence is presented as {} {}..2.3. Arrays of Bytes Arrays of ytes are represented in the form a a a 2 a 5. The ytes and the it ordering within ytes are derived from the 28-it input sequence, input input input 2 input 26 input 27 as a = {input, input,, input 7 }, a = {input 8, input 9,, input 5 } with the pattern continuing up to a 5 = {input 2, input 2,, input 27 }. The pattern can e extended to longer sequences associated with 92 and 256 it keys. In general, a n = {input 8n, input 8n+,, input 8n+7 }. An example of yte designation and numering within ytes for a given input sequence is presented in Figure 2. Figure 2. Indices for Bytes and Bits [].2.4. The State Internally, the AES algorithm s operations are performed on a two-dimensional array of ytes called the State. The State consists of four rows of ytes. Each row of a state contains N numers of ytes, where N is the lock length divided y 32. In the State array, which is denoted y the symol S, each individual yte has two indices. The first yte index is the row numer r, which lies in the range r 3 and the second yte 4

index is the column numer c, which lies in the range c N. Such indexing allows an individual yte of the State to e referred to as S r,c or S [r,c]. For the AES N = 4, which means that c 3. At the eginning of the Encryption and Decryption the input, which is the array of ytes symolized y in in in 5 is copied into the State array. This activity is illustrated in Figure 3. The Encryption or Decryption operations are conducted on the State array. After manipulation of the state array has completed its final value is copied to the output, which is an array of ytes symolized y out out out 5. Input Bytes State Array Output Bytes Figure 3. State Array Input and Output [] At the start of the Encryption or Decryption the input array is copied to the State array with S [r, c] = in[r + 4c] where r 3 and c N At the end of the Encryption and Decryption the State is copied to the output array with out[r + 4c] = S [r,c] where r 3 and c N. 5

.2.5. The State as an Array of Columns The four ytes in each column of the State form 32-it words, where the row numer r provides an index for the four ytes within each word. Therefore, the state can e interpreted as a one-dimensional array of 32 it words, which is symolized y w...w 3. The column numer c provides an index into this linear State array. Considering the State depicted in Figure3, the State can e considered as an array of four words where w = S, S, S 2, S 3,, w = S, S, S 2, S 3,, w 2 = S,2 S,2 S 2,2 S 3,2 and w 3 = S,3 S,3 S 2,3 S 3,3..3. Mathematical Background Every yte in the AES algorithm is interpreted as a finite field element using the notation introduced in Section...2. All Finite field elements can e added and multiplied. However, these operations differ from those used for numers and their use requires investigation..3.. Addition The addition of two elements in a finite field is achieved y adding the coefficients for the corresponding powers in the polynomials for the two elements. The addition is performed through use of the XOR operation, which is denoted y the operator symol. Such addition is performed modulo-2. In modulo-2 addition =, =, 6

= and =. Consequently, sutraction of polynomials is identical to addition of polynomials. Alternatively, addition of finite field elements can e descried as the modulo-2 addition of corresponding its in the yte. For two ytes {a 7 a 6 a 5 a 4 a 3 a 2 a a } and { 7 6 5 4 3 2 }, the sum is {c 7 c 6 c 5 c 4 c 3 c 2 c c }, where each c i = a i i where i represents corresponding its. For example, the following expressions are equivalent to one another. (x + 6 4 2 7 7 6 4 2 + x + x + x + ) + (x + x + ) = x + x + x x (Polynomial notation) { } {} = {} (Binary notation) { 57} {83} = { d4} (Hexadecimal notation).3.2. Multiplication In the polynomial representation, multiplication in Galois Field GF (2 8 ) (denoted y ) corresponds with the multiplication of polynomials modulo an irreducile polynomial of degree 8. A polynomial is irreducile if its only divisors are one and itself. For the AES algorithm, this irreducile polynomial is given y the equation (2). 8 4 3 m ( x) = x + x + x + x + (2) 7

For example, { 57} {83} = { c} ecause 6 4 2 7 3 9 8 ( x + x + x + x + )( x + x + ) = x + x + x + x + x 7 + x 7 5 3 2 + x + x + x + x + x 6 4 2 + x + x + x + 3 9 8 6 5 4 3 = x + x + x + x + x + x + x + x + 3 9 8 6 5 4 3 8 4 3 x + x + x + x + x + x + x + x + Modulo ( x + x + x + x + ) 7 6 = x + x +. The modular reduction y m(x) ensures that the result will e a inary polynomial of degree less than 8, which can e represented y a yte. Unlike addition, there is no simple operation at the yte level that corresponds to this multiplication. The multiplication defined aove is associative and the element {} is the multiplicative identity. For any non-zero inary polynomial (x) of degree less than 8, the multiplicative inverse of (x), denoted - (x), can e found. The inverse is found through use of the extended Euclidean algorithm to compute polynomials a(x) and c(x) such that ( x) a( x) + m( x) c( x) =. (3) Hence, a(x) (x) mod m(x) =, which means ( x) = a( x) mod m( x) (4) Moreover, for any a(x), (x) and c(x) in the field, it holds that a ( x) ( ( x) + c( x)) = a( x) ( x) + a( x) c( x) (5) It follows that the set of 256 possile yte values, with XOR used as addition and multiplication defined as aove, has the structure of the finite field GF (2 8 ). 8

.3.3. Multiplication y x Multiplying the inary polynomial defined in equation () with the polynomial x results in 8 7 6 5 4 3 2 x + x + x + x + x + x + x +. (6) 7 6 5 4 3 2 x The result x (x) is otained y reducing the aove result modulo m(x). If 7 equals zero the result is already in reduced form. If 7 equals one the reduction is accomplished y sutracting the polynomial m(x). It follows that multiplication y x, which is represented y {} or {2}, can e implemented at the yte level as a left shift and a susequent conditional itwise XOR with {}. This operation on ytes is denoted y xtime( ). Multiplication y higher powers of x can e implemented y repeated application of xtime( ). Through the addition of intermediate results, multiplication y any constant can e implemented. For example, {57} {3} = {fe} ecause {57} {2} = xtime ({57}) = {ae} {57} {4} = xtime ({ae}) = {47} {57} {8} = xtime ({47}) = {8e} {57} {} = xtime ({8e}) = {7}, Thus, {57} {3} = {57} ({} {2} {}) = {57} {ae} {7} = {fe}. 9

.3.4. Polynomials with Coefficients in GF (2 8 ) Four-term polynomials can e defined with coefficients that are finite field elements as the following equation (7) a = + (7) 3 2 ( x) a3x + a2 x + ax a which will e denoted as a word in the form [a, a, a2, a3 ]. Note that the polynomials in this section ehave somewhat differently than the polynomials used in the definition of finite field elements, even though oth types of polynomials use the same indeterminate, x. The coefficients in this section are themselves finite field elements, i.e., ytes, instead of its; also, the multiplication of four-term polynomials uses a different reduction polynomial, defined elow. To illustrate the addition and multiplication operations, let = + (8) 3 2 ( x) 3 x + 2 x + x define a second four-term polynomial. Addition is performed y adding the finite field coefficients of like powers of x. This addition corresponds to an XOR operation etween the corresponding ytes in each of the words in other words, the XOR of the complete word values Thus, using the equations of (7) and (8), 3 2 a x) + ( x) = ( a ) x + ( a ) x + ( a ) x + ( a ) (9) ( 3 3 2 2 Multiplication is achieved in two steps. In the first step, the polynomial product c(x) = a(x) (x) is algeraically expanded, and like powers are collected to give c = + () 6 5 4 3 2 ( x) c6 x + c5x + c4x + c3x + c2 x + cx c where

3 3 6 3 2 2 3 5 3 2 2 3 4 3 2 2 3 3 2 2 2 a c a a c a a a c a a a a c a a a c a a c a c = = = = = = = The result, c(x), does not represent a four-yte word. Therefore, the second step of the multiplication is to reduce c(x) modulo a polynomial of degree 4; the result can e reduced to a polynomial of degree less than 4. For the AES algorithm, this is accomplished with the polynomial x 4 +, so that. ) mod( mod 4 4 i i x x x = + () The modular product of a(x) and (x), denoted y a(x) (x), is given y the four-term polynomial d(x), defined as follows 2 2 3 3 ) ( d x d x d x d x d + + + = (2) with ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( 3 2 2 3 3 3 3 2 2 2 3 2 2 3 3 2 2 3 a a a a d a a a a d a a a a d a a a a d = = = = When a(x) is a fixed polynomial, the operation defined in equation (2) can e written in matrix form as the following equation (3). = 3 2 2 3 3 2 2 3 2 3 3 2 a a a a a a a a a a a a a a a a d d d d (3)

Because x 4 + is not an irreducile polynomial over GF(2 8 ), multiplication y a fixed four-term polynomial is not necessarily invertile. However, the AES algorithm specifies a fixed four-term polynomial that does have an inverse is given y 3 2 a ( x) = {3} x + {} x + {} x + {2} (4) 3 2 a ( x) = {} x + {d} x + {9} x + {e} (5) Another polynomial used in the AES algorithm has a = a = a 2 = {} and a 3 = {}, which is the polynomial x 3. Inspection of equation (3) aove will show that its effect is to form the output word y rotating ytes in the input word. This means that [,, 2, 3 ] is transformed into [, 2, 3, ]. 2

CHAPTER 2 ENCRYPTION 2.. Encryption Process The Encryption process of Advanced Encryption Standard algorithm is presented elow, in figure 4. Key Schedule Figure 4. Encryption Process [6] 3

This lock diagram is generic for AES specifications. It consists of a numer of different transformations applied consecutively over the data lock its, in a fixed numer of iterations, called rounds. The numer of rounds depends on the length of the key used for the encryption process. 2.2. Bytes Sustitution Transformation The ytes sustitution transformation Bytesu (state) is a non-linear sustitution of ytes that operates independently on each yte of the State using a sustitution tale(sox) presented in figure7. This S-ox which is invertile, is constructed y composing two transformations. Take the multiplicative inverse in the finite field GF (2 8 ), descried in Section.3.2. The element {} is mapped to itself. 2. Apply the following affine transformation (over GF (2)) ' i = i ( i+ 4) mod 8 ( i+ 5) mod8 ( i+ 6) mod8 ( i+ 7) mod8 c i (6) for i 8, where i is the i th it of the yte, and c i is the i th it of a yte c with the value {63} or {}. Here and elsewhere, a prime on a variale (e.g., ) indicates that the variale is to e updated with the value on the right. In matrix form, the affine transformation element of the S-ox can e expressed as 4

5 + = 7 6 5 4 3 2 ' 7 ' 6 ' 5 ' 4 ' 3 ' 2 ' ' Figure 5. Matrix Notation of S-ox [] Figure 6. Application of S-ox to the Each Byte of the State [] The S-ox used in the Su Bytes transformation is presented in hexadecimal form in figure 7. For example, if =S, = {53}, then the sustitution value would e determined y the intersection of the row with index 5 and the column with index 3 in figure 7. This would result in S', having a value of {ed}.

Figure 7. S-ox Values for All 256 Cominations in Hexadecimal Format [] 2.3. Shift Rows Transformation In the Shift Rows transformation ShiftRows( ), the ytes in the last three rows of the State are cyclically shifted over different numers of ytes (offsets). The first row, r =, is not shifted. Specifically, the ShiftRows( ) transformation proceeds as follows s ' r, c sr,( c + shift( r, N)) mod N = for < r < 4 and c N, Where the shift value shift(r, N) depends on the row numer, r, as follows (N = 4) Shift (,4) = : Shift(2,4) = 2; Shift(3,4) = 3. This has the effect of moving ytes to lower positions in the row (i.e., lower values of c in a given row), while the lowest ytes wrap around into the top of the row (i.e., higher values of c in a given row). Figure 7 illustrates the ShiftRows( )transformation. 6

Figure 8. Cyclic Shift of the Last Three Rows of the State [] 2.4. Mixing of Columns Transformation This transformation is ased on Galois Field multiplication. Each yte of a column is replaced with another value that is a function of all four ytes in the given column. The MixColumns( ) transformation operates on the State column-y-column, treating each column as a four-term polynomial as descried in Section..3.4. The columns are considered as polynomials over GF (2 8 ) and multiplied modulo x 4 + with a fixed polynomial a(x), given y the following equation. 3 a ( x) = {3} x + {} x + {} x + {2}. 2 As descried in Section..3.4, this can e written as a matrix multiplication. Let ' S ( x) = a( x) S( x) 7

S S S S ', c ', c ', c ', c 2 = 3 3 2 3 2 S S 3S 2 S, c, c, c, c for c < N. As a result of this multiplication, the four ytes in a column are replaced y the following S S S S ', c ', c ' 2, c ' 3, c = ({2} S, c ) ({3} S, c ) S2, c S3, c = S, c ({2} S, c ) ({3} S2, c ) S3, c = S, c S, c ({2} S2, c ) ({3} S3, c ) = ({3} S ) S S ({2} S ), c, c 2, c 3, c Figure 9. Mixing of Columns of the State [] 2.5. Addition of Round Key Transformation In the Addition of Round Key transformation AddRoundKey( ), a Round Key is added to the State y a simple itwise XOR operation. Each Round Key consists of N words from the key schedule generation (descried in following section 2.6). Those N words are each added into the columns of the State, such that 8

', ', ', ', [ S c, S c, S 2 c, S 3 c,] = [ S, c, S, c, S2, c, S3, c ] [ W round * N ] for c<n, Figure. Exclusive-OR Operation of State and Cipher Key Words [] where [w i ] are the key generation words descried in chapter 3, and round is a value in the range in the Encryption, the initial Round Key addition occurs when round =, prior to the first application of the round function. The application of the AddRoundKey ( ) transformation to the Nr rounds of the encryption occurs when round Nr. The action of this transformation is illustrated in figure, where l = round * N. The yte address within words of the key schedule was descried in Section.2.. 2.6. Key Schedule Generation Each round key is a 4-word (28-it) array generated as a product of the previous round key, a constant that changes each round, and a series of S-Box (figure6) lookups for each 32-it word of the key. The first round key is the same as the original user input. Each yte (w - w 3 ) of initial key is XOR d with a constant that depends on the current round, and the result of the S-Box lookup for w i, to form the next round key. The numer of rounds required for three different key lengths is presented in figure. 9

Key Length Block Size Numer of (Nk Words) (N Words) Rounds (Nr) AES-28 4 4 AES-92 6 4 2 AES-256 8 4 4 Figure. Key-Block- Round Cominations [] The Key schedule Expansion generates a total of N(Nr + ) words: the algorithm requires an initial set of N words, and each of the Nr rounds requires N words of key data. The resulting key schedule consists of a linear array of 4-yte words, denoted [wi], with i in the range i < N(Nr + ). 2

CHAPTER 3 DECRYPTION 3.. Decryption Process The Decryption process of Advanced Encryption Standard algorithm is presented elow, in figure2. Key Schedule Figure 2. Decryption Process [6] 2

This process is direct inverse of the Encryption process (chapter2). All the transformations applied in Encryption process are inversely applied to this process. Hence the last round values of oth the data and key are first round inputs for the Decryption process and follows in decreasing order. 3.2. Inverse Bytes Sustitution Transformation Inverse Byte Sustitution Transformation InvSuBytes( ) is the inverse of the yte sustitution transformation, in which the inverse S-Box (figure4) is applied to each yte of the State. This is otained y applying the inverse of the affine transformation to the equation (6) followed y taking the multiplicative inverse in GF (2 8 ). Figure 3. Application of the Inverse S-ox to Each Byte of the State [] 22

Figure 4. Inverse S-ox Values for All 256 Cominations in Hexadecimal Format 3.3. Inverse Shift Rows Transformation Inverse Shift Rows Transformation InvShiftRows( ) is the inverse of the ShiftRows( ) transformation presented in Chater2. The ytes in the last three rows of the State are cyclically shifted over different numers of ytes. The first row, r =, is not shifted. The ottom three rows are cyclically shifted y N-shift(r, N) ytes, where the shift value shift(r, N) depends on the row numer, and is explained in Section.2.3. Specifically, the InvShiftRows( ) transformation proceeds as follows ' S r, ( c shift( r, N))mod N = Sr, c + for r<4 and c<n 23

Figure 5. Inverse Cyclic Shift of the Last Three Rows of the State [] 3.4. Inverse Mixing of Columns Transformation Inverse Mixing of Columns Transformation InvMixColumns( ) is the inverse of the MixColumns ( ) transformation) presented in chapter2. InvMixColumns ( ) operates on the State column-y-column, treating each column as a four term polynomial as descried in Section..3.4. The columns are considered as polynomials over GF (2 8 ) and multiplied modulox 4 + with a fixed polynomial a - (x), given y 3 a ( x) = {} x + {d} x + {9} x + {e}. As descried in Section..3.4, this can e written as a matrix multiplication. Let ' S ( x) = a ( x) S( x) 2 24

S S S S ', c ', c ', c ', c e 9 = d e 9 d d e 9 9 S ds S e S, c, c, c, c for c<n. As a result of this multiplication, the four ytes in a column are replaced y the following equations. S S S S ', c ', c ' 2, c ' 3, c = ({e} S, c ) ({} S, c ) ({d} S2, c ) ({9} S3, c ) = ({9} S, c ) ({e} S, c ) ({} S2, c ) ({d} S3, c ) = ({d} S, c ) ({9} S, c ) ({e} S2, c ) ({} S3, c ) = ({} S ) ({d} S ) ({9} S ) ({e} S ), c Hence, State can e represented as, c 2, c 3, c InvMixColumn( ) Figure 6. Inverse Mix Column Operation on State [] 25

CHAPTER 4 IMPLEMETATION AND RESULTS 4.. Encryption Implementation VHDL is used as the hardware description language ecause of the flexiility to exchange among environments. The code is pure VHDL that could easily e implemented on other devices, without changing the design. The software used for this work is Altera Max+plus II.2. This is used for writing, deugging and optimizing efforts, and also for fitting, simulating and checking the performance results using the simulation tools availale on MaxPlus II design software. All the results are ased on simulations from the Max+plus II and Quartus tools, using Timing Analyzer and Waveform Generator. All the individual transformation of oth encryption and decryption are simulated using FPGA ACEXK family and EPK devices. The characteristics of the devices are presented in figure 7. An iterative method of design is implemented to minimize the hardware utilization and the fitting is done y the Altera s Quartus fitter Technology. 26

General Characteristics of the ACEX Family Device EPK EPK3 EPK5 EPK Typical Gates, 3, 5,, Maximum System Gates 56, 9, 99, 257, Logic Elements 576,728 2,88 4,992 Emedded Array Blocks (EABs) Maximum Bits RAM 3 6 2 2,288 24,576 4,96 49,52 Speed Grades -, -2, -3 -, -2, -3 -, -2, -3 -, -2, -3 Package (mm) -Pin TQFP 66 Maximum User I/O Pins 44-Pin TQFP 92 2 2 28-Pin PQFP 2 47 47 47 256-Pin (BGA) 36 7 86 86 484-Pin (BGA) 249 333 Figure 7. Basic Characteristics of the ACEXK Family Devices [4] In order to allow a full parallel process of the state, it is necessary to implement all the transformations over 28 its. The most expensive one is the Byte sustitution, ecause it is a tale lookup operation, implemented as ROM. Each 8 its requires a 248 it ROM. To process 28 its it is necessary 32768 its. The Key Expansion uses a Byte sustitution operation over 32 its also, so another 892 its should e allocated. The following figure 8 shows the waveforms generated y the 8-it yte sustitution transformation. The inputs are clock of ns time period, Active High reset, and 8-it state as a standard logic vector, whose output is 8-it S-ox lookup sustitution. This design utilizes 32% of the area of EPKFC484-, around 63 logic elements are consumed to implement only 8-it S-ox lookup tale. Hence, approximately 2, logic elements are necessary to implement the complete 28-it yte sustitution transformation. It can e done y the APEX2K family devices. 27

Figure 8. Waveforms of 8-it Byte Sustitution The following figure 9 represents the waveforms generated y the 8-it yte sustitution transformation. The inputs are clock of ns time period, Active High reset, and 28-it state as a standard logic vector, whose output is shifted as explained in the section 2.3. Design utilizes 2% of the area of EPKFC484-, around 28 logic elements are consumed. Figure 9. Waveforms of Shift Row Transformation The following figure 2 represents the waveforms generated y the 2 8-it Mix Columns transformation. The inputs are clock of ns time period, Active High reset, and 28-it state as a standard logic vector, whose output is shifted as explained in the section 2.4. Design utilizes 5% of the area of EPKFC484-, around 56 logic elements are consumed. 28

Figure 2. Waveforms of Mix Column Transformation The following figure 2 represents the waveforms generated y the 28-it Key Schedule Generation. The inputs are clock of ns time period, Active High reset, round, and 28-it state as a standard logic vector, whose output is the 28-it key for round one is generated. Design utilizes 74% of the area of EPKFC484-, around 37 logic elements are consumed. Figure 2. Waveforms of Key Schedule Generation 29

4.2. Decryption Implementation The decryption implementation results are similar to the encryption implementation. The key schedule generation module is modified in the reverse order. In which last round key is treated as the first round and decreasing order follows. The following figure 22 represents the waveforms generated y the 8-it yte sustitution transformation. The inputs are clock of ns time period, Active High reset, and 8-it state as a standard logic vector, whose output is 8-it Inverse S-ox lookup sustitution. This design utilizes 5% of the area of EPK3TC44-, around 877 logic elements are consumed to implement only 8-it S-ox lookup tale Figure 22. Waveforms of 8-it Inverse Byte Sustitution The following figure 23 represents the waveforms generated y the 8-it Inverse yte sustitution transformation. The inputs are clock of ns time period, Active High reset, and 8-it state as a standard logic vector whose output is shifted as explained in the section 3.3. Design utilizes 2% of the area of EPKFC484-, around 28 logic elements are consumed. 3

Figure 23. Waveforms of Inverse Shift Row Transformation The following figure 24 represents the waveforms generated y the 8-it yte sustitution transformation. The inputs are clock of ns time period, Active High reset, and 8-it state as a standard logic vector, whose output is shifted as explained in the section 3.4. Design utilizes 2% of the area of EPKFC484-, around 624 logic elements are consumed. Figure 24. Waveforms of Inverse Mix Column Transformation 3

4.3. Hardware Implementation The following figure 25 represents complete hardware implementation of the oth encryption and decryption with key generation modules. Plaintext/Ciphertext 28-it Clk En= or Key Length 2-Bit Encryption/Decryption Round 28-Bit Key Input Output 28-Bit Clk2 Secret Key 28/92/256 Key Schedule Generation Figure 25. Block Diagram of AES Hardware Implementation Key Schedule Generation lock can generate the required keys for the process with secret key and Clk2 as inputs; these generated keys are stored in internal ROM and read y Encryption/Decryption lock for each round to otain a distinct 28-it key with Round counter, where Encryption/Decryption module takes 28-it plaintext or ciphertext as input with respective to the Clk (If En=or process is encryption or decryption respectively). In order to distinguish the numer of rounds, a 2-it Key Length input is given to this module where,, represents (28-it key), 2(92- it key), 4(256-it key) rounds respectively, generates the final output of 28-it cipher or plaintext. 32

4.4. Conclusions Optimized and Synthesizale VHDL code is developed for the implementation of oth encryption and decryption process. Each program is tested with some of the sample vectors provided y NIST and output results are perfect with minimal delay. Therefore, AES can indeed e implemented with reasonale efficiency on an FPGA, with the encryption and decryption taking an average of 32 and 34 ns respectively (for every 28 its). The time varies from chip to chip and the calculated delay time can only e regarded as approximate. Adding data pipelines and some parallel cominational logic in the key scheduler and round calculator can further optimize this design. 33

REFERENCES [] FIPS 97, Advanced Encryption Standard (AES), Novemer 26, 2 http://csrc.nist.gov/pulications/fips/fips97/fips-97.pdf [2] J. Daemen and V. Rijmen, AES Proposal: Rijndael, AES Algorithm Sumission, Septemer 3, 999 http://www.esat.kuleuven.ac.e/~rijmen/rijndael/rijndaeldocv2.zip [3] ALTERA. Max+plus II VHDL. San Jose. Altera, 996 [4] ALTERA ACEXK Emedded Programmale Logic Family Data Sheet, pdf files, http://www.altera.com/literature/ds/acex.pdf (May 23) [5] ALTERA High-Speed Rijndael Encryption/Decryption Processors, http://www.altera.com/literature/wp/wp_hcores_rijnfast.pdf [6] Marcelo B. de Barcelos Design Case, Optimized performance and area implementation of Advanced Encryption Standard in Altera Devices, y, http://www.inf.ufrgs.r/~panato/artigos/designcon2.pdf [7] FPGA Simulations of Round 2 Advanced Encryption Standards http://csrc.nist.gov/cryptotoolkit/aes/round2/conf3/presentations/elirt.pdf. [8] http://en.wikipedia.org/wiki/extended_euclidean_algorithm [9] Tilorg, Henk C. A. van. Fundamentals of Cryptology: A Professional Reference and Interactive Tutorial, New York Kluwer Academic Pulishers, 22 [] Peter J. Ashenden, The Designer's Guide to VHDL, 2 nd Edition, San Francisco, CA, Morgan Kaufmann, 22 34

APPENDICES 35

Appendix A: Terms and Definitions The following definitions are used throughout this standard Terms Definitions AES Affine Transformation Array Bit Advanced Encryption Standard. A transformation consisting of multiplication y a matrix followed y the addition of a vector. An enumerated collection of identical entities. A inary digit having a value of or. Block Sequence of inary its that comprise the input, output, State, and Round Key. The length of a sequence is the numer of its it contains. Blocks are also interpreted as arrays of ytes. Byte A group of eight its that is treated either as a single entity or as an array of 8 individual its. Encryption or ciphertext Cipher Key Cipher Series of transformations that converts plaintext to using the Cipher Key Secret, cryptographic key that is used y the Key Expansion routine to generate a set of Round Keys; can e pictured as a rectangular array of ytes, having four rows and Nk columns. 36

Appendix A (continued) Ciphertext Decryption or Inverse Cipher Key Schedule Data output from the Encryption or input to the decryption. Series of transformations that converts ciphertext to plaintext using the Cipher Key. Routine used to generate a series of Round Keys from the Cipher Key. Plaintext Rijndael Data input to the Cipher or output from the Inverse Cipher. Cryptographic algorithm specified in this Advanced Encryption Standard (AES).Round Key Round keys are values derived from the Cipher Key using the Key Expansion routine; they are applied to the State in the Cipher and Inverse Cipher. State Intermediate Cipher result that can e pictured as a rectangular array of ytes, having four rows and N columns. S-Box A Non-linear sustitution tale used in several yte sustitution transformations and in the Key Schedule routine to perform a onefor-one sustitution of a yte value. Word A group of 32 its that is treated either as a single entity or as an array of 4 ytes 37

Appendix B: Cipher Example The following diagram shows the values in the State array as the Encryption progresses for a lock length and a Key length of 6 ytes each (i.e., N = 4 and Nk = 4). Input = 32 43 f6 a8 88 5a 3 8d 3 3 98 a2 e 37 7 34 Cipher Key = 2 7e 5 6 28 ae d2 a6 a f7 5 88 9 cf 4f 3c 38

Appendix B (continued) 39

Appendix B (continued) 4

Appendix C: Example Vectors This appendix contains example vectors, including intermediate values for all three AES key lengths (Nk = 4, 6, and 8), for the Encryption and Decryption. All vectors are in hexadecimal notation, with each pair of characters giving a yte value in which the left character of each pair provides the it pattern for the 4 it group containing the higher numered its using the notation explained in Section.22, while the right character provides the it pattern for the lower-numered its. The array index for all ytes (groups of two hexadecimal digits) within these test vectors starts at zero and increases from left to right. AES-28 (Nk=4, Nr=) PLAINTEXT: 2233445566778899aaccddeeff KEY: 23456789acdef CIPHER (ENCRYPT): round[ ].input 2233445566778899aaccddeeff round[ ].k_sch 23456789acdef round[ ].start 23456789acdef round[ ].s_ox 63ca74953d5cd6ee7a7e8c round[ ].s_row 6353e8c96e4cd775acade7 round[ ].m_col 5f7264557f5c92f7e329d9f9a round[ ].k_sch d6aa74fdd2af72fadaa678fd6a76fe round[ 2].start 89d8e8855ace682d843d8c28fe4 round[ 2].s_ox a76ca997e845d8ada6fc97369 round[ 2].s_row a7ea6997ad739d8c9ca45f686 round[ 2].m_col ff8796843d86a56455fa773ad9 round[ 2].k_sch 692cf643ddfe9c56833fe round[ 3].start 495598f55e5d7adaca94fafa63f7 4

Appendix C (continued) round[ 3].s_ox 359c73fcd9ee5774222dc67f68 round[ 3].s_row 3d92268fc74f735767cec59e2d round[ 3].m_col 4c9ce66f77f762c3f868e534df256 round[ 3].k_sch 6ff744ed2c2c9f6c59cf469f4 round[ 4].start fa636a2825339c94668a357244d7 round[ 4].s_ox 2df2343f6d2dd9337ec7536e3f round[ 4].s_row 2d6d7ef3f33e3349362dd5f2c7 round[ 4].m_col 638579ffc538df997e478e7547d69 round[ 4].k_sch 47f7f7c95353e3f96c32cfd58dfd round[ 5].start 247242369663fa6ed27532884256c round[ 5].s_ox 364926f9336d2d9f59d23c42c395 round[ 5].s_row 36339d5f9539269f2c92dc446d23 round[ 5].m_col f4cd45432e554d75fd6c5dd33c round[ 5].k_sch 3caaa3e8a99f9de5f3af57adf622aa round[ 6].start c8677c97ac93252799226996 round[ 6].s_ox e847f5654dadde23f7764fe7f7d49 round[ 6].s_row e8da69477d4653ff7f5e2e747dd4f round[ 6].m_col 986ee74f87f5562c49c8e5ad36 round[ 6].k_sch 5e39f7df7a69296a7553dcaa3f6 round[ 7].start c62fe9f75eedc3cc79395d84f9cf5d round[ 7].s_ox 45f86858552e4624c5f998a4c round[ 7].s_row 45824c6868a499f82e5f5554c round[ 7].m_col c57ec59a9d286f5f4e98c63439 round[ 7].k_sch 4f97ae35fe28c44adf4d4ea9c26 round[ 8].start d876cf79c43a45594add66ff4f round[ 8].s_ox 3e75766c4678dfc2295f6a8fc round[ 8].s_row 3ec22c6fcf768da8567f67495 42

Appendix C (continued) round[ 8].m_col aa3de7af956ed552ca5f44d23 round[ 8].k_sch 47438735a4c659e6af4aef7ad2 round[ 9].start fde3ad25e5dd73547964effe37f round[ 9].s_ox 54f456d97e96a92fa9aa round[ 9].s_row 54d99a6a9a596f4ea72f round[ 9].m_col e9f74eec232f6f2ccf2353c2c7 round[ 9].k_sch 549932df85576893ed9ce2c974e round[].start d6e7c3df25779e626e8689 round[].s_ox 7a9f2789d5f52effd9f3dca4ea7 round[].s_row 7ad5fda789ef4e272ca3d9ff59f round[].k_sch 3d7fe3944a7f37a784d23c5 round[].output 69c4ed86a743d8cd7874c55a INVERSE CIPHER (DECRYPT): round[ ].iinput 69c4ed86a743d8cd7874c55a round[ ].ik_sch 3d7fe3944a7f37a784d23c5 round[ ].istart 7ad5fda789ef4e272ca3d9ff59f round[ ].is_row 7a9f2789d5f52effd9f3dca4ea7 round[ ].is_ox d6e7c3df25779e626e8689 round[ ].ik_sch 549932df85576893ed9ce2c974e round[ ].ik_add e9f74eec232f6f2ccf2353c2c7 round[ 2].istart 54d99a6a9a596f4ea72f round[ 2].is_row 54f456d97e96a92fa9aa round[ 2].is_ox fde3ad25e5dd73547964effe37f round[ 2].ik_sch 47438735a4c659e6af4aef7ad2 round[ 2].ik_add aa3de7af956ed552ca5f44d23 round[ 3].istart 3ec22c6fcf768da8567f67495 43

Appendix C (continued) round[ 3].is_row 3e75766c4678dfc2295f6a8fc round[ 3].is_ox d876cf79c43a45594add66ff4f round[ 3].ik_sch 4f97ae35fe28c44adf4d4ea9c26 round[ 3].ik_add c57ec59a9d286f5f4e98c63439 round[ 4].istart 45824c6868a499f82e5f5554c round[ 4].is_row 45f86858552e4624c5f998a4c round[ 4].is_ox c62fe9f75eedc3cc79395d84f9cf5d round[ 4].ik_sch 5e39f7df7a69296a7553dcaa3f6 round[ 4].ik_add 986ee74f87f5562c49c8e5ad36 round[ 5].istart e8da69477d4653ff7f5e2e747dd4f round[ 5].is_row e847f5654dadde23f7764fe7f7d49 round[ 5].is_ox c8677c97ac93252799226996 round[ 5].ik_sch 3caaa3e8a99f9de5f3af57adf622aa round[ 5].ik_add f4cd45432e554d75fd6c5dd33c round[ 6].istart 36339d5f9539269f2c92dc446d23 round[ 6].is_row 364926f9336d2d9f59d23c42c395 round[ 6].is_ox 247242369663fa6ed27532884256c round[ 6].ik_sch 47f7f7c95353e3f96c32cfd58dfd round[ 6].ik_add 638579ffc538df997e478e7547d69 round[ 7].istart 2d6d7ef3f33e3349362dd5f2c7 round[ 7].is_row 2df2343f6d2dd9337ec7536e3f round[ 7].is_ox fa636a2825339c94668a357244d7 round[ 7].ik_sch 6ff744ed2c2c9f6c59cf469f4 round[ 7].ik_add 4c9ce66f77f762c3f868e534df256 round[ 8].istart 3d92268fc74f735767cec59e2d round[ 8].is_row 359c73fcd9ee5774222dc67f68 round[ 8].is_ox 495598f55e5d7adaca94fafa63f7 44

Appendix C (continued) round[ 8].ik_sch 692cf643ddfe9c56833fe round[ 8].ik_add ff8796843d86a56455fa773ad9 round[ 9].istart a7ea6997ad739d8c9ca45f686 round[ 9].is_row a76ca997e845d8ada6fc97369 round[ 9].is_ox 89d8e8855ace682d843d8c28fe4 round[ 9].ik_sch d6aa74fdd2af72fadaa678fd6a76fe round[ 9].ik_add 5f7264557f5c92f7e329d9f9a round[].istart 6353e8c96e4cd775acade7 round[].is_row 63ca74953d5cd6ee7a7e8c round[].is_ox 23456789acdef round[].ik_sch 23456789acdef round[].ioutput 2233445566778899aaccddeeff AES-92 (Nk=6, Nr=2) PLAINTEXT: 2233445566778899aaccddeeff KEY: 23456789acdef234567 CIPHER (ENCRYPT): round[ ].input 2233445566778899aaccddeeff round[ ].k_sch 23456789acdef round[ ].start 23456789acdef round[ ].s_ox 63ca74953d5cd6ee7a7e8c round[ ].s_row 6353e8c96e4cd775acade7 round[ ].m_col 5f7264557f5c92f7e329d9f9a round[ ].k_sch 2345675846f2f95c43f4fe round[ 2].start 4f6376643eaa85aff8c9d4fade4 round[ 2].s_ox 84f386faeac97794dd7832dd769 round[ 2].s_row 84edd69a4d76f792d389783fac7 round[ 2].m_col 9f487f794f955f662afc86ad7fa29 45

Appendix C (continued) round[ 2].k_sch 544afef55847ffa4856e2e95c43f4fe round[ 3].start c288c7d2af9c62aa6442825fd7 round[ 3].s_ox f77c64f579deaaac432c3d37cfe round[ 3].s_row f543efaccf64aa37cde3d77792c round[ 3].m_col 7a53ecf9d75ac4efc79674cc round[ 3].k_sch 4f9493cad4d48f4387342 round[ 4].start f75c7778a327c8ed8cfefca6c37f53 round[ 4].s_ox 684af5cacce85564878242ed2ed round[ 4].s_row 68cc8edad2c642ef555244ae878 round[ 4].m_col 7ae98dac6d4a6944dd6e2d3e round[ 4].k_sch 58e5a4a2a5557eff5462458c round[ 5].start 22ffc96a847446496f9c64ae2532 round[ 5].s_ox 936dd47c2fa9283439ade43e43f23 round[ 5].s_row 93faa23c293f4743e4dd8343692de round[ 5].m_col aaa75534cffe57cef6f98efc3e6 round[ 5].k_sch 2a5443a2f8f662e3a95d664c8 round[ 6].start 82e776fdd8a8d8c3c965dfee round[ 6].s_ox cdc972c53854a47e5d64c76594cc28 round[ 6].s_row cd54c7283864cc55d4c727e9c9a465 round[ 6].m_col 92f748fd96e937d622d7725a8a5c round[ 6].k_sch f5857297448d7edfc6ca87f33e3c round[ 7].start 67effd4e2ae3dfdcef3d7893 round[ 7].s_ox 8572a542fe57279e86c8df27c44 round[ 7].s_row 85e5c842f864549eca7277272df round[ 7].m_col e93e78f57d4227ef652758accc round[ 7].k_sch e59768359693457c9ea35fe round[ 8].start c37dce622668accd6d3a2c 46

Appendix C (continued) round[ 8].s_ox fe757fe7c8e93477f7e4f6987 round[ 8].s_row fe7c7e7fe7f87479593f678e4 round[ 8].m_col 6cf5edf996ea69c4ef2cfc25762 round[ 8].k_sch ea372a9953967c439e77ff25e round[ 9].start 7255dad3f83ed6c64d527c round[ 9].s_ox 4fc5766766c7caed757f97 round[ 9].s_row 46c576d766e757ca9fc77f round[ 9].m_col 7478cdce8a58d4327a9988262 round[ 9].k_sch dd7ee887e2fff6868fc842f9dcc54 round[].start a96254968af4e94d2d2fc44336 round[].s_ox d36f37297efe8d7a3758cca5 round[].s_row d37e37597aa28dc37e8c6ff5 round[].m_col d73cc2d8f6ae8cf2dd983d422e round[].k_sch 859f5f237a8d5a3dcc2952eefd63a round[].start 88ec93ef5e7e46cc32f4c96d2944 round[].s_ox c4cedcae694694e423fdd6f522fa round[].s_row c494ffae62322a45dc4e6fce69dd round[].m_col 7d729336d677dc8f28238ef7 round[].k_sch de6e7827cdf2ca2238fd8aeda32 round[2].start af73eecd856228f27f2d585 round[2].s_ox 79a92e99c3e6cdaa3476ccf7397 round[2].s_row 793e76979c343e9aa72dfa96ccc round[2].k_sch a497a33a78dc9c48c27e3a4d5d round[2].output dda97ca4864cdfe6eaf7aecd79 INVERSE CIPHER (DECRYPT): round[ ].iinput dda97ca4864cdfe6eaf7aecd79 47

Appendix C (continued) round[ ].ik_sch a497a33a78dc9c48c27e3a4d5d round[ ].istart 793e76979c343e9aa72dfa96ccc round[ ].is_row 79a92e99c3e6cdaa3476ccf7397 round[ ].is_ox af73eecd856228f27f2d585 round[ ].ik_sch de6e7827cdf2ca2238fd8aeda32 round[ ].ik_add 7d729336d677dc8f28238ef7 round[ 2].istart c494ffae62322a45dc4e6fce69dd round[ 2].is_row c4cedcae694694e423fdd6f522fa round[ 2].is_ox 88ec93ef5e7e46cc32f4c96d2944 round[ 2].ik_sch 859f5f237a8d5a3dcc2952eefd63a round[ 2].ik_add d73cc2d8f6ae8cf2dd983d422e round[ 3].istart d37e37597aa28dc37e8c6ff5 round[ 3].is_row d36f37297efe8d7a3758cca5 round[ 3].is_ox a96254968af4e94d2d2fc44336 round[ 3].ik_sch dd7ee887e2fff6868fc842f9dcc54 round[ 3].ik_add 7478cdce8a58d4327a9988262 round[ 4].istart 46c576d766e757ca9fc77f round[ 4].is_row 4fc5766766c7caed757f97 round[ 4].is_ox 7255dad3f83ed6c64d527c round[ 4].ik_sch ea372a9953967c439e77ff25e round[ 4].ik_add 6cf5edf996ea69c4ef2cfc25762 round[ 5].istart fe7c7e7fe7f87479593f678e4 round[ 5].is_row fe757fe7c8e93477f7e4f6987 round[ 5].is_ox c37dce622668accd6d3a2c round[ 5].ik_sch e59768359693457c9ea35fe round[ 5].ik_add e93e78f57d4227ef652758accc round[ 6].istart 85e5c842f864549eca7277272df 48

Appendix C (continued) round[ 6].is_row 8572a542fe57279e86c8df27c44 round[ 6].is_ox 67effd4e2ae3dfdcef3d7893 round[ 6].ik_sch f5857297448d7edfc6ca87f33e3c round[ 6].ik_add 92f748fd96e937d622d7725a8a5c round[ 7].istart cd54c7283864cc55d4c727e9c9a465 round[ 7].is_row cdc972c53854a47e5d64c76594cc28 round[ 7].is_ox 82e776fdd8a8d8c3c965dfee round[ 7].ik_sch 2a5443a2f8f662e3a95d664c8 round[ 7].ik_add aaa75534cffe57cef6f98efc3e6 round[ 8].istart 93faa23c293f4743e4dd8343692de round[ 8].is_row 936dd47c2fa9283439ade43e43f23 round[ 8].is_ox 22ffc96a847446496f9c64ae2532 round[ 8].ik_sch 58e5a4a2a5557eff5462458c round[ 8].ik_add 7ae98dac6d4a6944dd6e2d3e round[ 9].istart 68cc8edad2c642ef555244ae878 round[ 9].is_row 684af5cacce85564878242ed2ed round[ 9].is_ox f75c7778a327c8ed8cfefca6c37f53 round[ 9].ik_sch 4f9493cad4d48f4387342 round[ 9].ik_add 7a53ecf9d75ac4efc79674cc round[].istart f543efaccf64aa37cde3d77792c round[].is_row f77c64f579deaaac432c3d37cfe round[].is_ox c288c7d2af9c62aa6442825fd7 round[].ik_sch 544afef55847ffa4856e2e95c43f4fe round[].ik_add 9f487f794f955f662afc86ad7fa29 round[].istart 84edd69a4d76f792d389783fac7 round[].is_row 84f386faeac97794dd7832dd769 round[].is_ox 4f6376643eaa85aff8c9d4fade4 49

Appendix C (continued) round[].ik_sch 2345675846f2f95c43f4fe round[].ik_add 5f7264557f5c92f7e329d9f9a round[2].istart 6353e8c96e4cd775acade7 round[2].is_row 63ca74953d5cd6ee7a7e8c round[2].is_ox 23456789acdef round[2].ik_sch 23456789acdef round[2].ioutput 2233445566778899aaccddeeff AES-256 (Nk=8, Nr=4) PLAINTEXT: 2233445566778899aaccddeeff KEY: 23456789acdef23456789acdef CIPHER (ENCRYPT): round[ ].input 2233445566778899aaccddeeff round[ ].k_sch 23456789acdef round[ ].start 23456789acdef round[ ].s_ox 63ca74953d5cd6ee7a7e8c round[ ].s_row 6353e8c96e4cd775acade7 round[ ].m_col 5f7264557f5c92f7e329d9f9a round[ ].k_sch 23456789acdef round[ 2].start 4f6376643eaa85efa7232a4e75 round[ 2].s_ox 84f386faeac97df5cfd237c49946 round[ 2].s_row 84efd6a5c946fdf4938977cfac23 round[ 2].m_col d2a395d26ac438d92443e65da95 round[ 2].k_sch a573c29fa76c498a97fce93a572c9c round[ 3].start 859fc28aca78ed8aadc42f69 round[ 3].s_ox adcf257e9c63ec557e95c5ef round[ 3].s_row ad9c7e7e55ef25c5fecc6395 round[ 3].m_col 8dcecc9d8723678ce88a5d 5

Appendix C (continued) round[ 3].k_sch 65a8cd244edaa5da4c64ade round[ 4].start 975c66cc9f3fa8a93a28df8eef63 round[ 4].s_ox 884a3378fd75c2d38349e9f876f round[ 4].s_row 88d34ff87678d3f833c294a759e round[ 4].m_col 2822d8ae6f275faf3a78c33 round[ 4].k_sch ae87dffff68a68ed5f3fc567 round[ 5].start c5f27a47e4ff92c5c47554 round[ 5].s_ox 9c689a349fe8499fda678f25592 round[ 5].s_row 9cfa6249fd59a39958984f26e78 round[ 5].m_col ae65a974ef822d73f567d64c877 round[ 5].k_sch 6def486fa54f9275f8e5373858d round[ 6].start c357aae457a2c7d28a8dc99fa round[ 6].s_ox 2e5acf8af6ea9e73ac67a34c286ee2d round[ 6].s_row 2e6e7a2dafc6eef83a86ace7c25a934 round[ 6].m_col 95c33c2e9d29ae25cdefa8cc7 round[ 6].k_sch c656827fc9a79976f294cec6cd5598 round[ 7].start 7f7443c4e243ecc85d8375d54c round[ 7].s_ox d2c583af2f36278fec4cec9d329 round[ 7].s_row d22fc29ffe3a789d832ecc5364c round[ 7].m_col e9ec3ee7c9e87d7535e9ed6944 round[ 7].k_sch 3de23a75524775e727f9e4547cf39 round[ 8].start d653a4696cacf5acaa5d96c5e7d round[ 8].s_ox f6ed49f95e6576e74624c56558ff round[ 8].s_row f6e62ff57458f9e5497656ed654c round[ 8].m_col 574c8669da98435a83e62ca974a5ea round[ 8].k_sch dc95fc27948ad5245a4c87c2f round[ 9].start 5aa858395fd28d7d5ea38868f39c5 5

Appendix C (continued) round[ 9].s_ox ec26a2cf55dff6f8ac445d56a6 round[ 9].s_row e5aa6cff85626d6aff45c25dc4 round[ 9].m_col f77ee3d2ccadc543a83f4ef96ac3 round[ 9].k_sch 45f5a6672d3873d4d3364a82a round[].start 4a82485c57e7e47643de5c2af3e8c9 round[].s_ox d6352da6f3f3a4327d9fee5d9dd round[].s_row d6f3d9dda6279d43d52ae53f3fe round[].m_col d86fea748fc4f463fce933233 round[].k_sch 7ccff7ce4fe543e6fd26a7df round[].start c497f6ca33aa7e9aa33525ec round[].s_ox 783c54274e28e5eacc7e2d5ce round[].s_row 78e2acce74ed5425c5ee238c7 round[].m_col af86945d6edd387e5fedd5c893 round[].k_sch fafafee7a82979d7a5644a3afe64 round[2].s_ox cfde28f448ac539d5c338538ed round[2].s_row cf4dedf4938853852ac33de85c round[2].start 5f9c6afac634aa549fa766677653 round[2].m_col 7427fae4d8a695269ce83d35e392 round[2].k_sch 254fe79f525883d55a72ca round[3].start 56649543539534f86e492252 round[3].s_ox d33f22aaed2a7faf44697c4f3ffd round[3].s_row ded44fdaf3f2afa4ff277c332a69 round[3].m_col 2c2a8236f54a72c75eeeda4f round[3].k_sch 4e5a6699a9f24fe7e572aacdf8cdea round[4].start 627ce9999d5aaac945ecf423f56da5 round[4].s_ox aa2856ee5eeacdd6ecef26e63c6 round[4].s_row aa5ece6ee6e3c56dde68ac262ef 52

Appendix C (continued) round[4].k_sch 24fc79ccf979e937ac23c6d68de36 round[4].output 8ea27ca56745feafc499449689 INVERSE CIPHER (DECRYPT): round[ ].iinput 8ea27ca56745feafc499449689 round[ ].ik_sch 24fc79ccf979e937ac23c6d68de36 round[ ].istart aa5ece6ee6e3c56dde68ac262ef round[ ].is_row aa2856ee5eeacdd6ecef26e63c6 round[ ].is_ox 627ce9999d5aaac945ecf423f56da5 round[ ].ik_sch 4e5a6699a9f24fe7e572aacdf8cdea round[ ].ik_add 2c2a8236f54a72c75eeeda4f round[ 2].istart ded44fdaf3f2afa4ff277c332a69 round[ 2].is_row d33f22aaed2a7faf44697c4f3ffd round[ 2].is_ox 56649543539534f86e492252 round[ 2].ik_sch 254fe79f525883d55a72ca round[ 2].ik_add 7427fae4d8a695269ce83d35e392 round[ 3].istart cf4dedf4938853852ac33de85c round[ 3].is_row cfde28f448ac539d5c338538ed round[ 3].is_ox 5f9c6afac634aa549fa766677653 round[ 3].ik_sch fafafee7a82979d7a5644a3afe64 round[ 3].ik_add af86945d6edd387e5fedd5c893 round[ 4].istart 78e2acce74ed5425c5ee238c7 round[ 4].is_row 783c54274e28e5eacc7e2d5ce round[ 4].is_ox c497f6ca33aa7e9aa33525ec round[ 4].ik_sch 7ccff7ce4fe543e6fd26a7df round[ 4].ik_add d86fea748fc4f463fce933233 round[ 5].istart d6f3d9dda6279d43d52ae53f3fe 53

Appendix C (continued) round[ 5].is_row d6352da6f3f3a4327d9fee5d9dd round[ 5].is_ox 4a82485c57e7e47643de5c2af3e8c9 round[ 5].ik_sch 45f5a6672d3873d4d3364a82a round[ 5].ik_add f77ee3d2ccadc543a83f4ef96ac3 round[ 6].istart e5aa6cff85626d6aff45c25dc4 round[ 6].is_row ec26a2cf55dff6f8ac445d56a6 round[ 6].is_ox 5aa858395fd28d7d5ea38868f39c5 round[ 6].ik_sch dc95fc27948ad5245a4c87c2f round[ 6].ik_add 574c8669da98435a83e62ca974a5ea round[ 7].istart f6e62ff57458f9e5497656ed654c round[ 7].is_row f6ed49f95e6576e74624c56558ff round[ 7].is_ox d653a4696cacf5acaa5d96c5e7d round[ 7].ik_sch 3de23a75524775e727f9e4547cf39 round[ 7].ik_add e9ec3ee7c9e87d7535e9ed6944 round[ 8].istart d22fc29ffe3a789d832ecc5364c round[ 8].is_row d2c583af2f36278fec4cec9d329 round[ 8].is_ox 7f7443c4e243ecc85d8375d54c round[ 8].ik_sch c656827fc9a79976f294cec6cd5598 round[ 8].ik_add 95c33c2e9d29ae25cdefa8cc7 round[ 9].istart 2e6e7a2dafc6eef83a86ace7c25a934 round[ 9].is_row 2e5acf8af6ea9e73ac67a34c286ee2d round[ 9].is_ox c357aae457a2c7d28a8dc99fa round[ 9].ik_sch 6def486fa54f9275f8e5373858d round[ 9].ik_add ae65a974ef822d73f567d64c877 round[].istart 9cfa6249fd59a39958984f26e78 round[].is_row 9c689a349fe8499fda678f25592 round[].is_ox c5f27a47e4ff92c5c47554 54

Appendix C (continued) round[].ik_sch ae87dffff68a68ed5f3fc567 round[].ik_add 2822d8ae6f275faf3a78c33 round[].istart 88d34ff87678d3f833c294a759e round[].is_row 884a3378fd75c2d38349e9f876f round[].is_ox 975c66cc9f3fa8a93a28df8eef63 round[].ik_sch 65a8cd244edaa5da4c64ade round[].ik_add 8dcecc9d8723678ce88a5d round[2].istart ad9c7e7e55ef25c5fecc6395 round[2].is_row adcf257e9c63ec557e95c5ef round[2].is_ox 859fc28aca78ed8aadc42f69 round[2].ik_sch a573c29fa76c498a97fce93a572c9c round[2].ik_add d2a395d26ac438d92443e65da95 round[3].istart 84efd6a5c946fdf4938977cfac23 round[3].is_row 84f386faeac97df5cfd237c49946 round[3].is_ox 4f6376643eaa85efa7232a4e75 round[3].ik_sch 23456789acdef round[3].ik_add 5f7264557f5c92f7e329d9f9a round[4].istart 6353e8c96e4cd775acade7 round[4].is_row 63ca74953d5cd6ee7a7e8c round[4].is_ox 23456789acdef round[4].ik_sch 23456789acdef round[4].ioutput 2233445566778899aaccddeeff 55

Appendix D: VHDL Design Code lirary ieee; use ieee.std_logic_64.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; package rijndael_package is sutype SLV_8 is std_logic_vector(7 downto ); sutype STATE_TYPE is std_logic_vector(27 downto ); sutype SLV_28 is std_logic_vector(27 downto ); sutype SLV_32 is std_logic_vector(3 downto ); sutype round_type is integer range to 6; function SBOX_LOOKUP (a: SLV_8) return SLV_8; function INV_SBOX_LOOKUP (a: SLV_8) return SLV_8; function BYTE_SUB_FUNCT (state: STATE_TYPE) return STATE_TYPE; function INV_BYTE_SUB_FUNCT (state: STATE_TYPE) return STATE_TYPE; function SHIFT_ROW_FUNCT (state: STATE_TYPE) return STATE_TYPE; function INV_SHIFT_ROW_FUNCT (state: STATE_TYPE) return STATE_TYPE; function MIX_COLUMN_FUNCT (state: STATE_TYPE) return STATE_TYPE; function POLY_MULTE_FUNCT (a: SLV_8; : SLV_8) return SLV_8; function POLY_MULTD_FUNCT (a: SLV_8; : SLV_8) return SLV_8; function INV_MIX_COLUMN_FUNCT (state: STATE_TYPE) return STATE_TYPE; function ADD_ROUNDKEY_FUNCT (roundkey, state: STATE_TYPE) return STATE_TYPE; function ROUNDKEY_GEN (roundkey: STATE_TYPE; round: round_type) return STATE_TYPE; end package rijndael_package; 56

Appendix D (continued) package ody rijndael_package is function SBOX_LOOKUP (a: SLV_8) return SLV_8 is variale temp: SLV_8; egin case a is when x"" => temp := x"63"; when x"" => temp := x"7c"; when x"2" => temp := x"77"; when x"3" => temp := x"7"; when x"4" => temp := x"f2"; when x"5" => temp := x"6"; when x"6" => temp := x"6f"; when x"7" => temp := x"c5"; when x"8" => temp := x"3"; when x"9" => temp := x""; when x"a" => temp := x"67"; when x"" => temp := x"2"; when x"c" => temp := x"fe"; when x"d" => temp := x"d7"; when x"e" => temp := x"a"; when x"f" => temp := x"76"; when x"" => temp := x"ca"; when x"" => temp := x"82"; when x"2" => temp := x"c9"; when x"3" => temp := x"7d"; when x"4" => temp := x"fa"; when x"5" => temp := x"59"; when x"6" => temp := x"47"; when x"7" => temp := x"f"; when x"8" => temp := x"ad"; when x"9" => temp := x"d4"; when x"a" => temp := x"a2"; when x"" => temp := x"af"; when x"c" => temp := x"9c"; when x"d" => temp := x"a4"; when x"e" => temp := x"72"; when x"f" => temp := x"c"; 57

Appendix D (continued) when x"2" => temp := x"7"; when x"2" => temp := x"fd"; when x"22" => temp := x"93"; when x"23" => temp := x"26"; when x"24" => temp := x"36"; when x"25" => temp := x"3f"; when x"26" => temp := x"f7"; when x"27" => temp := x"cc"; when x"28" => temp := x"34"; when x"29" => temp := x"a5"; when x"2a" => temp := x"e5"; when x"2" => temp := x"f"; when x"2c" => temp := x"7"; when x"2d" => temp := x"d8"; when x"2e" => temp := x"3"; when x"2f" => temp := x"5"; when x"3" => temp := x"4"; when x"3" => temp := x"c7"; when x"32" => temp := x"23"; when x"33" => temp := x"c3"; when x"34" => temp := x"8"; when x"35" => temp := x"96"; when x"36" => temp := x"5"; when x"37" => temp := x"9a"; when x"38" => temp := x"7"; when x"39" => temp := x"2"; when x"3a" => temp := x"8"; when x"3" => temp := x"e2"; when x"3c" => temp := x"e"; when x"3d" => temp := x"27"; when x"3e" => temp := x"2"; when x"3f" => temp := x"75"; 58

Appendix D (continued) when x"4" => temp := x"9"; when x"4" => temp := x"83"; when x"42" => temp := x"2c"; when x"43" => temp := x"a"; when x"44" => temp := x""; when x"45" => temp := x"6e"; when x"46" => temp := x"5a"; when x"47" => temp := x"a"; when x"48" => temp := x"52"; when x"49" => temp := x"3"; when x"4a" => temp := x"d6"; when x"4" => temp := x"3"; when x"4c" => temp := x"29"; when x"4d" => temp := x"e3"; when x"4e" => temp := x"2f"; when x"4f" => temp := x"84"; when x"5" => temp := x"53"; when x"5" => temp := x"d"; when x"52" => temp := x""; when x"53" => temp := x"ed"; when x"54" => temp := x"2"; when x"55" => temp := x"fc"; when x"56" => temp := x""; when x"57" => temp := x"5"; when x"58" => temp := x"6a"; when x"59" => temp := x"c"; when x"5a" => temp := x"e"; when x"5" => temp := x"39"; when x"5c" => temp := x"4a"; when x"5d" => temp := x"4c"; when x"5e" => temp := x"58"; when x"5f" => temp := x"cf"; 59

Appendix D (continued) when x"6" => temp := x"d"; when x"6" => temp := x"ef"; when x"62" => temp := x"aa"; when x"63" => temp := x"f"; when x"64" => temp := x"43"; when x"65" => temp := x"4d"; when x"66" => temp := x"33"; when x"67" => temp := x"85"; when x"68" => temp := x"45"; when x"69" => temp := x"f9"; when x"6a" => temp := x"2"; when x"6" => temp := x"7f"; when x"6c" => temp := x"5"; when x"6d" => temp := x"3c"; when x"6e" => temp := x"9f"; when x"6f" => temp := x"a8"; when x"7" => temp := x"5"; when x"7" => temp := x"a3"; when x"72" => temp := x"4"; when x"73" => temp := x"8f"; when x"74" => temp := x"92"; when x"75" => temp := x"9d"; when x"76" => temp := x"38"; when x"77" => temp := x"f5"; when x"78" => temp := x"c"; when x"79" => temp := x"6"; when x"7a" => temp := x"da"; when x"7" => temp := x"2"; when x"7c" => temp := x""; when x"7d" => temp := x"ff"; when x"7e" => temp := x"f3"; when x"7f" => temp := x"d2"; 6

Appendix D (continued) when x"8" => temp := x"cd"; when x"8" => temp := x"c"; when x"82" => temp := x"3"; when x"83" => temp := x"ec"; when x"84" => temp := x"5f"; when x"85" => temp := x"97"; when x"86" => temp := x"44"; when x"87" => temp := x"7"; when x"88" => temp := x"c4"; when x"89" => temp := x"a7"; when x"8a" => temp := x"7e"; when x"8" => temp := x"3d"; when x"8c" => temp := x"64"; when x"8d" => temp := x"5d"; when x"8e" => temp := x"9"; when x"8f" => temp := x"73"; when x"9" => temp := x"6"; when x"9" => temp := x"8"; when x"92" => temp := x"4f"; when x"93" => temp := x"dc"; when x"94" => temp := x"22"; when x"95" => temp := x"2a"; when x"96" => temp := x"9"; when x"97" => temp := x"88"; when x"98" => temp := x"46"; when x"99" => temp := x"ee"; when x"9a" => temp := x"8"; when x"9" => temp := x"4"; when x"9c" => temp := x"de"; when x"9d" => temp := x"5e"; when x"9e" => temp := x""; when x"9f" => temp := x"d"; 6

Appendix D (continued) when x"a" => temp := x"e"; when x"a" => temp := x"32"; when x"a2" => temp := x"3a"; when x"a3" => temp := x"a"; when x"a4" => temp := x"49"; when x"a5" => temp := x"6"; when x"a6" => temp := x"24"; when x"a7" => temp := x"5c"; when x"a8" => temp := x"c2"; when x"a9" => temp := x"d3"; when x"aa" => temp := x"ac"; when x"a" => temp := x"62"; when x"ac" => temp := x"9"; when x"ad" => temp := x"95"; when x"ae" => temp := x"e4"; when x"af" => temp := x"79"; when x"" => temp := x"e7"; when x"" => temp := x"c8"; when x"2" => temp := x"37"; when x"3" => temp := x"6d"; when x"4" => temp := x"8d"; when x"5" => temp := x"d5"; when x"6" => temp := x"4e"; when x"7" => temp := x"a9"; when x"8" => temp := x"6c"; when x"9" => temp := x"56"; when x"a" => temp := x"f4"; when x"" => temp := x"ea"; when x"c" => temp := x"65"; when x"d" => temp := x"7a"; when x"e" => temp := x"ae"; when x"f" => temp := x"8"; 62

Appendix D (continued) when x"c" => temp := x"a"; when x"c" => temp := x"78"; when x"c2" => temp := x"25"; when x"c3" => temp := x"2e"; when x"c4" => temp := x"c"; when x"c5" => temp := x"a6"; when x"c6" => temp := x"4"; when x"c7" => temp := x"c6"; when x"c8" => temp := x"e8"; when x"c9" => temp := x"dd"; when x"ca" => temp := x"74"; when x"c" => temp := x"f"; when x"cc" => temp := x"4"; when x"cd" => temp := x"d"; when x"ce" => temp := x"8"; when x"cf" => temp := x"8a"; when x"d" => temp := x"7"; when x"d" => temp := x"3e"; when x"d2" => temp := x"5"; when x"d3" => temp := x"66"; when x"d4" => temp := x"48"; when x"d5" => temp := x"3"; when x"d6" => temp := x"f6"; when x"d7" => temp := x"e"; when x"d8" => temp := x"6"; when x"d9" => temp := x"35"; when x"da" => temp := x"57"; when x"d" => temp := x"9"; when x"dc" => temp := x"86"; when x"dd" => temp := x"c"; when x"de" => temp := x"d"; when x"df" => temp := x"9e"; 63

Appendix D (continued) end case; when x"e" => temp := x"e"; when x"e" => temp := x"f8"; when x"e2" => temp := x"98"; when x"e3" => temp := x""; when x"e4" => temp := x"69"; when x"e5" => temp := x"d9"; when x"e6" => temp := x"8e"; when x"e7" => temp := x"94"; when x"e8" => temp := x"9"; when x"e9" => temp := x"e"; when x"ea" => temp := x"87"; when x"e" => temp := x"e9"; when x"ec" => temp := x"ce"; when x"ed" => temp := x"55"; when x"ee" => temp := x"28"; when x"ef" => temp := x"df"; when x"f" => temp := x"8c"; when x"f" => temp := x"a"; when x"f2" => temp := x"89"; when x"f3" => temp := x"d"; when x"f4" => temp := x"f"; when x"f5" => temp := x"e6"; when x"f6" => temp := x"42"; when x"f7" => temp := x"68"; when x"f8" => temp := x"4"; when x"f9" => temp := x"99"; when x"fa" => temp := x"2d"; when x"f" => temp := x"f"; when x"fc" => temp := x""; when x"fd" => temp := x"54"; when x"fe" => temp := x""; when x"ff" => temp := x"6"; when others => null; return temp; end function SBOX_LOOKUP; 64

Appendix D (continued) function INV_SBOX_LOOKUP (a: SLV_8) return SLV_8 is egin variale temp: SLV_8; case a is when x"" => temp := x"52"; when x"" => temp := x"9"; when x"2" => temp := x"6a"; when x"3" => temp := x"d5"; when x"4" => temp := x"3"; when x"5" => temp := x"36"; when x"6" => temp := x"a5"; when x"7" => temp := x"38"; when x"8" => temp := x"f"; when x"9" => temp := x"4"; when x"a" => temp := x"a3"; when x"" => temp := x"9e"; when x"c" => temp := x"8"; when x"d" => temp := x"f3"; when x"e" => temp := x"d7"; when x"f" => temp := x"f"; when x"" => temp := x"7c"; when x"" => temp := x"e3"; when x"2" => temp := x"39"; when x"3" => temp := x"82"; when x"4" => temp := x"9"; when x"5" => temp := x"2f"; when x"6" => temp := x"ff"; when x"7" => temp := x"87"; when x"8" => temp := x"34"; when x"9" => temp := x"8e"; when x"a" => temp := x"43"; when x"" => temp := x"44"; when x"c" => temp := x"c4"; when x"d" => temp := x"de"; when x"e" => temp := x"e9"; when x"f" => temp := x"c"; 65

Appendix D (continued) when x"2" => temp := x"54"; when x"2" => temp := x"7"; when x"22" => temp := x"94"; when x"23" => temp := x"32"; when x"24" => temp := x"a6"; when x"25" => temp := x"c2"; when x"26" => temp := x"23"; when x"27" => temp := x"3d"; when x"28" => temp := x"ee"; when x"29" => temp := x"4c"; when x"2a" => temp := x"95"; when x"2" => temp := x""; when x"2c" => temp := x"42"; when x"2d" => temp := x"fa"; when x"2e" => temp := x"c3"; when x"2f" => temp := x"49"; when x"3" => temp := x"8"; when x"3" => temp := x"2e"; when x"32" => temp := x"a"; when x"33" => temp := x"66"; when x"34" => temp := x"28"; when x"35" => temp := x"d9"; when x"36" => temp := x"24"; when x"37" => temp := x"2"; when x"38" => temp := x"76"; when x"39" => temp := x"5"; when x"3a" => temp := x"a2"; when x"3" => temp := x"49"; when x"3c" => temp := x"6d"; when x"3d" => temp := x"8"; when x"3e" => temp := x"d"; 66

Appendix D (continued) when x"4" => temp := x"72"; when x"4" => temp := x"f8"; when x"42" => temp := x"f6"; when x"43" => temp := x"64"; when x"44" => temp := x"86"; when x"45" => temp := x"68"; when x"46" => temp := x"98"; when x"47" => temp := x"6"; when x"48" => temp := x"d4"; when x"49" => temp := x"a4"; when x"4a" => temp := x"5c"; when x"4" => temp := x"cc"; when x"4c" => temp := x"5d"; when x"4d" => temp := x"65"; when x"4e" => temp := x"6"; when x"4f" => temp := x"92"; when x"5" => temp := x"6c"; when x"5" => temp := x"7"; when x"52" => temp := x"48"; when x"53" => temp := x"5"; when x"54" => temp := x"fd"; when x"55" => temp := x"ed"; when x"56" => temp := x"9"; when x"57" => temp := x"da"; when x"58" => temp := x"5e"; when x"59" => temp := x"5"; when x"5a" => temp := x"46"; when x"5" => temp := x"57"; when x"5c" => temp := x"a7"; when x"5d" => temp := x"8d"; when x"5e" => temp := x"9d"; when x"5f" => temp := x"84"; 67

Appendix D (continued) when x"6" => temp := x"9"; when x"6" => temp := x"d8"; when x"62" => temp := x"a"; when x"63" => temp := x""; when x"64" => temp := x"8c"; when x"65" => temp := x"c"; when x"66" => temp := x"d3"; when x"67" => temp := x"a"; when x"68" => temp := x"f7"; when x"69" => temp := x"e4"; when x"6a" => temp := x"58"; when x"6" => temp := x"5"; when x"6c" => temp := x"8"; when x"6d" => temp := x"3"; when x"6e" => temp := x"45"; when x"6f" => temp := x"6"; when x"7" => temp := x"d"; when x"7" => temp := x"2c"; when x"72" => temp := x"e"; when x"73" => temp := x"8f"; when x"74" => temp := x"ca"; when x"75" => temp := x"3f"; when x"76" => temp := x"f"; when x"77" => temp := x"2"; when x"78" => temp := x"c"; when x"79" => temp := x"af"; when x"7a" => temp := x"d"; when x"7" => temp := x"3"; when x"7c" => temp := x""; when x"7d" => temp := x"3"; when x"7e" => temp := x"8a"; when x"7f" => temp := x"6"; 68

Appendix D (continued) when x"8" => temp := x"3a"; when x"8" => temp := x"9"; when x"82" => temp := x""; when x"83" => temp := x"4"; when x"84" => temp := x"4f"; when x"85" => temp := x"67"; when x"86" => temp := x"dc"; when x"87" => temp := x"ea"; when x"88" => temp := x"97"; when x"89" => temp := x"f2"; when x"8a" => temp := x"cf"; when x"8" => temp := x"ce"; when x"8c" => temp := x"f"; when x"8d" => temp := x"4"; when x"8e" => temp := x"e6"; when x"8f" => temp := x"73"; when x"9" => temp := x"96"; when x"9" => temp := x"ac"; when x"92" => temp := x"74"; when x"93" => temp := x"22"; when x"94" => temp := x"e7"; when x"95" => temp := x"ad"; when x"96" => temp := x"35"; when x"97" => temp := x"85"; when x"98" => temp := x"e2"; when x"99" => temp := x"f9"; when x"9a" => temp := x"37"; when x"9" => temp := x"e8"; when x"9c" => temp := x"c"; when x"9d" => temp := x"75"; when x"9e" => temp := x"df"; when x"9f" => temp := x"6e"; 69

Appendix D (continued) when x"a" => temp := x"47"; when x"a" => temp := x"f"; when x"a2" => temp := x"a"; when x"a3" => temp := x"7"; when x"a4" => temp := x"d"; when x"a5" => temp := x"29"; when x"a6" => temp := x"c5"; when x"a7" => temp := x"89"; when x"a8" => temp := x"6f"; when x"a9" => temp := x"7"; when x"aa" => temp := x"62"; when x"a" => temp := x"e"; when x"ac" => temp := x"aa"; when x"ad" => temp := x"8"; when x"ae" => temp := x"e"; when x"af" => temp := x""; when x"" => temp := x"fc"; when x"" => temp := x"56"; when x"2" => temp := x"3e"; when x"3" => temp := x"4"; when x"4" => temp := x"c6"; when x"5" => temp := x"d2"; when x"6" => temp := x"79"; when x"7" => temp := x"2"; when x"8" => temp := x"9a"; when x"9" => temp := x"d"; when x"a" => temp := x"c"; when x"" => temp := x"fe"; when x"c" => temp := x"78"; when x"d" => temp := x"cd"; when x"e" => temp := x"5a"; when x"f" => temp := x"f4"; 7

Appendix D (continued) when x"c" => temp := x"f"; when x"c" => temp := x"dd"; when x"c2" => temp := x"a8"; when x"c3" => temp := x"33"; when x"c4" => temp := x"88"; when x"c5" => temp := x"7"; when x"c6" => temp := x"c7"; when x"c7" => temp := x"3"; when x"c8" => temp := x""; when x"c9" => temp := x"2"; when x"ca" => temp := x""; when x"c" => temp := x"59"; when x"cc" => temp := x"27"; when x"cd" => temp := x"8"; when x"ce" => temp := x"ec"; when x"cf" => temp := x"5f"; when x"d" => temp := x"6"; when x"d" => temp := x"5"; when x"d2" => temp := x"7f"; when x"d3" => temp := x"a9"; when x"d4" => temp := x"9"; when x"d5" => temp := x"5"; when x"d6" => temp := x"4a"; when x"d7" => temp := x"d"; when x"d8" => temp := x"2d"; when x"d9" => temp := x"e5"; when x"da" => temp := x"7a"; when x"d" => temp := x"9f"; when x"dc" => temp := x"93"; when x"dd" => temp := x"c9"; when x"de" => temp := x"9c"; when x"df" => temp := x"ef"; 7

Appendix D (continued) end case; when x"e" => temp := x"a"; when x"e" => temp := x"e"; when x"e2" => temp := x"3"; when x"e3" => temp := x"4d"; when x"e4" => temp := x"ae"; when x"e5" => temp := x"2a"; when x"e6" => temp := x"f5"; when x"e7" => temp := x""; when x"e8" => temp := x"c8"; when x"e9" => temp := x"e"; when x"ea" => temp := x""; when x"e" => temp := x"3c"; when x"ec" => temp := x"83"; when x"ed" => temp := x"53"; when x"ee" => temp := x"99"; when x"ef" => temp := x"6"; when x"f" => temp := x"7"; when x"f" => temp := x"2"; when x"f2" => temp := x"4"; when x"f3" => temp := x"7e"; when x"f4" => temp := x"a"; when x"f5" => temp := x"77"; when x"f6" => temp := x"d6"; when x"f7" => temp := x"26"; when x"f8" => temp := x"e"; when x"f9" => temp := x"69"; when x"fa" => temp := x"4"; when x"f" => temp := x"63"; when x"fc" => temp := x"55"; when x"fd" => temp := x"2"; when x"fe" => temp := x"c"; when x"ff" => temp := x"7d"; when others => null; return temp; end function INV_SBOX_LOOKUP; 72

Appendix D (continued) function BYTE_SUB_FUNCT (state: STATE_TYPE) return STATE_TYPE is egin variale : STATE_TYPE; variale temp: STATE_TYPE; (27 downto 2) := SBOX_LOOKUP(state(27 downto 2)); (9 downto 2) := SBOX_LOOKUP(state(9 downto 2)); ( downto 4) := SBOX_LOOKUP(state( downto 4)); (3 downto 96) := SBOX_LOOKUP(state(3 downto 96)); (95 downto 88) := SBOX_LOOKUP(state(95 downto 88)); (87 downto 8) := SBOX_LOOKUP(state(87 downto 8)); (79 downto 72) := SBOX_LOOKUP(state(79 downto 72)); (7 downto 64) := SBOX_LOOKUP(state(7 downto 64)); (63 downto 56) := SBOX_LOOKUP(state(63 downto 56)); (55 downto 48) := SBOX_LOOKUP(state(55 downto 48)); (47 downto 4) := SBOX_LOOKUP(state(47 downto 4)); (39 downto 32) := SBOX_LOOKUP(state(39 downto 32)); (3 downto 24) := SBOX_LOOKUP(state(3 downto 24)); (23 downto 6) := SBOX_LOOKUP(state(23 downto 6)); (5 downto 8) := SBOX_LOOKUP(state(5 downto 8)); (7 downto ) := SBOX_LOOKUP(state(7 downto )); temp:=; return temp; end function BYTE_SUB_FUNCT; 73

Appendix D (continued) function INV_BYTE_SUB_FUNCT (state: STATE_TYPE) return STATE_TYPE is variale : STATE_TYPE; variale temp: STATE_TYPE; egin (27 downto 2) := INV_SBOX_LOOKUP(state(27 downto 2)); (9 downto 2) := INV_SBOX_LOOKUP(state(9 downto 2)); ( downto 4) := INV_SBOX_LOOKUP(state( downto 4)); (3 downto 96) := INV_SBOX_LOOKUP(state(3 downto 96)); (95 downto 88) := INV_SBOX_LOOKUP(state(95 downto 88)); (87 downto 8) := INV_SBOX_LOOKUP(state(87 downto 8)); (79 downto 72) := INV_SBOX_LOOKUP state(79 downto 72)); (7 downto 64) := INV_SBOX_LOOKUP(state(7 downto 64)); (63 downto 56) := INV_SBOX_LOOKUP(state(63 downto 56)); (55 downto 48) := INV_SBOX_LOOKUP(state(55 downto 48)); (47 downto 4) := INV_SBOX_LOOKUP( state(47 downto 4)); (39 downto 32) := INV_SBOX_LOOKUP(state(39 downto 32)); (3 downto 24) := INV_SBOX_LOOKUP(state(3 downto 24)); (23 downto 6) := INV_SBOX_LOOKUP(state(23 downto 6)); (5 downto 8) := INV_SBOX_LOOKUP(state(5 downto 8)); (7 downto ) := INV_SBOX_LOOKUP(state(7 downto )); temp:=; return temp; end function INV_BYTE_SUB_FUNCT; 74

Appendix D (continued) function SHIFT_ROW_FUNCT (state: STATE_TYPE) return STATE_TYPE is variale a: STATE_TYPE; variale temp: STATE_TYPE; egin temp(27 downto 2) := state(27 downto 2); temp(9 downto 2) := state(87 downto 8); temp( downto 4) := state(47 downto 4); temp(3 downto 96) := state(7 downto ); temp(95 downto 88) := state(95 downto 88); temp(87 downto 8) := state(55 downto 48); temp(79 downto 72) := state(5 downto 8); temp(7 downto 64) := state(3 downto 96); temp(63 downto 56) := state(63 downto 56); temp(55 downto 48) := state(23 downto 6); temp(47 downto 4) := state( downto 4); temp(39 downto 32) := state(7 downto 64); --t --t --t2 --t3 --t4 --t5 --t6 --t7 --t8 --t9 --t --t temp(3 downto 24) := state(3 downto 24); --t2 temp(23 downto 6) := state(9 downto 2); --t3 temp(5 downto 8) := state(79 downto 72); --t4 temp(7 downto ) := state(39 downto 32); --t5 a:=temp; return a; end function SHIFT_ROW_FUNCT; 75

Appendix D (continued) function INV_SHIFT_ROW_FUNCT (state: STATE_TYPE) return STATE_TYPE is egin variale a: STATE_TYPE; variale temp: STATE_TYPE; temp(27 downto 2) := state(27 downto 2); temp(9 downto 2) := state(23 downto 6); temp( downto 4) := state(47 downto 4); temp(3 downto 96) := state(7 downto 64); temp(95 downto 88) := state(95 downto 88); temp(87 downto 8) := state(9 downto 2); temp(79 downto 72) := state(5 downto 8); temp(7 downto 64) := state(39 downto 32); temp(63 downto 56) := state(63 downto 56); temp(55 downto 48) := state(87 downto 8); temp(47 downto 4) := state( downto 4); temp(39 downto 32) := state(7 downto ); --t --t --t2 --t3 --t4 --t5 --t6 --t7 --t8 --t9 --t --t temp(3 downto 24) := state(3 downto 24); --t2 temp(23 downto 6) := state(55 downto 48); --t3 temp(5 downto 8) := state(79 downto 72); --t4 temp(7 downto ) := state(3 downto 96); --t5 a := temp; return a; end function INV_SHIFT_ROW_FUNCT; 76

Appendix D (continued) function MIX_COLUMN_FUNCT (state: STATE_TYPE) return STATE_TYPE is egin variale t: SLV_8; variale t: SLV_8; variale t2: SLV_8; variale t3: SLV_8; variale t4: SLV_8; variale t5: SLV_8; variale t6: SLV_8; variale t7: SLV_8; variale t8: SLV_8; variale t9: SLV_8; variale t: SLV_8; variale t: SLV_8; variale t2: SLV_8; variale t3: SLV_8; variale t4: SLV_8; variale t5: SLV_8; variale DATAOUT: SLV_28; variale temp: SLV_28; t := state(27 downto 2); t := state(9 downto 2); t2 := state( downto 4); t3 := state(3 downto 96); t4 := state(95 downto 88); t5 := state(87 downto 8); t6 := state(79 downto 72); t7:= state(7 downto 64); t8 := state(63 downto 56); t9 := state(55 downto 48); t := state(47 downto 4); t := state(39 downto 32); t2 := state(3 downto 24); t3 := state(23 downto 6); t4 := state(5 downto 8); t5 := state(7 downto ); 77

Appendix D (continued) DATAOUT(27 downto 2) := POLY_MULTE_FUNCT("", t) xor POLY_MULTE_FUNCT("", t) xor t2 xor t3; DATAOUT(9 downto 2) := t xor POLY_MULTE_FUNCT("", t) xor POLY_MULTE_FUNCT("", t2) xor t3; DATAOUT( downto 4) := POLY_MULTE_FUNCT("", t2) xor POLY_MULTE_FUNCT("", t3) xor t xor t; DATAOUT(3 downto 96) := POLY_MULTE_FUNCT("", t) xor POLY_MULTE_FUNCT("", t3) xor t xor t2; DATAOUT(95 downto 88) := POLY_MULTE_FUNCT("", t4) xor POLY_MULTE_FUNCT("", t5) xor t6 xor t7; DATAOUT(87 downto 8) := POLY_MULTE_FUNCT("", t5) xor POLY_MULTE_FUNCT("", t6) xor t4 xor t7; DATAOUT(79 downto 72) := POLY_MULTE_FUNCT("", t6) xor POLY_MULTE_FUNCT("", t7) xor t4 xor t5; DATAOUT(7 downto 64) := POLY_MULTE_FUNCT("", t4) xor POLY_MULTE_FUNCT("", t7) xor t5 xor t6; DATAOUT(63 downto 56) := POLY_MULTE_FUNCT("", t8) xor POLY_MULTE_FUNCT("", t9) xor t xor t; DATAOUT(55 downto 48) := POLY_MULTE_FUNCT("", t9) xor POLY_MULTE_FUNCT("", t) xor t8 xor t; 78

Appendix D (continued) DATAOUT(47 downto 4) := POLY_MULTE_FUNCT("", t) xor POLY_MULTE_FUNCT("", t) xor t8 xor t9; DATAOUT(39 downto 32) := POLY_MULTE_FUNCT("", t8) xor POLY_MULTE_FUNCT("", t) xor t9 xor t; DATAOUT(3 downto 24) := POLY_MULTE_FUNCT("", t2) xor POLY_MULTE_FUNCT("", t3) xor t4 xor t5; DATAOUT(23 downto 6) := POLY_MULTE_FUNCT("",t3) xor POLY_MULTE_FUNCT("",t4) xor t2 xor t5; DATAOUT(5 downto 8) := POLY_MULTE_FUNCT("", t4) xor POLY_MULTE_FUNCT("", t5) xor t2 xor t3; DATAOUT(7 downto ) := POLY_MULTE_FUNCT("", t2) xor POLY_MULTE_FUNCT("", t5) xor t3 xor t4; temp:=dataout; return temp; end function MIX_COLUMN_FUNCT; 79

Appendix D (continued) function INV_MIX_COLUMN_FUNCT (state: STATE_TYPE) return STATE_TYPE is egin variale t: SLV_8; variale t: SLV_8; variale t2: SLV_8; variale t3: SLV_8; variale t4: SLV_8; variale t5: SLV_8; variale t6: SLV_8; variale t7: SLV_8; variale t8: SLV_8; variale t9: SLV_8; variale t: SLV_8; variale t: SLV_8; variale t2: SLV_8; variale t3: SLV_8; variale t4: SLV_8; variale t5: SLV_8; variale : STATE_TYPE; variale temp: STATE_TYPE; t := state(27 downto 2); t := state(9 downto 2); t2 := state( downto 4); t3 := state(3 downto 96); t4 := state(95 downto 88); t5 := state(87 downto 8); t6 := state(79 downto 72); t7 := state(7 downto 64); t8 := state(63 downto 56); t9 := state(55 downto 48); t := state(47 downto 4); t := state(39 downto 32); t2 := state(3 downto 24); t3 := state(23 downto 6); t4 := state(5 downto 8); t5 := state(7 downto ); 8

Appendix D (continued) (27 downto 2) := POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t2) xor POLY_MULTD_FUNCT("", t3); (9 downto 2) := POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t2) xor POLY_MULTD_FUNCT("", t3); ( downto 4) := POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t2) xor POLY_MULTD_FUNCT("", t3); (3 downto 96) := POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t2) xor POLY_MULTD_FUNCT("", t3); (95 downto 88) := POLY_MULTD_FUNCT("", t4) xor POLY_MULTD_FUNCT("", t5) xor POLY_MULTD_FUNCT("", t6) xor POLY_MULTD_FUNCT("", t7) ; (87 downto 8) := POLY_MULTD_FUNCT("", t4) xor POLY_MULTD_FUNCT("", t5) xor POLY_MULTD_FUNCT("", t6) xor POLY_MULTD_FUNCT("", t7); (79 downto 72) := POLY_MULTD_FUNCT("", t4) xor POLY_MULTD_FUNCT("", t5) xor POLY_MULTD_FUNCT("", t6) xor POLY_MULTD_FUNCT("", t7); (7 downto 64) := POLY_MULTD_FUNCT("", t4) xor POLY_MULTD_FUNCT("", t5) xor POLY_MULTD_FUNCT("", t6) xor POLY_MULTD_FUNCT("", t7); 8

Appendix D (continued) (63 downto 56) := POLY_MULTD_FUNCT("", t8) xor POLY_MULTD_FUNCT("", t9) xor POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t) ; (55 downto 48) := POLY_MULTD_FUNCT("", t8) xor POLY_MULTD_FUNCT("", t9) xor POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t); (47 downto 4) := POLY_MULTD_FUNCT("", t8) xor POLY_MULTD_FUNCT("", t9) xor POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t); (39 downto 32) := POLY_MULTD_FUNCT("", t8) xor POLY_MULTD_FUNCT("", t9) xor POLY_MULTD_FUNCT("", t) xor POLY_MULTD_FUNCT("", t); (3 downto 24) := POLY_MULTD_FUNCT("", t2) xor POLY_MULTD_FUNCT("", t3) xor POLY_MULTD_FUNCT("", t4) xor POLY_MULTD_FUNCT("", t5); (23 downto 6) := POLY_MULTD_FUNCT("", t2) xor POLY_MULTD_FUNCT("", t3) xor POLY_MULTD_FUNCT("", t4) xor POLY_MULTD_FUNCT("", t5); (5 downto 8) := POLY_MULTD_FUNCT("", t2) xor POLY_MULTD_FUNCT("", t3) xor POLY_MULTD_FUNCT("", t4) xor POLY_MULTD_FUNCT("", t5); (7 downto ) := POLY_MULTD_FUNCT("", t2) xor POLY_MULTD_FUNCT("", t3) xor POLY_MULTD_FUNCT("", t4) xor POLY_MULTD_FUNCT("", t5); temp:=; return temp; end function INV_MIX_COLUMN_FUNCT; 82

Appendix D (continued) function POLY_MULTE_FUNCT (a: SLV_8; : SLV_8 ) return SLV_8 is egin variale temp : SLV_8; variale temp : SLV_8; variale temp2 : SLV_8; variale temp3 : SLV_8; variale and_mask : SLV_8; and_mask := (7) & (7) & (7) & (7) & (7) & (7) & (7) & (7); case a(3 downto ) is when "" => temp := ; when "" =>temp := (6 downto ) & '' xor (("") and and_mask); when ""=> temp := (6 downto ) & '' xor (("") and and_mask) xor ; when others => temp := (others => ''); end case; return temp; end function POLY_MULTE_FUNCT; 83

Appendix D (continued) function POLY_MULTD_FUNCT (a: SLV_8; : SLV_8) return SLV_8 is egin variale temp: SLV_8; variale temp: SLV_8; variale temp2: SLV_8; variale temp3: SLV_8; variale and_mask: SLV_8; and_mask := (7) & (7) & (7) & (7) & (7) & (7) & (7) & (7); case a(3 downto ) is when ""=> temp := (6 downto ) & ') xor (("") and and_mask); and_mask := temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7); temp2 := temp(6 downto ) & '' xor (("") and and_mask); and_mask := temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7); temp3 := temp2(6 downto ) & '' xor (("") and and_mask); temp := temp3 xor ; when ""=> temp := (6 downto ) & '' xor (("") and and_mask); and_mask := temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7); temp2 := temp(6 downto ) & '' xor (("") and and_mask); and_mask := temp2(7) & temp2(7) & temp2(7) & temp2(7) &emp2(7) & temp2(7) & temp2(7) & temp2(7); temp3 := temp2(6 downto ) & '' xor (("") and and_mask); temp := temp xor temp3 xor ; 84

Appendix D (continued) when "" => temp := (6 downto ) & '' xor (("") and and_mask); and_mask := temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7); temp2 := temp(6 downto ) & '' xor (("") and and_mask); and_mask := temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7); temp3 := temp2(6 downto ) & '' xor (("") and and_mask); temp := temp2 xor temp3 xor ; when ""=> temp := (6 downto ) & '' xor (("") and and_mask); and_mask := temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7) & temp(7); temp2 := temp(6 downto & '' xor (("") and and_mask); and_mask := temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7) & temp2(7); temp3 := temp2(6 downto ) & '' xor (("") and and_mask); temp := temp xor temp2 xor temp3; when others => temp := (others => ''); end case; return temp; end function POLY_MULTD_FUNCT; 85

Appendix D (continued) function ADD_ROUNDKEY_FUNCT (roundkey: STATE_TYPE; state: STATE_TYPE) return STATE_TYPE is egin variale : STATE_TYPE; := state xor roundkey; return ; end function ADD_ROUNDKEY_FUNCT; function ROUNDKEY_GEN (roundkey: STATE_TYPE; round: round_type) return STATE_TYPE is variale : STATE_TYPE; variale :SLV_8; variale :SLV_8; variale 2:SLV_8; variale 3:SLV_8; egin := roundkey(3 downto 24); := roundkey(23 downto 6); 2 := roundkey(5 downto 8); 3 := roundkey(7 downto ); case round is when => (27 downto 2) := SBOX_LOOKUP() xor "" xor roundkey(27 downto 2); (9 downto 2) := SBOX_LOOKUP(2)xor roundkey(9 downto 2); ( downto 4) := SBOX_LOOKUP(3) xor roundkey( downto 4); (3 downto 96) := SBOX_LOOKUP() xor roundkey(3 downto 96); (95 downto 64) := (27 downto 96) xor roundkey(95 downto 64); (63 downto 32) := (95 downto 64) xor roundkey(63 downto 32); (3 downto ) := (63 downto 32) xor roundkey(3 downto ); 86

Appendix D (continued) when 2 => (27 downto 2) := SBOX_LOOKUP() xor "" xor roundkey(27 downto 2); (9 downto 2):= SBOX_LOOKUP(2) xor roundkey(9 downto 2); ( downto 4) := SBOX_LOOKUP(3) xor roundkey( downto 4); (3 downto 96) := SBOX_LOOKUP() xor roundkey(3 downto 96); (95 downto 64) := (27 downto 96) xor roundkey(95 downto 64); (63 downto 32) := (95 downto 64) xor roundkey(63 downto 32); (3 downto ) := (63 downto 32) xor roundkey(3 downto ); when 3 => (27 downto 2) := SBOX_LOOKUP() xor "" xor roundkey(27 downto 2); (9 downto 2):= SBOX_LOOKUP(2) xor roundkey(9 downto 2); ( downto 4) := SBOX_LOOKUP(3) xor roundkey( downto 4); (3 downto 96) := SBOX_LOOKUP() xor roundkey(3 downto 96); (95 downto 64) := (27 downto 96) xor roundkey(95 downto 64); (63 downto 32) := (95 downto 64) xor roundkey(63 downto 32); (3 downto ) := (63 downto 32) xor roundkey(3 downto ); when 4 => (27 downto 2) := SBOX_LOOKUP() xor "" xor roundkey(27 downto 2); (9 downto 2) := SBOX_LOOKUP(2) xor roundkey(9 downto 2); ( downto 4) := SBOX_LOOKUP(3) xor roundkey( downto 4); (3 downto 96) := SBOX_LOOKUP() xor roundkey(3 downto 96); (95 downto 64) := (27 downto 96) xor roundkey(95 downto 64); (63 downto 32) := (95 downto 64) xor roundkey(63 downto 32); (3 downto ) := (63 downto 32) xor roundkey(3 downto ); 87

Appendix D (continued) when 5 => (27 downto 2) := SBOX_LOOKUP() xor "" xor roundkey(27 downto 2); (9 downto 2) := SBOX_LOOKUP(2) xor roundkey(9 downto 2); ( downto 4) := SBOX_LOOKUP(3) xor roundkey( downto 4); (3 downto 96) := SBOX_LOOKUP() xor roundkey(3 downto 96); (95 downto 64) := (27 downto 96) xor roundkey(95 downto 64); (63 downto 32) := (95 downto 64) xor roundkey(63 downto 32); (3 downto ) := (63 downto 32) xor roundkey(3 downto ); when 6 => (27 downto 2) := SBOX_LOOKUP() xor "" xor roundkey(27 downto 2); (9 downto 2) := SBOX_LOOKUP(2) xor roundkey(9 downto 2); ( downto 4) := SBOX_LOOKUP(3) xor roundkey( downto 4); (3 downto 96) := SBOX_LOOKUP() xor roundkey(3 downto 96); (95 downto 64) := (27 downto 96) xor roundkey(95 downto 64); (63 downto 32) := (95 downto 64) xor roundkey(63 downto 32); (3 downto ) := (63 downto 32) xor roundkey(3 downto ); when 7 =>(27 downto 2) := SBOX_LOOKUP() xor "" xor roundkey(27 downto 2) ; (9 downto 2):= SBOX_LOOKUP(2) xor roundkey(9 downto 2); ( downto 4) := SBOX_LOOKUP(3) xor roundkey( downto 4); (3 downto 96) := SBOX_LOOKUP() xor roundkey(3 downto 96); (95 downto 64) := (27 downto 96) xor roundkey(95 downto 64); (63 downto 32) := (95 downto 64) xor roundkey(63 downto 32); (3 downto ) := (63 downto 32) xor roundkey(3 downto ); 88

Appendix D (continued) when 8 => (27 downto 2) := SBOX_LOOKUP() xor "" xor roundkey(27 downto 2) ; (9 downto 2) := SBOX_LOOKUP(2) xor roundkey(9 downto 2); ( downto 4) := SBOX_LOOKUP(3) xor roundkey( downto 4); (3 downto 96) := SBOX_LOOKUP() xor roundkey(3 downto 96); (95 downto 64) := (27 downto 96) xor roundkey(95 downto 64); (63 downto 32) := (95 downto 64) xor roundkey(63 downto 32); (3 downto ) := (63 downto 32) xor roundkey(3 downto ); when 9 => (27 downto 2) := SBOX_LOOKUP() xor "" xor roundkey(27 downto 2); (9 downto 2):= SBOX_LOOKUP(2) xor roundkey(9 downto 2); ( downto 4) := SBOX_LOOKUP(3) xor roundkey( downto 4); (3 downto 96) := SBOX_LOOKUP() xor roundkey(3 downto 96); (95 downto 64) := (27 downto 96) xor roundkey(95 downto 64); (63 downto 32) := (95 downto 64) xor roundkey(63 downto 32); (3 downto ) := (63 downto 32) xor roundkey(3 downto ); when => (27 downto 2) := SBOX_LOOKUP() xor "" xor roundkey(27 downto 2); (9 downto 2) := SBOX_LOOKUP(2) xor roundkey(9 downto 2); ( downto 4) := SBOX_LOOKUP(3) xor roundkey( downto 4); (3 downto 96) := SBOX_LOOKUP() xor roundkey(3 downto 96); (95 downto 64) := (27 downto 96) xor roundkey(95 downto 64); (63 downto 32) := (95 downto 64) xor roundkey(63 downto 32); (3 downto ) := (63 downto 32) xor roundkey(3 downto ); 89

Appendix D (continued) when others => null; end case; return end function ROUNDKEY_GEN; end package ody rijndael_package; 9

Appendix D (continued) S-Box Transformation lirary ieee; use ieee.std_logic_64.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity yte_su is port (state: in STD_LOGIC_VECTOR(7 downto ); clk: in std_logic; rst: in std_logic; : out STD_LOGIC_VECTOR(7 downto )); end entity yte_su; architecture top_aes_rtl of yte_su is egin process (clk) is egin end process; if rst = '' then <= (others => ''); elsif (clk='' and clk'event) then <= SBOX_LOOKUP( state); end if; end architecture top_aes_rtl; 9

Appendix D (continued) Shift Row Transformation lirary ieee; use ieee.std_logic_64.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity shift_row is port (state: in STD_LOGIC_VECTOR(27 downto ); clk: in std_logic; rst: in std_logic; DATAOUT: out STD_LOGIC_VECTOR(27 downto )); end entity shift_row; architecture top_aes_rtl of shift_row is egin process (clk) is egin end process; if rst = '' then DATAOUT <= (others => ''); elsif (clk='' and clk'event) then DATAOUT <= SHIFT_ROW_FUNCT(state); end if; end architecture top_aes_rtl; 92

Appendix D (continued) Mix Column Transformation lirary ieee; use ieee.std_logic_64.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity mix_column is port (state: in STD_LOGIC_VECTOR(27 downto ); clk: in std_logic; rst: in std_logic; DATAOUT: out STD_LOGIC_VECTOR(27 downto )); end entity mix_column; architecture top_aes_rtl of mix_column is egin process (clk) is egin if rst = '' then DATAOUT <= (others => ''); elsif (clk='' and clk'event) then DATAOUT <= MIX_COLUMN_FUNCT(state); end if; end process; end architecture top_aes_rtl; 93

Appendix D (continued) Key Generation lirary ieee; use ieee.std_logic_64.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity key_gen is port (roundkey: in STD_LOGIC_VECTOR(27 downto ); round: in round_type; DATAOUT: out STD_LOGIC_VECTOR(27 downto )); end entity key_gen; architecture top_aes_rtl of key_gen is egin process (roundkey, round) is egin DATAOUT <= ROUNDKEY_GEN(roundkey, round); end process; end architecture top_aes_rtl; 94

Appendix D (continued) Inverse S-BOX lirary ieee; use ieee.std_logic_64.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity inv_yte_su is port (state: IN STD_LOGIC_VECTOR(7 downto ); clk: in std_logic; rst: in std_logic; : out STD_LOGIC_VECTOR(7 downto )); end entity inv_yte_su; architecture top_aes_rtl of inv_yte_su is egin process (clk) is egin end process; if rst = '' then <= ( others => '' ); elsif (clk='' and clk'event) then <= INV_SBOX_LOOKUP( state); end if; end architecture top_aes_rtl; 95

Appendix D (continued) Inverse Shift Row Transformation lirary ieee; use ieee.std_logic_64.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity inv_shift_row is port (state: in STD_LOGIC_VECTOR(27 downto ); clk: in std_logic; rst: in std_logic; DATAOUT: out STD_LOGIC_VECTOR(27 downto )); end entity inv_shift_row; architecture top_aes_rtl of inv_shift_row is egin process (clk) is egin end process; if rst = '' then DATAOUT <= (others => ''); elsif (clk='' and clk'event) then DATAOUT <= INV_SHIFT_ROW_FUNCT(state); end if; end architecture top_aes_rtl; 96

Appendix D (continued) Inverse Mix Column Transformation lirary ieee; use ieee.std_logic_64.all; use ieee.std_logic_arith.all; use work.rijndael_package.all; entity inv_mix_column is port (state: in STD_LOGIC_VECTOR(27 downto ); clk: in std_logic; rst: in std_logic; DATAOUT : out STD_LOGIC_VECTOR(27 downto )); end entity inv_mix_column; architecture top_aes_rtl of inv_mix_column is egin process (clk) is egin end process; if rst = '' then DATAOUT <= ( others => '' ); elsif (clk='' and clk'event) then DATAOUT <= INV_MIX_COLUMN_FUNCT(state); end if; end architecture top_aes_rtl; 97