From 09023bf45e5bb32ac31c5ddce0105a4e0afe3b83 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Tue, 5 Sep 2017 16:43:29 -0400 Subject: [PATCH] Align buffers for Poly1305 and VMAC --- poly1305.cpp | 4 +++- vmac.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/poly1305.cpp b/poly1305.cpp index 9bef7585..6f778677 100644 --- a/poly1305.cpp +++ b/poly1305.cpp @@ -34,7 +34,9 @@ void Poly1305_Base::UncheckedSetKey(const byte *key, unsigned int length, con if (params.GetValue(Name::IV(), t) && t.begin() && t.size()) { // Nonce key is a class member to avoid the zeroizer on a temporary - m_cipher.ProcessBlock(t.begin(), m_nk.begin()); + CRYPTOPP_ASSERT(t.size() == m_nk.size()); + std::memcpy(m_nk.begin(), t.begin(), m_nk.size()); + m_cipher.ProcessBlock(m_nk.begin()); m_n[0] = GetWord(false, LITTLE_ENDIAN_ORDER, m_nk + 0); m_n[1] = GetWord(false, LITTLE_ENDIAN_ORDER, m_nk + 4); diff --git a/vmac.cpp b/vmac.cpp index 8978a73a..c99b2692 100644 --- a/vmac.cpp +++ b/vmac.cpp @@ -69,8 +69,8 @@ void VMAC_Base::UncheckedSetKey(const byte *userKey, unsigned int keylength, con cipher.SetKey(userKey, keylength, params); const unsigned int blockSize = cipher.BlockSize(); const unsigned int blockSizeInWords = blockSize / sizeof(word64); - SecBlock out(blockSizeInWords); - SecByteBlock in; + SecBlock > out(blockSizeInWords); + AlignedSecByteBlock in; in.CleanNew(blockSize); size_t i;