Fast Aes Decryption
Total Page:16
File Type:pdf, Size:1020Kb
FAST AES DECRYPTION Vinit Azad B.S., University of California, Davis, 2007 PROJECT Submitted in partial satisfaction of the requirements for the degree of MASTER OF SCIENCE in COMPUTER SCIENCE at CALIFORNIA STATE UNIVERSITY, SACRAMENTO SPRING 2011 FAST AES DECRYPTION A Project by Vinit Azad Approved by: __________________________________, Committee Chair Ted Krovetz, Ph.D. __________________________________, Second Reader Chung E. Wang, Ph.D. ____________________________ Date ii Student: Vinit Azad I certify that this student has met the requirements for format contained in the University format manual, and that this project is suitable for shelving in the Library and credit is to be awarded for the Project. __________________________, Graduate Coordinator ________________ Nikrouz Faroughi, Ph.D. Date Department of Computer Science iii Abstract of FAST AES DECRYPTION by Vinit Azad Due to the prevalent use of internet-enabled devices, confidentiality and privacy in communication has been more important than ever. Encryption algorithms, such as AES and RSA, are used to ensure the security and privacy of such communications. However, as computers get computationally powerful, more complex encryption algorithms are needed to avoid brute force attacks. This complexity in the algorithms also means that encryption and decryption of messages using these algorithms can be slow. To avoid this decrease in speed, many optimizations have been proposed to make these complex algorithms perform much faster. Emilia Käsper and Peter Schwabe proposed one such optimization to AES in their paper “Faster and Timing-Attack Resistant AES-GCM.” They describe a fast constant- time AES encryption algorithm, which is also immune from cache-timing attacks, using Intel’s SSE instructions. This paper focuses on the study of Käsper and Schwabe’s proposal and implements a fast constant-time AES decryption algorithm that can work with their encryption algorithm. The paper concludes that while the decryption algorithm is slower than the encryption algorithm proposed by Käsper and Schwabe, it is about 3 times faster than the standard decryption implementation such as OpenSSL. Therefore, this fast decryption algorithm paired with Käsper and Schwabe’s fast encryption iv algorithm can provide users a complete AES package that can be used in applications that require fast encryptions and decryption along with protection against timing attacks. _______________________, Committee Chair Ted Krovetz, Ph.D. _______________________ Date v TABLE OF CONTENTS Page List of Tables ................................................................................................................... viii List of Figures .................................................................................................................... ix Chapter 1. INTRODUCTION TO AES ........................................................................................... 1 1.1 AES State ........................................................................................................ 2 1.2 AES Encryption Algorithm............................................................................. 2 1.2.1 ShiftRows ......................................................................................... 3 1.2.2 MixColumns .................................................................................... 4 1.2.3 AddRoundKey ................................................................................. 4 1.2.4 SubBytes .......................................................................................... 5 1.3 AES Decryption Algorithm ............................................................................ 6 1.3.1 InvShiftRows ................................................................................... 8 1.3.2 InvMixColumns ............................................................................... 8 1.3.3 InvSubBytes ..................................................................................... 9 1.4 Key Expansion Algorithm .............................................................................. 9 2. BITSLICED AES ENCRYPTION .............................................................................. 12 2.1 Bitslicing ....................................................................................................... 13 2.2 Bitsliced ShiftRows ...................................................................................... 14 2.3 Bitsliced MixColumns .................................................................................. 14 2.4 Bitsliced AddRoundKey ............................................................................... 16 2.5 Bitsliced SubBytes ........................................................................................ 16 2.6 Bitsliced Key Expansion Algorithm ............................................................. 18 3. BITSLICED AES DECRYPTION .............................................................................. 19 3.1 Bitsliced InvShiftRows ................................................................................. 19 3.2 Bitsliced InvMixColumns ............................................................................. 20 3.3 Bitsliced AddRoundKey ............................................................................... 24 3.4 Bitsliced InvSubBytes ................................................................................... 25 vi 3.5 Bitsliced Inverse Key Expansion Algorithm ................................................ 26 4. VALIDATION AND PERFORMANCE ANALYSIS ................................................ 27 5. CONCLUSION ............................................................................................................ 30 Appendix A. Bitsliced Decryption Code ......................................................................... 33 Appendix B. OpenSSL Decryption Code ........................................................................ 60 Appendix C. System Configuration ................................................................................. 69 References ......................................................................................................................... 71 vii LIST OF TABLES Page 1. Table 4.1: Performance data for Core2Duo CPU ....................................................... 28 2. Table 4.2: Instruction count for AES operations ........................................................ 29 viii LIST OF FIGURES Page 1. Figure 1.1: Operation performed on State array ........................................................... 2 2. Figure 1.2: AES encryption psuedocode ..................................................................... 3 3. Figure 1.3: ShiftRows transformation .......................................................................... 4 4. Figure 1.4: Column multiplication ............................................................................... 4 5. Figure 1.5: AES decryption psuedocode ..................................................................... 7 6. Figure 1.6: InvShiftRows transformation .................................................................... 8 7. Figure 1.7: Inverse column multiplication .................................................................... 8 8. Figure 1.8: Key expansion algorithm.......................................................................... 10 9. Figure 2.1: Bitsliced 8 AES-State ............................................................................... 13 10. Figure 2.2: ShiftRows using pshufb............................................................................ 14 11. Figure 2.3: Equation for bitsliced MixColumns ......................................................... 15 12. Figure 2.4: Matrix used to change from standard basis to subfield basis ................... 17 13. Figure 2.5: Subfield basis to standard basis along with affine transformation ........... 18 14. Figure 3.1: InvShiftRows using pshufb ...................................................................... 20 15. Figure 3.2: Multiplication using shifts and XOR........................................................ 20 16. Figure 3.3: Shifts using XOR...................................................................................... 22 17. Figure 3.4: Galois multiplication using XORs ........................................................... 23 18. Figure 3.5: InvMixColumns equations ....................................................................... 24 19. Figure 3.6: Inverse affine transform and standard to subfield basis change ............... 25 20. Figure 3.7: Subfield to standard basis change matrix ................................................. 25 ix 1 Chapter 1 INTRODUCTION TO AES Due to prevalent use of internet-enabled devices, confidentiality and privacy in communication has been more important than ever. To provide this confidentiality for electronic communications, encryption algorithms are used [7]. There are two kinds of encryption algorithms: symmetric-key encryption and public-key encryption [7]. Symmetric encryption is also known as a single key encryption [7] because a single key is used for both encryption and decryption algorithm. Public-key encryption algorithm is an algorithm where a public key (available to all) and a separate private key (only known to one entity) are used for encryption and decryption [7]. Data Encryption Standard (DES), Advanced Encryption Standard (AES), Blowfish, and Serpent are all examples of symmetric