From 9eb10b06036840822c03aec900a1e64f90e77181 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Wed, 8 Aug 2018 13:05:13 -0400 Subject: Add StreamCipher::default_iv_length --- src/lib/stream/chacha/chacha.cpp | 2 +- src/lib/stream/chacha/chacha.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src/lib/stream/chacha') diff --git a/src/lib/stream/chacha/chacha.cpp b/src/lib/stream/chacha/chacha.cpp index 7ccc4293b..fac9a5a36 100644 --- a/src/lib/stream/chacha/chacha.cpp +++ b/src/lib/stream/chacha/chacha.cpp @@ -310,7 +310,7 @@ void ChaCha::seek(uint64_t offset) verify_key_set(m_state.empty() == false); // Find the block offset - uint64_t counter = offset / 64; + const uint64_t counter = offset / 64; uint8_t out[8]; diff --git a/src/lib/stream/chacha/chacha.h b/src/lib/stream/chacha/chacha.h index a4f3e3b75..d0e131315 100644 --- a/src/lib/stream/chacha/chacha.h +++ b/src/lib/stream/chacha/chacha.h @@ -34,11 +34,15 @@ class BOTAN_PUBLIC_API(2,0) ChaCha final : public StreamCipher void set_iv(const uint8_t iv[], size_t iv_len) override; /* - * ChaCha accepts 0, 8, or 12 byte IVs. The default IV is a 8 zero bytes. + * ChaCha accepts 0, 8, 12 or 24 byte IVs. + * The default IV is a 8 zero bytes. * An IV of length 0 is treated the same as the default zero IV. + * An IV of length 24 selects XChaCha mode */ bool valid_iv_length(size_t iv_len) const override; + size_t default_iv_length() const override { return 24; } + Key_Length_Specification key_spec() const override { return Key_Length_Specification(16, 32, 16); -- cgit v1.2.3