aboutsummaryrefslogtreecommitdiffstats
path: root/src/aead
diff options
context:
space:
mode:
authorlloyd <[email protected]>2013-04-10 14:40:14 +0000
committerlloyd <[email protected]>2013-04-10 14:40:14 +0000
commit70c3f7edc155bdbc2630e0086536a1c90506b5b9 (patch)
treeca7d439d08eba7fb33d1f15658522fc1816799e9 /src/aead
parentedc6851e89a33e0c2b2005fb5a079f9e91a5457e (diff)
Revert part of 5be6e329324fc8263de56167091754e27305917b,
AEAD_Mode::start now returns a value again. While not useful for any current modes it allows future flexibility of presenting protoocol-level concepts (eg, OpenPGP encryption) using the AEAD interface.
Diffstat (limited to 'src/aead')
-rw-r--r--src/aead/aead.h9
-rw-r--r--src/aead/eax/eax.cpp4
-rw-r--r--src/aead/eax/eax.h2
-rw-r--r--src/aead/gcm/gcm.cpp4
-rw-r--r--src/aead/gcm/gcm.h2
-rw-r--r--src/aead/ocb/ocb.cpp4
-rw-r--r--src/aead/ocb/ocb.h2
7 files changed, 14 insertions, 13 deletions
diff --git a/src/aead/aead.h b/src/aead/aead.h
index c4de71857..e0e07e8ab 100644
--- a/src/aead/aead.h
+++ b/src/aead/aead.h
@@ -66,10 +66,10 @@ class AEAD_Mode : public SymmetricAlgorithm
* @param nonce the per message nonce
* @param nonce_len length of nonce
*/
- virtual void start(const byte nonce[], size_t nonce_len) = 0;
+ virtual secure_vector<byte> start(const byte nonce[], size_t nonce_len) = 0;
template<typename Alloc>
- void start_vec(const std::vector<byte, Alloc>& nonce)
+ secure_vector<byte> start_vec(const std::vector<byte, Alloc>& nonce)
{
return start(&nonce[0], nonce.size());
}
@@ -94,11 +94,6 @@ class AEAD_Mode : public SymmetricAlgorithm
virtual ~AEAD_Mode() {}
};
-/**
-* Get an AEAD mode by name (eg "AES-128/GCM" or "Serpent/EAX")
-*/
-BOTAN_DLL AEAD_Mode* get_aead(const std::string& name, Cipher_Dir direction);
-
}
#endif
diff --git a/src/aead/eax/eax.cpp b/src/aead/eax/eax.cpp
index a0e00b6d6..c6aaa9e85 100644
--- a/src/aead/eax/eax.cpp
+++ b/src/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);
}
-void EAX_Mode::start(const byte nonce[], size_t nonce_len)
+secure_vector<byte> EAX_Mode::start(const byte nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -104,6 +104,8 @@ void EAX_Mode::start(const byte nonce[], size_t nonce_len)
for(size_t i = 0; i != block_size() - 1; ++i)
m_cmac->update(0);
m_cmac->update(2);
+
+ return secure_vector<byte>();
}
void EAX_Encryption::update(secure_vector<byte>& buffer, size_t offset)
diff --git a/src/aead/eax/eax.h b/src/aead/eax/eax.h
index 790f24513..6720bdca4 100644
--- a/src/aead/eax/eax.h
+++ b/src/aead/eax/eax.h
@@ -22,7 +22,7 @@ namespace Botan {
class BOTAN_DLL EAX_Mode : public AEAD_Mode
{
public:
- void start(const byte nonce[], size_t nonce_len) override;
+ secure_vector<byte> start(const byte nonce[], size_t nonce_len) override;
void set_associated_data(const byte ad[], size_t ad_len) override;
diff --git a/src/aead/gcm/gcm.cpp b/src/aead/gcm/gcm.cpp
index fbef36fee..665fc4472 100644
--- a/src/aead/gcm/gcm.cpp
+++ b/src/aead/gcm/gcm.cpp
@@ -153,7 +153,7 @@ void GCM_Mode::set_associated_data(const byte ad[], size_t ad_len)
m_ad_len = ad_len;
}
-void GCM_Mode::start(const byte nonce[], size_t nonce_len)
+secure_vector<byte> GCM_Mode::start(const byte nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -178,6 +178,8 @@ void GCM_Mode::start(const byte nonce[], size_t nonce_len)
m_text_len = 0;
m_mac = m_H_ad;
+
+ return secure_vector<byte>();
}
void GCM_Encryption::update(secure_vector<byte>& buffer, size_t offset)
diff --git a/src/aead/gcm/gcm.h b/src/aead/gcm/gcm.h
index 10a4a3497..bc7eaae20 100644
--- a/src/aead/gcm/gcm.h
+++ b/src/aead/gcm/gcm.h
@@ -21,7 +21,7 @@ namespace Botan {
class BOTAN_DLL GCM_Mode : public AEAD_Mode
{
public:
- void start(const byte nonce[], size_t nonce_len) override;
+ secure_vector<byte> start(const byte nonce[], size_t nonce_len) override;
void set_associated_data(const byte ad[], size_t ad_len) override;
diff --git a/src/aead/ocb/ocb.cpp b/src/aead/ocb/ocb.cpp
index 20f54dca7..4cbd8bde8 100644
--- a/src/aead/ocb/ocb.cpp
+++ b/src/aead/ocb/ocb.cpp
@@ -215,7 +215,7 @@ void OCB_Mode::set_associated_data(const byte ad[], size_t ad_len)
m_ad_hash = ocb_hash(*m_L, *m_cipher, &ad[0], ad_len);
}
-void OCB_Mode::start(const byte nonce[], size_t nonce_len)
+secure_vector<byte> OCB_Mode::start(const byte nonce[], size_t nonce_len)
{
if(!valid_nonce_length(nonce_len))
throw Invalid_IV_Length(name(), nonce_len);
@@ -225,6 +225,8 @@ void OCB_Mode::start(const byte nonce[], size_t nonce_len)
m_offset = m_nonce_state->update_nonce(nonce, nonce_len);
zeroise(m_checksum);
m_block_index = 0;
+
+ return secure_vector<byte>();
}
void OCB_Encryption::encrypt(byte buffer[], size_t blocks)
diff --git a/src/aead/ocb/ocb.h b/src/aead/ocb/ocb.h
index 597cd9c52..d50710a79 100644
--- a/src/aead/ocb/ocb.h
+++ b/src/aead/ocb/ocb.h
@@ -30,7 +30,7 @@ class Nonce_State;
class BOTAN_DLL OCB_Mode : public AEAD_Mode
{
public:
- void start(const byte nonce[], size_t nonce_len) override;
+ secure_vector<byte> start(const byte nonce[], size_t nonce_len) override;
void set_associated_data(const byte ad[], size_t ad_len) override;