Botan::AES_192_Intel Class Reference

#include <aes_intel.h>

Inheritance diagram for Botan::AES_192_Intel:

Botan::BlockCipher Botan::SymmetricAlgorithm

List of all members.

Public Member Functions

 AES_192_Intel ()
void clear ()
BlockCipherclone () 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


Detailed Description

AES-192 using AES-NI

Definition at line 40 of file aes_intel.h.


Constructor & Destructor Documentation

Botan::AES_192_Intel::AES_192_Intel (  )  [inline]

Definition at line 52 of file aes_intel.h.

00052 : BlockCipher(16, 24) { }


Member Function Documentation

void Botan::AES_192_Intel::clear (  )  [virtual]

Zeroize internal state

Implements Botan::BlockCipher.

Definition at line 523 of file aes_intel.cpp.

References Botan::MemoryRegion< T >::clear().

00524    {
00525    EK.clear();
00526    DK.clear();
00527    }

BlockCipher* Botan::AES_192_Intel::clone (  )  const [inline, virtual]

Get a new object representing the same algorithm as *this

Implements Botan::BlockCipher.

Definition at line 50 of file aes_intel.h.

00050 { return new AES_192_Intel; }

void Botan::BlockCipher::decrypt ( byte  block[]  )  const [inline, inherited]

Decrypt a block.

Parameters:
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); }

void Botan::BlockCipher::decrypt ( const byte  in[],
byte  out[] 
) const [inline, inherited]

Decrypt a block.

Parameters:
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); }

void Botan::AES_192_Intel::decrypt_n ( const byte  in[],
byte  out[],
u32bit  blocks 
) const [virtual]

Decrypt one or more blocks

Parameters:
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 398 of file aes_intel.cpp.

References AES_DEC_4_LAST_ROUNDS, and AES_DEC_4_ROUNDS.

00399    {
00400    const __m128i* in_mm = (const __m128i*)in;
00401    __m128i* out_mm = (__m128i*)out;
00402 
00403    const __m128i* key_mm = (const __m128i*)&DK[0];
00404 
00405    __m128i K0  = _mm_loadu_si128(key_mm);
00406    __m128i K1  = _mm_loadu_si128(key_mm + 1);
00407    __m128i K2  = _mm_loadu_si128(key_mm + 2);
00408    __m128i K3  = _mm_loadu_si128(key_mm + 3);
00409    __m128i K4  = _mm_loadu_si128(key_mm + 4);
00410    __m128i K5  = _mm_loadu_si128(key_mm + 5);
00411    __m128i K6  = _mm_loadu_si128(key_mm + 6);
00412    __m128i K7  = _mm_loadu_si128(key_mm + 7);
00413    __m128i K8  = _mm_loadu_si128(key_mm + 8);
00414    __m128i K9  = _mm_loadu_si128(key_mm + 9);
00415    __m128i K10 = _mm_loadu_si128(key_mm + 10);
00416    __m128i K11 = _mm_loadu_si128(key_mm + 11);
00417    __m128i K12 = _mm_loadu_si128(key_mm + 12);
00418 
00419    while(blocks >= 4)
00420       {
00421       __m128i B0 = _mm_loadu_si128(in_mm + 0);
00422       __m128i B1 = _mm_loadu_si128(in_mm + 1);
00423       __m128i B2 = _mm_loadu_si128(in_mm + 2);
00424       __m128i B3 = _mm_loadu_si128(in_mm + 3);
00425 
00426       B0 = _mm_xor_si128(B0, K0);
00427       B1 = _mm_xor_si128(B1, K0);
00428       B2 = _mm_xor_si128(B2, K0);
00429       B3 = _mm_xor_si128(B3, K0);
00430 
00431       AES_DEC_4_ROUNDS(K1);
00432       AES_DEC_4_ROUNDS(K2);
00433       AES_DEC_4_ROUNDS(K3);
00434       AES_DEC_4_ROUNDS(K4);
00435       AES_DEC_4_ROUNDS(K5);
00436       AES_DEC_4_ROUNDS(K6);
00437       AES_DEC_4_ROUNDS(K7);
00438       AES_DEC_4_ROUNDS(K8);
00439       AES_DEC_4_ROUNDS(K9);
00440       AES_DEC_4_ROUNDS(K10);
00441       AES_DEC_4_ROUNDS(K11);
00442       AES_DEC_4_LAST_ROUNDS(K12);
00443 
00444       _mm_storeu_si128(out_mm + 0, B0);
00445       _mm_storeu_si128(out_mm + 1, B1);
00446       _mm_storeu_si128(out_mm + 2, B2);
00447       _mm_storeu_si128(out_mm + 3, B3);
00448 
00449       blocks -= 4;
00450       in_mm += 4;
00451       out_mm += 4;
00452       }
00453 
00454    for(u32bit i = 0; i != blocks; ++i)
00455       {
00456       __m128i B = _mm_loadu_si128(in_mm + i);
00457 
00458       B = _mm_xor_si128(B, K0);
00459 
00460       B = _mm_aesdec_si128(B, K1);
00461       B = _mm_aesdec_si128(B, K2);
00462       B = _mm_aesdec_si128(B, K3);
00463       B = _mm_aesdec_si128(B, K4);
00464       B = _mm_aesdec_si128(B, K5);
00465       B = _mm_aesdec_si128(B, K6);
00466       B = _mm_aesdec_si128(B, K7);
00467       B = _mm_aesdec_si128(B, K8);
00468       B = _mm_aesdec_si128(B, K9);
00469       B = _mm_aesdec_si128(B, K10);
00470       B = _mm_aesdec_si128(B, K11);
00471       B = _mm_aesdeclast_si128(B, K12);
00472 
00473       _mm_storeu_si128(out_mm + i, B);
00474       }
00475    }

void Botan::BlockCipher::encrypt ( byte  block[]  )  const [inline, inherited]

Encrypt a block.

Parameters:
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); }

void Botan::BlockCipher::encrypt ( const byte  in[],
byte  out[] 
) const [inline, inherited]

Encrypt a block.

Parameters:
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); }

void Botan::AES_192_Intel::encrypt_n ( const byte  in[],
byte  out[],
u32bit  blocks 
) const [virtual]

Encrypt one or more blocks

Parameters:
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 316 of file aes_intel.cpp.

References AES_ENC_4_LAST_ROUNDS, and AES_ENC_4_ROUNDS.

00317    {
00318    const __m128i* in_mm = (const __m128i*)in;
00319    __m128i* out_mm = (__m128i*)out;
00320 
00321    const __m128i* key_mm = (const __m128i*)&EK[0];
00322 
00323    __m128i K0  = _mm_loadu_si128(key_mm);
00324    __m128i K1  = _mm_loadu_si128(key_mm + 1);
00325    __m128i K2  = _mm_loadu_si128(key_mm + 2);
00326    __m128i K3  = _mm_loadu_si128(key_mm + 3);
00327    __m128i K4  = _mm_loadu_si128(key_mm + 4);
00328    __m128i K5  = _mm_loadu_si128(key_mm + 5);
00329    __m128i K6  = _mm_loadu_si128(key_mm + 6);
00330    __m128i K7  = _mm_loadu_si128(key_mm + 7);
00331    __m128i K8  = _mm_loadu_si128(key_mm + 8);
00332    __m128i K9  = _mm_loadu_si128(key_mm + 9);
00333    __m128i K10 = _mm_loadu_si128(key_mm + 10);
00334    __m128i K11 = _mm_loadu_si128(key_mm + 11);
00335    __m128i K12 = _mm_loadu_si128(key_mm + 12);
00336 
00337    while(blocks >= 4)
00338       {
00339       __m128i B0 = _mm_loadu_si128(in_mm + 0);
00340       __m128i B1 = _mm_loadu_si128(in_mm + 1);
00341       __m128i B2 = _mm_loadu_si128(in_mm + 2);
00342       __m128i B3 = _mm_loadu_si128(in_mm + 3);
00343 
00344       B0 = _mm_xor_si128(B0, K0);
00345       B1 = _mm_xor_si128(B1, K0);
00346       B2 = _mm_xor_si128(B2, K0);
00347       B3 = _mm_xor_si128(B3, K0);
00348 
00349       AES_ENC_4_ROUNDS(K1);
00350       AES_ENC_4_ROUNDS(K2);
00351       AES_ENC_4_ROUNDS(K3);
00352       AES_ENC_4_ROUNDS(K4);
00353       AES_ENC_4_ROUNDS(K5);
00354       AES_ENC_4_ROUNDS(K6);
00355       AES_ENC_4_ROUNDS(K7);
00356       AES_ENC_4_ROUNDS(K8);
00357       AES_ENC_4_ROUNDS(K9);
00358       AES_ENC_4_ROUNDS(K10);
00359       AES_ENC_4_ROUNDS(K11);
00360       AES_ENC_4_LAST_ROUNDS(K12);
00361 
00362       _mm_storeu_si128(out_mm + 0, B0);
00363       _mm_storeu_si128(out_mm + 1, B1);
00364       _mm_storeu_si128(out_mm + 2, B2);
00365       _mm_storeu_si128(out_mm + 3, B3);
00366 
00367       blocks -= 4;
00368       in_mm += 4;
00369       out_mm += 4;
00370       }
00371 
00372    for(u32bit i = 0; i != blocks; ++i)
00373       {
00374       __m128i B = _mm_loadu_si128(in_mm + i);
00375 
00376       B = _mm_xor_si128(B, K0);
00377 
00378       B = _mm_aesenc_si128(B, K1);
00379       B = _mm_aesenc_si128(B, K2);
00380       B = _mm_aesenc_si128(B, K3);
00381       B = _mm_aesenc_si128(B, K4);
00382       B = _mm_aesenc_si128(B, K5);
00383       B = _mm_aesenc_si128(B, K6);
00384       B = _mm_aesenc_si128(B, K7);
00385       B = _mm_aesenc_si128(B, K8);
00386       B = _mm_aesenc_si128(B, K9);
00387       B = _mm_aesenc_si128(B, K10);
00388       B = _mm_aesenc_si128(B, K11);
00389       B = _mm_aesenclast_si128(B, K12);
00390 
00391       _mm_storeu_si128(out_mm + i, B);
00392       }
00393    }

std::string Botan::AES_192_Intel::name (  )  const [inline, virtual]

The name of the algorithm.

Returns:
name of the algorithm

Implements Botan::SymmetricAlgorithm.

Definition at line 49 of file aes_intel.h.

00049 { return "AES-192"; }

u32bit Botan::BlockCipher::parallel_bytes (  )  const [inline, inherited]

Returns:
prefererred parallelism of this cipher in bytes

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_192_Intel::parallelism (  )  const [inline, virtual]

Returns:
native parallelism of this cipher in blocks

Reimplemented from Botan::BlockCipher.

Definition at line 43 of file aes_intel.h.

00043 { return 4; }

void Botan::SymmetricAlgorithm::set_key ( const byte  key[],
u32bit  length 
) [inline, inherited]

Set the symmetric key of this object.

Parameters:
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]

bool Botan::SymmetricAlgorithm::valid_keylength ( u32bit  length  )  const [inline, inherited]

Check whether a given key length is valid for this algorithm.

Parameters:
length the key length to be checked.
Returns:
true if the key length is valid.

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          }


Member Data Documentation

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().

A valid keylength is a multiple of this value.

Definition at line 37 of file sym_algo.h.

Referenced by Botan::keylength_multiple_of().

The maximum allowed key length.

Definition at line 27 of file sym_algo.h.

Referenced by Botan::max_keylength_of().

The minimal allowed key length.

Definition at line 32 of file sym_algo.h.

Referenced by Botan::min_keylength_of().


The documentation for this class was generated from the following files:

Generated on Tue Jun 29 08:56:41 2010 for Botan by  doxygen 1.5.8