diff options
author | lloyd <[email protected]> | 2009-11-06 15:48:58 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-11-06 15:48:58 +0000 |
commit | 89da502ff80a9c63038b8b02a5062e460dff4649 (patch) | |
tree | 336208ded07cf9adcf7144d5748109fa24ad026c /src/block/aes_intel/aes_intel.h | |
parent | 2fa888b0147a644de0df42fe0721eeb385810714 (diff) |
Stub for AES class using Intel's AES-NI instructions and an engine for
providing it. Also stubs in the engine for VIA's AES instructions, but
needs CPUID checking also.
Diffstat (limited to 'src/block/aes_intel/aes_intel.h')
-rw-r--r-- | src/block/aes_intel/aes_intel.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/block/aes_intel/aes_intel.h b/src/block/aes_intel/aes_intel.h new file mode 100644 index 000000000..b40c2d3f6 --- /dev/null +++ b/src/block/aes_intel/aes_intel.h @@ -0,0 +1,74 @@ +/** +* AES using Intel's AES instructions +* (C) 1999-2009 Jack Lloyd +* +* Distributed under the terms of the Botan license +*/ + +#ifndef BOTAN_AES_INTEL_H__ +#define BOTAN_AES_INTEL_H__ + +#include <botan/block_cipher.h> + +namespace Botan { + +class BOTAN_DLL AES_Intel : public BlockCipher + { + public: + void encrypt_n(const byte in[], byte out[], u32bit blocks) const; + void decrypt_n(const byte in[], byte out[], u32bit blocks) const; + + void clear(); + std::string name() const { return "AES"; } + BlockCipher* clone() const { return new AES_Intel; } + + AES_Intel() : BlockCipher(16, 16, 32, 8) { ROUNDS = 14; } + AES_Intel(u32bit); + private: + void key_schedule(const byte[], u32bit); + + u32bit ROUNDS; + + SecureBuffer<u32bit, 56> EK; + SecureBuffer<byte, 16> ME; + + SecureBuffer<u32bit, 56> DK; + SecureBuffer<byte, 16> MD; + }; + +/** +* AES-128 +*/ +class BOTAN_DLL AES_Intel_128 : public AES_Intel + { + public: + std::string name() const { return "AES-128"; } + BlockCipher* clone() const { return new AES_Intel_128; } + AES_Intel_128() : AES_Intel(16) {} + }; + +/** +* AES-192 +*/ +class BOTAN_DLL AES_Intel_192 : public AES_Intel + { + public: + std::string name() const { return "AES-192"; } + BlockCipher* clone() const { return new AES_Intel_192; } + AES_Intel_192() : AES_Intel(24) {} + }; + +/** +* AES-256 +*/ +class BOTAN_DLL AES_Intel_256 : public AES_Intel + { + public: + std::string name() const { return "AES-256"; } + BlockCipher* clone() const { return new AES_Intel_256; } + AES_Intel_256() : AES_Intel(32) {} + }; + +} + +#endif |