Botan
1.11.15
|
00001 /* 00002 * AES using AES-NI instructions 00003 * (C) 2009 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_AES_NI_H__ 00009 #define BOTAN_AES_NI_H__ 00010 00011 #include <botan/block_cipher.h> 00012 00013 namespace Botan { 00014 00015 /** 00016 * AES-128 using AES-NI 00017 */ 00018 class BOTAN_DLL AES_128_NI : public Block_Cipher_Fixed_Params<16, 16> 00019 { 00020 public: 00021 size_t parallelism() const { return 4; } 00022 00023 void encrypt_n(const byte in[], byte out[], size_t blocks) const; 00024 void decrypt_n(const byte in[], byte out[], size_t blocks) const; 00025 00026 void clear(); 00027 std::string name() const { return "AES-128"; } 00028 BlockCipher* clone() const { return new AES_128_NI; } 00029 private: 00030 void key_schedule(const byte[], size_t); 00031 00032 secure_vector<u32bit> EK, DK; 00033 }; 00034 00035 /** 00036 * AES-192 using AES-NI 00037 */ 00038 class BOTAN_DLL AES_192_NI : public Block_Cipher_Fixed_Params<16, 24> 00039 { 00040 public: 00041 size_t parallelism() const { return 4; } 00042 00043 void encrypt_n(const byte in[], byte out[], size_t blocks) const; 00044 void decrypt_n(const byte in[], byte out[], size_t blocks) const; 00045 00046 void clear(); 00047 std::string name() const { return "AES-192"; } 00048 BlockCipher* clone() const { return new AES_192_NI; } 00049 private: 00050 void key_schedule(const byte[], size_t); 00051 00052 secure_vector<u32bit> EK, DK; 00053 }; 00054 00055 /** 00056 * AES-256 using AES-NI 00057 */ 00058 class BOTAN_DLL AES_256_NI : public Block_Cipher_Fixed_Params<16, 32> 00059 { 00060 public: 00061 size_t parallelism() const { return 4; } 00062 00063 void encrypt_n(const byte in[], byte out[], size_t blocks) const; 00064 void decrypt_n(const byte in[], byte out[], size_t blocks) const; 00065 00066 void clear(); 00067 std::string name() const { return "AES-256"; } 00068 BlockCipher* clone() const { return new AES_256_NI; } 00069 private: 00070 void key_schedule(const byte[], size_t); 00071 00072 secure_vector<u32bit> EK, DK; 00073 }; 00074 00075 } 00076 00077 #endif