From bbc6ea53558c12ed7ea8880b8515432f6c7414d2 Mon Sep 17 00:00:00 2001 From: Jeffrey Walton Date: Sat, 30 Sep 2017 06:19:28 -0400 Subject: [PATCH] Comments, constants and whitespace --- authenc.cpp | 3 +-- authenc.h | 9 ++++++--- ccm.cpp | 1 - cryptlib.h | 2 +- eax.cpp | 2 +- filters.cpp | 2 +- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/authenc.cpp b/authenc.cpp index 0ed9cd14..bb6cf2c0 100644 --- a/authenc.cpp +++ b/authenc.cpp @@ -74,8 +74,7 @@ void AuthenticatedSymmetricCipherBase::Resynchronize(const byte *iv, int length) void AuthenticatedSymmetricCipherBase::Update(const byte *input, size_t length) { - if (length == 0) - return; + if (length == 0) {return;} switch (m_state) { diff --git a/authenc.h b/authenc.h index 8e460c77..a0dd5a1c 100644 --- a/authenc.h +++ b/authenc.h @@ -78,11 +78,14 @@ protected: virtual void AuthenticateLastConfidentialBlock() {} virtual void AuthenticateLastFooterBlock(byte *mac, size_t macSize) =0; + // State_AuthUntransformed: authentication is applied to plain text (Authenticate-then-Encrypt) + // State_AuthTransformed: authentication is applied to cipher text (Encrypt-then-Authenticate) enum State {State_Start, State_KeySet, State_IVSet, State_AuthUntransformed, State_AuthTransformed, State_AuthFooter}; - State m_state; - unsigned int m_bufferedDataLength; - lword m_totalHeaderLength, m_totalMessageLength, m_totalFooterLength; + AlignedSecByteBlock m_buffer; + lword m_totalHeaderLength, m_totalMessageLength, m_totalFooterLength; + unsigned int m_bufferedDataLength; + State m_state; }; NAMESPACE_END diff --git a/ccm.cpp b/ccm.cpp index 0d40397e..c0c2c352 100644 --- a/ccm.cpp +++ b/ccm.cpp @@ -11,7 +11,6 @@ NAMESPACE_BEGIN(CryptoPP) void CCM_Base::SetKeyWithoutResync(const byte *userKey, size_t keylength, const NameValuePairs ¶ms) { BlockCipher &blockCipher = AccessBlockCipher(); - blockCipher.SetKey(userKey, keylength, params); if (blockCipher.BlockSize() != REQUIRED_BLOCKSIZE) diff --git a/cryptlib.h b/cryptlib.h index 84fd9507..c9336bb8 100644 --- a/cryptlib.h +++ b/cryptlib.h @@ -913,7 +913,7 @@ public: //!
  if (m_cipher.IsLastBlockSpecial())
 	//!   {
 	//!     size_t reserve = 2*m_cipher.MandatoryBlockSize();
-	//!     space = HelpCreatePutSpace(*AttachedTransformation(), DEFAULT_CHANNEL, length, length+reserve);
+	//!     space = HelpCreatePutSpace(*AttachedTransformation(), DEFAULT_CHANNEL, length+reserve);
 	//!     length = m_cipher.ProcessLastBlock(space, length+reserve, inString, length);
 	//!     AttachedTransformation()->Put(space, length);
 	//!     return;
diff --git a/eax.cpp b/eax.cpp
index ef4f2a9f..90b9d90b 100644
--- a/eax.cpp
+++ b/eax.cpp
@@ -36,7 +36,7 @@ void EAX_Base::AuthenticateLastHeaderBlock()
 {
 	CRYPTOPP_ASSERT(m_bufferedDataLength == 0);
 	MessageAuthenticationCode &mac = AccessMAC();
-	unsigned int blockSize = mac.TagSize();
+	const unsigned int blockSize = mac.TagSize();
 
 	mac.Final(m_buffer);
 	xorbuf(m_buffer+blockSize, m_buffer, blockSize);
diff --git a/filters.cpp b/filters.cpp
index 98f3bd7a..b05db19d 100644
--- a/filters.cpp
+++ b/filters.cpp
@@ -690,7 +690,7 @@ void StreamTransformationFilter::LastPut(const byte *inString, size_t length)
 	if (m_cipher.IsLastBlockSpecial())
 	{
 		size_t reserve = 2*m_cipher.MandatoryBlockSize();
-		space = HelpCreatePutSpace(*AttachedTransformation(), DEFAULT_CHANNEL, length, length+reserve);
+		space = HelpCreatePutSpace(*AttachedTransformation(), DEFAULT_CHANNEL, length+reserve);
 		length = m_cipher.ProcessLastBlock(space, length+reserve, inString, length);
 		AttachedTransformation()->Put(space, length);
 		return;