diff options
author | lloyd <[email protected]> | 2013-03-27 14:03:58 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2013-03-27 14:03:58 +0000 |
commit | 7703ed769010f9ef4d037be1e9d1183a854f8348 (patch) | |
tree | 5766676f2c8c89d39b953c10466cb8d996bddf95 /src/aead/eax | |
parent | 86ecbb4fc9d4db13281a2cb689c604222900a6e7 (diff) |
Move GCM to new AEAD interface
Diffstat (limited to 'src/aead/eax')
-rw-r--r-- | src/aead/eax/eax.cpp | 27 | ||||
-rw-r--r-- | src/aead/eax/eax.h | 13 | ||||
-rw-r--r-- | src/aead/eax/info.txt | 2 |
3 files changed, 28 insertions, 14 deletions
diff --git a/src/aead/eax/eax.cpp b/src/aead/eax/eax.cpp index d03d6ec5e..8a7287062 100644 --- a/src/aead/eax/eax.cpp +++ b/src/aead/eax/eax.cpp @@ -45,11 +45,30 @@ EAX_Mode::EAX_Mode(BlockCipher* cipher, size_t tag_size) : throw Invalid_Argument(name() + ": Bad tag size " + std::to_string(tag_size)); } +void EAX_Mode::clear() + { + m_cipher.reset(); + m_ctr.reset(); + m_cmac.reset(); + zeroise(m_ad_mac); + zeroise(m_nonce_mac); + } + +std::string EAX_Mode::name() const + { + return (m_cipher->name() + "/EAX"); + } + size_t EAX_Mode::update_granularity() const { return 8 * m_cipher->parallel_bytes(); } +Key_Length_Specification EAX_Mode::key_spec() const + { + return m_cipher->key_spec(); + } + /* * Set the EAX key */ @@ -86,14 +105,6 @@ secure_vector<byte> EAX_Mode::start(const byte nonce[], size_t nonce_len) return secure_vector<byte>(); } -/* -* Return the name of this cipher mode -*/ -std::string EAX_Mode::name() const - { - return (m_cipher->name() + "/EAX"); - } - void EAX_Encryption::update(secure_vector<byte>& buffer) { m_ctr->cipher(&buffer[0], &buffer[0], buffer.size()); diff --git a/src/aead/eax/eax.h b/src/aead/eax/eax.h index f7e1c6387..f3562f755 100644 --- a/src/aead/eax/eax.h +++ b/src/aead/eax/eax.h @@ -9,7 +9,6 @@ #define BOTAN_EAX_H__ #include <botan/aead.h> -#include <botan/buf_filt.h> #include <botan/block_cipher.h> #include <botan/stream_cipher.h> #include <botan/mac.h> @@ -18,23 +17,25 @@ namespace Botan { /** -* EAX Mode +* EAX base class */ class BOTAN_DLL EAX_Mode : public AEAD_Mode { public: - size_t update_granularity() const; - secure_vector<byte> start(const byte nonce[], size_t nonce_len) override; void set_associated_data(const byte ad[], size_t ad_len) override; std::string name() const override; - Key_Length_Specification key_spec() const override { return m_cipher->key_spec(); } + size_t update_granularity() const; + + Key_Length_Specification key_spec() const override; // EAX supports arbitrary nonce lengths bool valid_nonce_length(size_t) const override { return true; } + + void clear(); protected: void key_schedule(const byte key[], size_t length) override; @@ -72,6 +73,8 @@ class BOTAN_DLL EAX_Encryption : public EAX_Mode EAX_Encryption(BlockCipher* cipher, size_t tag_size = 16) : EAX_Mode(cipher, tag_size) {} + size_t minimum_final_size() const override { return 0; } + void update(secure_vector<byte>& blocks) override; void finish(secure_vector<byte>& final_block) override; diff --git a/src/aead/eax/info.txt b/src/aead/eax/info.txt index 09d92e724..94924e682 100644 --- a/src/aead/eax/info.txt +++ b/src/aead/eax/info.txt @@ -1,4 +1,4 @@ -define EAX +define AEAD_EAX <requires> block |