From df169024a36b5f72eaa40fef5f9fc6ca17261035 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sun, 5 Aug 2018 18:57:54 -0400 Subject: Fix crashes when modes were used unkeyed. Fix crashes in OCB, GCM and CFB when called without a key being set. --- src/lib/modes/aead/aead.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/lib/modes/aead/aead.h') diff --git a/src/lib/modes/aead/aead.h b/src/lib/modes/aead/aead.h index 4d4b60ce1..92957fb24 100644 --- a/src/lib/modes/aead/aead.h +++ b/src/lib/modes/aead/aead.h @@ -60,6 +60,13 @@ class BOTAN_PUBLIC_API(2,0) AEAD_Mode : public Cipher_Mode */ virtual void set_associated_data(const uint8_t ad[], size_t ad_len) = 0; + /** + * Most AEADs require the key to be set prior to setting the AD + * A few allow the AD to be set even before the cipher is keyed. + * Such ciphers would return false from this function. + */ + virtual bool associated_data_requires_key() const { return true; } + /** * Set associated data that is not included in the ciphertext but * that should be authenticated. Must be called after set_key and -- cgit v1.2.3