VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-09-20 14:14:49 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-10-17 18:40:12 +0200
commitb81ec7d7e0170bed5a878169daed9392bf80751d (patch)
tree5fbd114f8e0c20bf671050df4a8ce5a3e7716ce5
parent479925f40340a67cee3f9b5e1199952987176d33 (diff)
downloadVeraCrypt-b81ec7d7e0170bed5a878169daed9392bf80751d.tar.gz
VeraCrypt-b81ec7d7e0170bed5a878169daed9392bf80751d.zip
Crypto: make HMAC-SHA512 code more clear by removing the memory usage optimization and make field k of hmac_sha512_ctx big enough to hold computation results instead of relying on the field u that follows it.
-rw-r--r--src/Common/Pkcs5.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/Common/Pkcs5.c b/src/Common/Pkcs5.c
index 3dbfd322..d0dbd8bc 100644
--- a/src/Common/Pkcs5.c
+++ b/src/Common/Pkcs5.c
@@ -280,7 +280,7 @@ typedef struct hmac_sha512_ctx_struct
sha512_ctx ctx;
sha512_ctx inner_digest_ctx; /*pre-computed inner digest context */
sha512_ctx outer_digest_ctx; /*pre-computed outer digest context */
- char k[PKCS5_SALT_SIZE + 4]; /* enough to hold (salt_len + 4) and also the SHA512 hash */
+ char k[SHA512_BLOCKSIZE]; /* enough to hold (salt_len + 4) and also the SHA512 hash */
char u[SHA512_DIGESTSIZE];
} hmac_sha512_ctx;
@@ -322,9 +322,7 @@ void hmac_sha512
{
hmac_sha512_ctx hmac;
sha512_ctx* ctx;
- char* buf = hmac.k; /* there is enough space to hold SHA512_BLOCKSIZE (128) bytes
- * because k is followed by u in hmac_sha512_ctx
- */
+ char* buf = hmac.k;
int b;
char key[SHA512_DIGESTSIZE];
@@ -405,9 +403,7 @@ void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32
{
hmac_sha512_ctx hmac;
sha512_ctx* ctx;
- char* buf = hmac.k; /* there is enough space to hold SHA512_BLOCKSIZE (128) bytes
- * because k is followed by u in hmac_sha512_ctx
- */
+ char* buf = hmac.k;
int b, l, r;
char key[SHA512_DIGESTSIZE];