diff options
Diffstat (limited to 'src/lib/modes/aead')
-rw-r--r-- | src/lib/modes/aead/ccm/ccm.cpp | 2 | ||||
-rw-r--r-- | src/lib/modes/aead/ccm/ccm.h | 4 | ||||
-rw-r--r-- | src/lib/modes/aead/eax/eax.cpp | 2 | ||||
-rw-r--r-- | src/lib/modes/aead/eax/eax.h | 8 | ||||
-rw-r--r-- | src/lib/modes/aead/gcm/gcm.cpp | 2 | ||||
-rw-r--r-- | src/lib/modes/aead/gcm/gcm.h | 8 | ||||
-rw-r--r-- | src/lib/modes/aead/ocb/ocb.cpp | 2 | ||||
-rw-r--r-- | src/lib/modes/aead/ocb/ocb.h | 4 | ||||
-rw-r--r-- | src/lib/modes/aead/siv/siv.cpp | 12 | ||||
-rw-r--r-- | src/lib/modes/aead/siv/siv.h | 5 |
10 files changed, 23 insertions, 26 deletions
diff --git a/src/lib/modes/aead/ccm/ccm.cpp b/src/lib/modes/aead/ccm/ccm.cpp index 7fd92e149..2ae58c990 100644 --- a/src/lib/modes/aead/ccm/ccm.cpp +++ b/src/lib/modes/aead/ccm/ccm.cpp @@ -90,7 +90,7 @@ void CCM_Mode::set_associated_data(const byte ad[], size_t length) } } -secure_vector<byte> CCM_Mode::start(const byte nonce[], size_t nonce_len) +secure_vector<byte> CCM_Mode::start_raw(const byte nonce[], size_t nonce_len) { if(!valid_nonce_length(nonce_len)) throw Invalid_IV_Length(name(), nonce_len); diff --git a/src/lib/modes/aead/ccm/ccm.h b/src/lib/modes/aead/ccm/ccm.h index bf0f35e66..9db377827 100644 --- a/src/lib/modes/aead/ccm/ccm.h +++ b/src/lib/modes/aead/ccm/ccm.h @@ -22,8 +22,6 @@ namespace Botan { class BOTAN_DLL CCM_Mode : public AEAD_Mode { public: - secure_vector<byte> start(const byte nonce[], size_t nonce_len) override; - void update(secure_vector<byte>& blocks, size_t offset = 0) override; void set_associated_data(const byte ad[], size_t ad_len) override; @@ -62,6 +60,8 @@ class BOTAN_DLL CCM_Mode : public AEAD_Mode secure_vector<byte> format_b0(size_t msg_size); secure_vector<byte> format_c0(); private: + secure_vector<byte> start_raw(const byte nonce[], size_t nonce_len) override; + void key_schedule(const byte key[], size_t length) override; const size_t m_tag_size; diff --git a/src/lib/modes/aead/eax/eax.cpp b/src/lib/modes/aead/eax/eax.cpp index 249bf5f7e..c1d55d0e4 100644 --- a/src/lib/modes/aead/eax/eax.cpp +++ b/src/lib/modes/aead/eax/eax.cpp @@ -92,7 +92,7 @@ void EAX_Mode::set_associated_data(const byte ad[], size_t length) m_ad_mac = eax_prf(1, block_size(), *m_cmac, ad, length); } -secure_vector<byte> EAX_Mode::start(const byte nonce[], size_t nonce_len) +secure_vector<byte> EAX_Mode::start_raw(const byte nonce[], size_t nonce_len) { if(!valid_nonce_length(nonce_len)) throw Invalid_IV_Length(name(), nonce_len); diff --git a/src/lib/modes/aead/eax/eax.h b/src/lib/modes/aead/eax/eax.h index c27c83ed0..9e721c303 100644 --- a/src/lib/modes/aead/eax/eax.h +++ b/src/lib/modes/aead/eax/eax.h @@ -21,8 +21,6 @@ namespace Botan { class BOTAN_DLL EAX_Mode : public AEAD_Mode { public: - 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; @@ -38,8 +36,6 @@ class BOTAN_DLL EAX_Mode : public AEAD_Mode void clear() override; protected: - void key_schedule(const byte key[], size_t length) override; - /** * @param cipher the cipher to use * @param tag_size is how big the auth tag will be @@ -57,6 +53,10 @@ class BOTAN_DLL EAX_Mode : public AEAD_Mode secure_vector<byte> m_ad_mac; secure_vector<byte> m_nonce_mac; + private: + secure_vector<byte> start_raw(const byte nonce[], size_t nonce_len) override; + + void key_schedule(const byte key[], size_t length) override; }; /** diff --git a/src/lib/modes/aead/gcm/gcm.cpp b/src/lib/modes/aead/gcm/gcm.cpp index b39e6ac92..2b60f332e 100644 --- a/src/lib/modes/aead/gcm/gcm.cpp +++ b/src/lib/modes/aead/gcm/gcm.cpp @@ -206,7 +206,7 @@ void GCM_Mode::set_associated_data(const byte ad[], size_t ad_len) m_ghash->set_associated_data(ad, ad_len); } -secure_vector<byte> GCM_Mode::start(const byte nonce[], size_t nonce_len) +secure_vector<byte> GCM_Mode::start_raw(const byte nonce[], size_t nonce_len) { if(!valid_nonce_length(nonce_len)) throw Invalid_IV_Length(name(), nonce_len); diff --git a/src/lib/modes/aead/gcm/gcm.h b/src/lib/modes/aead/gcm/gcm.h index 41cb189d9..918f3c7c7 100644 --- a/src/lib/modes/aead/gcm/gcm.h +++ b/src/lib/modes/aead/gcm/gcm.h @@ -22,8 +22,6 @@ class GHASH; class BOTAN_DLL GCM_Mode : public AEAD_Mode { public: - 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; @@ -39,8 +37,6 @@ class BOTAN_DLL GCM_Mode : public AEAD_Mode void clear() override; protected: - void key_schedule(const byte key[], size_t length) override; - GCM_Mode(BlockCipher* cipher, size_t tag_size); const size_t BS = 16; @@ -50,6 +46,10 @@ class BOTAN_DLL GCM_Mode : public AEAD_Mode std::unique_ptr<StreamCipher> m_ctr; std::unique_ptr<GHASH> m_ghash; + private: + secure_vector<byte> start_raw(const byte nonce[], size_t nonce_len) override; + + void key_schedule(const byte key[], size_t length) override; }; /** diff --git a/src/lib/modes/aead/ocb/ocb.cpp b/src/lib/modes/aead/ocb/ocb.cpp index 5909e0c12..8bb45f217 100644 --- a/src/lib/modes/aead/ocb/ocb.cpp +++ b/src/lib/modes/aead/ocb/ocb.cpp @@ -223,7 +223,7 @@ OCB_Mode::update_nonce(const byte nonce[], size_t nonce_len) return offset; } -secure_vector<byte> OCB_Mode::start(const byte nonce[], size_t nonce_len) +secure_vector<byte> OCB_Mode::start_raw(const byte nonce[], size_t nonce_len) { if(!valid_nonce_length(nonce_len)) throw Invalid_IV_Length(name(), nonce_len); diff --git a/src/lib/modes/aead/ocb/ocb.h b/src/lib/modes/aead/ocb/ocb.h index 24a6c474f..a7293ffcb 100644 --- a/src/lib/modes/aead/ocb/ocb.h +++ b/src/lib/modes/aead/ocb/ocb.h @@ -28,8 +28,6 @@ class L_computer; class BOTAN_DLL OCB_Mode : public AEAD_Mode { public: - 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; @@ -64,6 +62,8 @@ class BOTAN_DLL OCB_Mode : public AEAD_Mode secure_vector<byte> m_offset; secure_vector<byte> m_ad_hash; private: + secure_vector<byte> start_raw(const byte nonce[], size_t nonce_len) override; + secure_vector<byte> update_nonce(const byte nonce[], size_t nonce_len); size_t m_tag_size = 0; diff --git a/src/lib/modes/aead/siv/siv.cpp b/src/lib/modes/aead/siv/siv.cpp index be998cdb0..827be1ef7 100644 --- a/src/lib/modes/aead/siv/siv.cpp +++ b/src/lib/modes/aead/siv/siv.cpp @@ -71,7 +71,7 @@ void SIV_Mode::set_associated_data_n(size_t n, const byte ad[], size_t length) m_ad_macs[n] = m_cmac->process(ad, length); } -secure_vector<byte> SIV_Mode::start(const byte nonce[], size_t nonce_len) +secure_vector<byte> SIV_Mode::start_raw(const byte nonce[], size_t nonce_len) { if(!valid_nonce_length(nonce_len)) throw Invalid_IV_Length(name(), nonce_len); @@ -100,7 +100,7 @@ secure_vector<byte> SIV_Mode::S2V(const byte* text, size_t text_len) { const byte zero[16] = { 0 }; - secure_vector<byte> V = cmac().process(zero, 16); + secure_vector<byte> V = m_cmac->process(zero, 16); for(size_t i = 0; i != m_ad_macs.size(); ++i) { @@ -119,14 +119,14 @@ secure_vector<byte> SIV_Mode::S2V(const byte* text, size_t text_len) V = CMAC::poly_double(V); xor_buf(&V[0], text, text_len); V[text_len] ^= 0x80; - return cmac().process(V); + return m_cmac->process(V); } - cmac().update(text, text_len - 16); + m_cmac->update(text, text_len - 16); xor_buf(&V[0], &text[text_len - 16], 16); - cmac().update(V); + m_cmac->update(V); - return cmac().final(); + return m_cmac->final(); } void SIV_Mode::set_ctr_iv(secure_vector<byte> V) diff --git a/src/lib/modes/aead/siv/siv.h b/src/lib/modes/aead/siv/siv.h index bca8831b8..433771696 100644 --- a/src/lib/modes/aead/siv/siv.h +++ b/src/lib/modes/aead/siv/siv.h @@ -21,8 +21,6 @@ namespace Botan { class BOTAN_DLL SIV_Mode : public AEAD_Mode { public: - secure_vector<byte> start(const byte nonce[], size_t nonce_len) override; - void update(secure_vector<byte>& blocks, size_t offset = 0) override; void set_associated_data_n(size_t n, const byte ad[], size_t ad_len); @@ -55,12 +53,11 @@ class BOTAN_DLL SIV_Mode : public AEAD_Mode secure_vector<byte> S2V(const byte text[], size_t text_len); private: - MessageAuthenticationCode& cmac() { return *m_cmac; } + secure_vector<byte> start_raw(const byte nonce[], size_t nonce_len) override; void key_schedule(const byte key[], size_t length) override; const std::string m_name; - std::unique_ptr<StreamCipher> m_ctr; std::unique_ptr<MessageAuthenticationCode> m_cmac; secure_vector<byte> m_nonce, m_msg_buf; |