From 3bd9e5c14a7e244a5c154db3c821e69cad3df08c Mon Sep 17 00:00:00 2001 From: lloyd Date: Thu, 28 Mar 2013 17:30:22 +0000 Subject: Add an offset to ignore at the start of the buffer in AEAD processing which makes more complicated packet building easier to do in-place. For instance now update can take a buffer that contains a header and be told to ignore the header. --- src/aead/aead.h | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/aead/aead.h') diff --git a/src/aead/aead.h b/src/aead/aead.h index 736de85e1..e0e07e8ab 100644 --- a/src/aead/aead.h +++ b/src/aead/aead.h @@ -33,6 +33,11 @@ class AEAD_Mode : public SymmetricAlgorithm */ virtual size_t minimum_final_size() const = 0; + /** + * @return Random nonce appropriate for passing to start + */ + //virtual secure_vector nonce(RandomNumberGenerator& rng) const = 0; + /** * Set associated data that is not included in the ciphertext but * that should be authenticated. Must be called after set_key @@ -47,6 +52,12 @@ class AEAD_Mode : public SymmetricAlgorithm */ virtual void set_associated_data(const byte ad[], size_t ad_len) = 0; + template + void set_associated_data_vec(const std::vector& ad) + { + set_associated_data(&ad[0], ad.size()); + } + virtual bool valid_nonce_length(size_t) const = 0; /** @@ -68,7 +79,7 @@ class AEAD_Mode : public SymmetricAlgorithm * update_granularity() byte blocks. * @param blocks in/out paramter which will possibly be resized */ - virtual void update(secure_vector& blocks) = 0; + virtual void update(secure_vector& blocks, size_t offset = 0) = 0; /** * Complete processing of a message. For decryption, may throw an exception @@ -76,8 +87,9 @@ class AEAD_Mode : public SymmetricAlgorithm * * @param final_block in/out parameter which must be at least * minimum_final_size() bytes, and will be set to any final output + * @param offset an offset into final_block to begin processing */ - virtual void finish(secure_vector& final_block) = 0; + virtual void finish(secure_vector& final_block, size_t offset = 0) = 0; virtual ~AEAD_Mode() {} }; -- cgit v1.2.3