From 7c3414b0721dfafb7c71904dcbac2ee0fda359ef Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Mon, 28 Jan 2019 10:01:19 -0500 Subject: [PATCH] Fix ChaCha20Poly1305 IVSize() (GH #724) --- chachapoly.cpp | 2 +- chachapoly.h | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/chachapoly.cpp b/chachapoly.cpp index 90b2864c..02a1f6b1 100644 --- a/chachapoly.cpp +++ b/chachapoly.cpp @@ -19,7 +19,7 @@ void ChaCha20Poly1305_Base::RekeyCipherAndMac(const byte *userKey, size_t keylen AccessSymmetricCipher().ProcessString(derived, derived.size()); // Set the Poly1305 key - AccessMAC().SetKey(derived, 32, params); + AccessMAC().SetKey(derived, derived.size(), params); // Key Cipher for bulk encryption AlgorithmParameters block1 = MakeParameters("InitialBlock", (word64)1, true); diff --git a/chachapoly.h b/chachapoly.h index 31dc9659..0c03e392 100644 --- a/chachapoly.h +++ b/chachapoly.h @@ -53,7 +53,7 @@ public: IV_Requirement IVRequirement() const {return UNIQUE_IV;} unsigned int IVSize() const - {return 16;} + {return 12;} unsigned int MinIVLength() const {return 12;} unsigned int MaxIVLength() const @@ -128,6 +128,10 @@ protected: /// \since Crypto++ 8.1 class ChaCha20Poly1305_Final : public ChaCha20Poly1305_Base { +public: + static std::string StaticAlgorithmName() + {return std::string("ChaCha20/Poly1305");} + protected: const SymmetricCipher & GetSymmetricCipher() {return const_cast(this)->AccessSymmetricCipher();}