VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto/Whirlpool.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/Crypto/Whirlpool.c')
-rw-r--r--src/Crypto/Whirlpool.c51
1 files changed, 29 insertions, 22 deletions
diff --git a/src/Crypto/Whirlpool.c b/src/Crypto/Whirlpool.c
index 6a1fe8b4..140c7c6f 100644
--- a/src/Crypto/Whirlpool.c
+++ b/src/Crypto/Whirlpool.c
@@ -957,28 +957,35 @@ void WHIRLPOOL_add(const unsigned char * input,
}
// now process the input data in blocks of 64 bytes and save the leftovers to ctx->data
- if (len >= 64)
- {
- if (input == data)
- {
- HashMultipleBlocks(ctx, dataBuf, 64);
- return;
- }
- else if (IsAligned16(input))
- {
- uint64 leftOver = HashMultipleBlocks(ctx, (uint64 *)input, len);
- input += (len - leftOver);
- len = leftOver;
- }
- else
- do
- { // copy input first if it's not aligned correctly
- memcpy(data, input, 64);
- HashMultipleBlocks(ctx, dataBuf, 64);
- input+=64;
- len-=64;
- } while (len >= 64);
- }
+ if (len >= 64)
+ {
+ if (input == data)
+ {
+ HashMultipleBlocks(ctx, dataBuf, 64);
+ return;
+ }
+ else
+ {
+#ifndef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
+ if (IsAligned16(input))
+#endif
+ {
+ uint64 leftOver = HashMultipleBlocks(ctx, (uint64*)input, len);
+ input += (len - leftOver);
+ len = leftOver;
+ }
+#ifndef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS
+ else
+ do
+ { // copy input first if it's not aligned correctly
+ memcpy(data, input, 64);
+ HashMultipleBlocks(ctx, dataBuf, 64);
+ input += 64;
+ len -= 64;
+ } while (len >= 64);
+#endif
+ }
+ }
if (len && data != input)
memcpy(data, input, (size_t) len);