VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Crypto
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-10-14 15:22:51 (GMT)
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-11-08 22:24:01 (GMT)
commit905a3ff4a5d70a00d9ba7819b9f43ad9ce0654e6 (patch)
treee1e3e34ec2c1192d7f15fbb5bec8d1ac404e9ad8 /src/Crypto
parent922a09b6342f1d7859e67ee8949b4590dc796b04 (diff)
downloadVeraCrypt-905a3ff4a5d70a00d9ba7819b9f43ad9ce0654e6.zip
VeraCrypt-905a3ff4a5d70a00d9ba7819b9f43ad9ce0654e6.tar.gz
Small code size optimization for RIPEMD-160 when compiled for boot encryption.
Diffstat (limited to 'src/Crypto')
-rw-r--r--src/Crypto/Rmd160.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/Crypto/Rmd160.c b/src/Crypto/Rmd160.c
index 7441dd7..05285c0 100644
--- a/src/Crypto/Rmd160.c
+++ b/src/Crypto/Rmd160.c
@@ -68,17 +68,18 @@ void RMD160Init (RMD160_CTX *ctx)
void RMD160Update (RMD160_CTX *ctx, const unsigned char *input, unsigned __int32 lenArg)
{
#ifndef TC_WINDOWS_BOOT
- uint64 len = lenArg, have, need;
+ uint64 len = lenArg;
#else
- uint32 len = lenArg, have, need;
+ uint32 len = lenArg;
#endif
+ unsigned int have, need;
/* Check how many bytes we already have and how many more we need. */
- have = ((ctx->count >> 3) & (RIPEMD160_BLOCK_LENGTH - 1));
+ have = (unsigned int) ((ctx->count) & (RIPEMD160_BLOCK_LENGTH - 1));
need = RIPEMD160_BLOCK_LENGTH - have;
/* Update bitcount */
- ctx->count += len << 3;
+ ctx->count += len;
if (len >= need) {
if (have != 0) {
@@ -114,15 +115,16 @@ static void RMD160Pad(RMD160_CTX *ctx)
/* Convert count to 8 bytes in little endian order. */
#ifndef TC_WINDOWS_BOOT
- PUT_64BIT_LE(count, ctx->count);
+ uint64 bitcount = ctx->count << 3;
+ PUT_64BIT_LE(count, bitcount);
#else
*(uint32 *) (count + 4) = 0;
- *(uint32 *) (count + 0) = ctx->count;
+ *(uint32 *) (count + 0) = ctx->count << 3;
#endif
/* Pad out to 56 mod 64. */
padlen = RIPEMD160_BLOCK_LENGTH -
- (uint32)((ctx->count >> 3) & (RIPEMD160_BLOCK_LENGTH - 1));
+ (uint32)((ctx->count) & (RIPEMD160_BLOCK_LENGTH - 1));
if (padlen < 1 + 8)
padlen += RIPEMD160_BLOCK_LENGTH;
RMD160Update(ctx, PADDING, padlen - 8); /* padlen - 8 <= 64 */