#include <aes_intel.h>

Public Member Functions | |
| AES_128_Intel () | |
| void | clear () |
| BlockCipher * | clone () const |
| void | decrypt (byte block[]) const |
| void | decrypt (const byte in[], byte out[]) const |
| void | decrypt_n (const byte in[], byte out[], u32bit blocks) const |
| void | encrypt (byte block[]) const |
| void | encrypt (const byte in[], byte out[]) const |
| void | encrypt_n (const byte in[], byte out[], u32bit blocks) const |
| std::string | name () const |
| u32bit | parallel_bytes () const |
| u32bit | parallelism () const |
| void | set_key (const byte key[], u32bit length) |
| void | set_key (const SymmetricKey &key) |
| bool | valid_keylength (u32bit length) const |
Public Attributes | |
| const u32bit | BLOCK_SIZE |
| const u32bit | KEYLENGTH_MULTIPLE |
| const u32bit | MAXIMUM_KEYLENGTH |
| const u32bit | MINIMUM_KEYLENGTH |
Definition at line 18 of file aes_intel.h.
| Botan::AES_128_Intel::AES_128_Intel | ( | ) | [inline] |
| void Botan::AES_128_Intel::clear | ( | ) | [virtual] |
Zeroize internal state
Implements Botan::BlockCipher.
Definition at line 307 of file aes_intel.cpp.
References Botan::MemoryRegion< T >::clear().
| BlockCipher* Botan::AES_128_Intel::clone | ( | ) | const [inline, virtual] |
Get a new object representing the same algorithm as *this
Implements Botan::BlockCipher.
Definition at line 28 of file aes_intel.h.
00028 { return new AES_128_Intel; }
| void Botan::BlockCipher::decrypt | ( | byte | block[] | ) | const [inline, inherited] |
Decrypt a block.
| block | the ciphertext block to be decrypted Must be of length BLOCK_SIZE. Will hold the result when the function has finished. |
Definition at line 89 of file block_cipher.h.
00089 { decrypt_n(block, block, 1); }
Decrypt a block.
| in | The ciphertext block to be decypted as a byte array. Must be of length BLOCK_SIZE. | |
| out | The byte array designated to hold the decrypted block. Must be of length BLOCK_SIZE. |
Definition at line 72 of file block_cipher.h.
Referenced by Botan::DESX::decrypt_n().
00073 { decrypt_n(in, out, 1); }
Decrypt one or more blocks
| in | the input buffer (multiple of BLOCK_SIZE) | |
| out | the output buffer (same size as in) | |
| blocks | the number of blocks to process |
Implements Botan::BlockCipher.
Definition at line 182 of file aes_intel.cpp.
References AES_DEC_4_LAST_ROUNDS, and AES_DEC_4_ROUNDS.
00183 { 00184 const __m128i* in_mm = (const __m128i*)in; 00185 __m128i* out_mm = (__m128i*)out; 00186 00187 const __m128i* key_mm = (const __m128i*)&DK[0]; 00188 00189 __m128i K0 = _mm_loadu_si128(key_mm); 00190 __m128i K1 = _mm_loadu_si128(key_mm + 1); 00191 __m128i K2 = _mm_loadu_si128(key_mm + 2); 00192 __m128i K3 = _mm_loadu_si128(key_mm + 3); 00193 __m128i K4 = _mm_loadu_si128(key_mm + 4); 00194 __m128i K5 = _mm_loadu_si128(key_mm + 5); 00195 __m128i K6 = _mm_loadu_si128(key_mm + 6); 00196 __m128i K7 = _mm_loadu_si128(key_mm + 7); 00197 __m128i K8 = _mm_loadu_si128(key_mm + 8); 00198 __m128i K9 = _mm_loadu_si128(key_mm + 9); 00199 __m128i K10 = _mm_loadu_si128(key_mm + 10); 00200 00201 while(blocks >= 4) 00202 { 00203 __m128i B0 = _mm_loadu_si128(in_mm + 0); 00204 __m128i B1 = _mm_loadu_si128(in_mm + 1); 00205 __m128i B2 = _mm_loadu_si128(in_mm + 2); 00206 __m128i B3 = _mm_loadu_si128(in_mm + 3); 00207 00208 B0 = _mm_xor_si128(B0, K0); 00209 B1 = _mm_xor_si128(B1, K0); 00210 B2 = _mm_xor_si128(B2, K0); 00211 B3 = _mm_xor_si128(B3, K0); 00212 00213 AES_DEC_4_ROUNDS(K1); 00214 AES_DEC_4_ROUNDS(K2); 00215 AES_DEC_4_ROUNDS(K3); 00216 AES_DEC_4_ROUNDS(K4); 00217 AES_DEC_4_ROUNDS(K5); 00218 AES_DEC_4_ROUNDS(K6); 00219 AES_DEC_4_ROUNDS(K7); 00220 AES_DEC_4_ROUNDS(K8); 00221 AES_DEC_4_ROUNDS(K9); 00222 AES_DEC_4_LAST_ROUNDS(K10); 00223 00224 _mm_storeu_si128(out_mm + 0, B0); 00225 _mm_storeu_si128(out_mm + 1, B1); 00226 _mm_storeu_si128(out_mm + 2, B2); 00227 _mm_storeu_si128(out_mm + 3, B3); 00228 00229 blocks -= 4; 00230 in_mm += 4; 00231 out_mm += 4; 00232 } 00233 00234 for(u32bit i = 0; i != blocks; ++i) 00235 { 00236 __m128i B = _mm_loadu_si128(in_mm + i); 00237 00238 B = _mm_xor_si128(B, K0); 00239 00240 B = _mm_aesdec_si128(B, K1); 00241 B = _mm_aesdec_si128(B, K2); 00242 B = _mm_aesdec_si128(B, K3); 00243 B = _mm_aesdec_si128(B, K4); 00244 B = _mm_aesdec_si128(B, K5); 00245 B = _mm_aesdec_si128(B, K6); 00246 B = _mm_aesdec_si128(B, K7); 00247 B = _mm_aesdec_si128(B, K8); 00248 B = _mm_aesdec_si128(B, K9); 00249 B = _mm_aesdeclast_si128(B, K10); 00250 00251 _mm_storeu_si128(out_mm + i, B); 00252 } 00253 }
| void Botan::BlockCipher::encrypt | ( | byte | block[] | ) | const [inline, inherited] |
Encrypt a block.
| block | the plaintext block to be encrypted Must be of length BLOCK_SIZE. Will hold the result when the function has finished. |
Definition at line 81 of file block_cipher.h.
00081 { encrypt_n(block, block, 1); }
Encrypt a block.
| in | The plaintext block to be encrypted as a byte array. Must be of length BLOCK_SIZE. | |
| out | The byte array designated to hold the encrypted block. Must be of length BLOCK_SIZE. |
Definition at line 62 of file block_cipher.h.
Referenced by Botan::aont_package(), Botan::aont_unpackage(), Botan::OFB::cipher(), Botan::DESX::encrypt_n(), Botan::OFB::set_iv(), Botan::XTS_Decryption::set_iv(), Botan::XTS_Encryption::set_iv(), Botan::CFB_Decryption::set_iv(), and Botan::CFB_Encryption::set_iv().
00063 { encrypt_n(in, out, 1); }
Encrypt one or more blocks
| in | the input buffer (multiple of BLOCK_SIZE) | |
| out | the output buffer (same size as in) | |
| blocks | the number of blocks to process |
Implements Botan::BlockCipher.
Definition at line 106 of file aes_intel.cpp.
References AES_ENC_4_LAST_ROUNDS, and AES_ENC_4_ROUNDS.
00107 { 00108 const __m128i* in_mm = (const __m128i*)in; 00109 __m128i* out_mm = (__m128i*)out; 00110 00111 const __m128i* key_mm = (const __m128i*)&EK[0]; 00112 00113 __m128i K0 = _mm_loadu_si128(key_mm); 00114 __m128i K1 = _mm_loadu_si128(key_mm + 1); 00115 __m128i K2 = _mm_loadu_si128(key_mm + 2); 00116 __m128i K3 = _mm_loadu_si128(key_mm + 3); 00117 __m128i K4 = _mm_loadu_si128(key_mm + 4); 00118 __m128i K5 = _mm_loadu_si128(key_mm + 5); 00119 __m128i K6 = _mm_loadu_si128(key_mm + 6); 00120 __m128i K7 = _mm_loadu_si128(key_mm + 7); 00121 __m128i K8 = _mm_loadu_si128(key_mm + 8); 00122 __m128i K9 = _mm_loadu_si128(key_mm + 9); 00123 __m128i K10 = _mm_loadu_si128(key_mm + 10); 00124 00125 while(blocks >= 4) 00126 { 00127 __m128i B0 = _mm_loadu_si128(in_mm + 0); 00128 __m128i B1 = _mm_loadu_si128(in_mm + 1); 00129 __m128i B2 = _mm_loadu_si128(in_mm + 2); 00130 __m128i B3 = _mm_loadu_si128(in_mm + 3); 00131 00132 B0 = _mm_xor_si128(B0, K0); 00133 B1 = _mm_xor_si128(B1, K0); 00134 B2 = _mm_xor_si128(B2, K0); 00135 B3 = _mm_xor_si128(B3, K0); 00136 00137 AES_ENC_4_ROUNDS(K1); 00138 AES_ENC_4_ROUNDS(K2); 00139 AES_ENC_4_ROUNDS(K3); 00140 AES_ENC_4_ROUNDS(K4); 00141 AES_ENC_4_ROUNDS(K5); 00142 AES_ENC_4_ROUNDS(K6); 00143 AES_ENC_4_ROUNDS(K7); 00144 AES_ENC_4_ROUNDS(K8); 00145 AES_ENC_4_ROUNDS(K9); 00146 AES_ENC_4_LAST_ROUNDS(K10); 00147 00148 _mm_storeu_si128(out_mm + 0, B0); 00149 _mm_storeu_si128(out_mm + 1, B1); 00150 _mm_storeu_si128(out_mm + 2, B2); 00151 _mm_storeu_si128(out_mm + 3, B3); 00152 00153 blocks -= 4; 00154 in_mm += 4; 00155 out_mm += 4; 00156 } 00157 00158 for(u32bit i = 0; i != blocks; ++i) 00159 { 00160 __m128i B = _mm_loadu_si128(in_mm + i); 00161 00162 B = _mm_xor_si128(B, K0); 00163 00164 B = _mm_aesenc_si128(B, K1); 00165 B = _mm_aesenc_si128(B, K2); 00166 B = _mm_aesenc_si128(B, K3); 00167 B = _mm_aesenc_si128(B, K4); 00168 B = _mm_aesenc_si128(B, K5); 00169 B = _mm_aesenc_si128(B, K6); 00170 B = _mm_aesenc_si128(B, K7); 00171 B = _mm_aesenc_si128(B, K8); 00172 B = _mm_aesenc_si128(B, K9); 00173 B = _mm_aesenclast_si128(B, K10); 00174 00175 _mm_storeu_si128(out_mm + i, B); 00176 } 00177 }
| std::string Botan::AES_128_Intel::name | ( | ) | const [inline, virtual] |
The name of the algorithm.
Implements Botan::SymmetricAlgorithm.
Definition at line 27 of file aes_intel.h.
| u32bit Botan::BlockCipher::parallel_bytes | ( | ) | const [inline, inherited] |
Definition at line 50 of file block_cipher.h.
Referenced by Botan::CTR_BE::CTR_BE().
00051 { 00052 return parallelism() * BLOCK_SIZE * BOTAN_BLOCK_CIPHER_PAR_MULT; 00053 }
| u32bit Botan::AES_128_Intel::parallelism | ( | ) | const [inline, virtual] |
Reimplemented from Botan::BlockCipher.
Definition at line 21 of file aes_intel.h.
Set the symmetric key of this object.
| key | the to be set as a byte array. | |
| length | in bytes of key param |
Definition at line 57 of file sym_algo.h.
00058 { 00059 if(!valid_keylength(length)) 00060 throw Invalid_Key_Length(name(), length); 00061 key_schedule(key, length); 00062 }
| void Botan::SymmetricAlgorithm::set_key | ( | const SymmetricKey & | key | ) | [inline, inherited] |
Set the symmetric key of this object.
| key | the SymmetricKey to be set. |
Definition at line 49 of file sym_algo.h.
References Botan::OctetString::begin(), Botan::OctetString::length(), and Botan::SymmetricAlgorithm::set_key().
Referenced by Botan::aont_package(), Botan::aont_unpackage(), Botan::Lion::decrypt_n(), Botan::PKCS5_PBKDF2::derive_key(), Botan::ECB_Decryption::ECB_Decryption(), Botan::ECB_Encryption::ECB_Encryption(), Botan::Lion::encrypt_n(), Botan::HMAC_RNG::HMAC_RNG(), Botan::MAC_Filter::MAC_Filter(), Botan::HMAC_RNG::reseed(), Botan::SymmetricAlgorithm::set_key(), Botan::XTS_Decryption::set_key(), Botan::XTS_Encryption::set_key(), Botan::EAX_Base::set_key(), Botan::MAC_Filter::set_key(), and Botan::StreamCipher_Filter::StreamCipher_Filter().
00050 { set_key(key.begin(), key.length()); }
| bool Botan::SymmetricAlgorithm::valid_keylength | ( | u32bit | length | ) | const [inline, inherited] |
Check whether a given key length is valid for this algorithm.
| length | the key length to be checked. |
Definition at line 69 of file sym_algo.h.
Referenced by Botan::aont_package(), Botan::aont_unpackage(), Botan::HMAC_RNG::HMAC_RNG(), Botan::Lion::Lion(), Botan::Randpool::Randpool(), Botan::XTS_Decryption::set_key(), Botan::XTS_Encryption::set_key(), Botan::EAX_Base::valid_keylength(), Botan::MAC_Filter::valid_keylength(), and Botan::valid_keylength_for().
00070 { 00071 return ((length >= MINIMUM_KEYLENGTH) && 00072 (length <= MAXIMUM_KEYLENGTH) && 00073 (length % KEYLENGTH_MULTIPLE == 0)); 00074 }
const u32bit Botan::BlockCipher::BLOCK_SIZE [inherited] |
The block size of this algorithm.
Definition at line 40 of file block_cipher.h.
Referenced by Botan::ANSI_X931_RNG::ANSI_X931_RNG(), Botan::aont_package(), Botan::aont_unpackage(), Botan::Cascade_Cipher::Cascade_Cipher(), Botan::CBC_Decryption::CBC_Decryption(), Botan::CBC_Encryption::CBC_Encryption(), Botan::CFB_Decryption::CFB_Decryption(), Botan::CFB_Encryption::CFB_Encryption(), Botan::Lion::clone(), Botan::CMAC::CMAC(), Botan::CTS_Decryption::CTS_Decryption(), Botan::CTS_Encryption::CTS_Encryption(), Botan::XTEA_SIMD::decrypt_n(), Botan::XTEA::decrypt_n(), Botan::Twofish::decrypt_n(), Botan::TEA::decrypt_n(), Botan::Square::decrypt_n(), Botan::Skipjack::decrypt_n(), Botan::Serpent_SIMD::decrypt_n(), Botan::Serpent_IA32::decrypt_n(), Botan::Serpent::decrypt_n(), Botan::SEED::decrypt_n(), Botan::SAFER_SK::decrypt_n(), Botan::RC6::decrypt_n(), Botan::RC5::decrypt_n(), Botan::RC2::decrypt_n(), Botan::Noekeon::decrypt_n(), Botan::MISTY1::decrypt_n(), Botan::MARS::decrypt_n(), Botan::LubyRackoff::decrypt_n(), Botan::Lion::decrypt_n(), Botan::KASUMI::decrypt_n(), Botan::IDEA_SSE2::decrypt_n(), Botan::GOST_28147_89::decrypt_n(), Botan::DESX::decrypt_n(), Botan::TripleDES::decrypt_n(), Botan::DES::decrypt_n(), Botan::CAST_256::decrypt_n(), Botan::CAST_128::decrypt_n(), Botan::Cascade_Cipher::decrypt_n(), Botan::Blowfish::decrypt_n(), Botan::AES::decrypt_n(), Botan::XTEA_SIMD::encrypt_n(), Botan::XTEA::encrypt_n(), Botan::Twofish::encrypt_n(), Botan::TEA::encrypt_n(), Botan::Square::encrypt_n(), Botan::Skipjack::encrypt_n(), Botan::Serpent_SIMD::encrypt_n(), Botan::Serpent_IA32::encrypt_n(), Botan::Serpent::encrypt_n(), Botan::SEED::encrypt_n(), Botan::SAFER_SK::encrypt_n(), Botan::RC6::encrypt_n(), Botan::RC5::encrypt_n(), Botan::RC2::encrypt_n(), Botan::Noekeon::encrypt_n(), Botan::MISTY1::encrypt_n(), Botan::MARS::encrypt_n(), Botan::LubyRackoff::encrypt_n(), Botan::Lion::encrypt_n(), Botan::KASUMI::encrypt_n(), Botan::IDEA_SSE2::encrypt_n(), Botan::GOST_28147_89::encrypt_n(), Botan::DESX::encrypt_n(), Botan::TripleDES::encrypt_n(), Botan::DES::encrypt_n(), Botan::CAST_256::encrypt_n(), Botan::CAST_128::encrypt_n(), Botan::Cascade_Cipher::encrypt_n(), Botan::Blowfish::encrypt_n(), Botan::AES::encrypt_n(), Botan::get_cipher_mode(), Botan::Lion::Lion(), Botan::Lion::name(), Botan::OFB::OFB(), Botan::Randpool::Randpool(), Botan::CTR_BE::set_iv(), Botan::XTS_Decryption::set_iv(), Botan::XTS_Encryption::set_iv(), Botan::XTS_Decryption::XTS_Decryption(), and Botan::XTS_Encryption::XTS_Encryption().
const u32bit Botan::SymmetricAlgorithm::KEYLENGTH_MULTIPLE [inherited] |
A valid keylength is a multiple of this value.
Definition at line 37 of file sym_algo.h.
Referenced by Botan::keylength_multiple_of().
const u32bit Botan::SymmetricAlgorithm::MAXIMUM_KEYLENGTH [inherited] |
The maximum allowed key length.
Definition at line 27 of file sym_algo.h.
Referenced by Botan::max_keylength_of().
const u32bit Botan::SymmetricAlgorithm::MINIMUM_KEYLENGTH [inherited] |
The minimal allowed key length.
Definition at line 32 of file sym_algo.h.
Referenced by Botan::min_keylength_of().
1.5.8