summaryrefslogtreecommitdiff
path: root/cbcmac.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2015-11-05 01:59:46 -0500
committerJeffrey Walton <noloader@gmail.com>2015-11-05 01:59:46 -0500
commit48809d4e85c125814425c621d8d0d89f95405924 (patch)
tree1010fd16c4b1199f3d27dd726dda241a2bd29f83 /cbcmac.cpp
parent025337a94aceb75d188149db70c2094673772816 (diff)
downloadcryptopp-git-48809d4e85c125814425c621d8d0d89f95405924.tar.gz
CRYPTOPP 5.6.3 RC6 checkin
Diffstat (limited to 'cbcmac.cpp')
-rw-r--r--cbcmac.cpp124
1 files changed, 62 insertions, 62 deletions
diff --git a/cbcmac.cpp b/cbcmac.cpp
index 6b0e8858..b0c46de2 100644
--- a/cbcmac.cpp
+++ b/cbcmac.cpp
@@ -1,62 +1,62 @@
-#include "pch.h"
-
-#ifndef CRYPTOPP_IMPORTS
-
-#include "cbcmac.h"
-
-NAMESPACE_BEGIN(CryptoPP)
-
-void CBC_MAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
-{
- AccessCipher().SetKey(key, length, params);
- m_reg.CleanNew(AccessCipher().BlockSize());
- m_counter = 0;
-}
-
-void CBC_MAC_Base::Update(const byte *input, size_t length)
-{
- unsigned int blockSize = AccessCipher().BlockSize();
-
- while (m_counter && length)
- {
- m_reg[m_counter++] ^= *input++;
- if (m_counter == blockSize)
- ProcessBuf();
- length--;
- }
-
- if (length >= blockSize)
- {
- size_t leftOver = AccessCipher().AdvancedProcessBlocks(m_reg, input, m_reg, length, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
- input += (length - leftOver);
- length = leftOver;
- }
-
- while (length--)
- {
- m_reg[m_counter++] ^= *input++;
- if (m_counter == blockSize)
- ProcessBuf();
- }
-}
-
-void CBC_MAC_Base::TruncatedFinal(byte *mac, size_t size)
-{
- ThrowIfInvalidTruncatedSize(size);
-
- if (m_counter)
- ProcessBuf();
-
- memcpy(mac, m_reg, size);
- memset(m_reg, 0, AccessCipher().BlockSize());
-}
-
-void CBC_MAC_Base::ProcessBuf()
-{
- AccessCipher().ProcessBlock(m_reg);
- m_counter = 0;
-}
-
-NAMESPACE_END
-
-#endif
+#include "pch.h"
+
+#ifndef CRYPTOPP_IMPORTS
+
+#include "cbcmac.h"
+
+NAMESPACE_BEGIN(CryptoPP)
+
+void CBC_MAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
+{
+ AccessCipher().SetKey(key, length, params);
+ m_reg.CleanNew(AccessCipher().BlockSize());
+ m_counter = 0;
+}
+
+void CBC_MAC_Base::Update(const byte *input, size_t length)
+{
+ unsigned int blockSize = AccessCipher().BlockSize();
+
+ while (m_counter && length)
+ {
+ m_reg[m_counter++] ^= *input++;
+ if (m_counter == blockSize)
+ ProcessBuf();
+ length--;
+ }
+
+ if (length >= blockSize)
+ {
+ size_t leftOver = AccessCipher().AdvancedProcessBlocks(m_reg, input, m_reg, length, BlockTransformation::BT_DontIncrementInOutPointers|BlockTransformation::BT_XorInput);
+ input += (length - leftOver);
+ length = leftOver;
+ }
+
+ while (length--)
+ {
+ m_reg[m_counter++] ^= *input++;
+ if (m_counter == blockSize)
+ ProcessBuf();
+ }
+}
+
+void CBC_MAC_Base::TruncatedFinal(byte *mac, size_t size)
+{
+ ThrowIfInvalidTruncatedSize(size);
+
+ if (m_counter)
+ ProcessBuf();
+
+ memcpy(mac, m_reg, size);
+ memset(m_reg, 0, AccessCipher().BlockSize());
+}
+
+void CBC_MAC_Base::ProcessBuf()
+{
+ AccessCipher().ProcessBlock(m_reg);
+ m_counter = 0;
+}
+
+NAMESPACE_END
+
+#endif