1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2026-06-09 22:36:59 -05:00

Use blake2b as hash for random generator from Argon2 is used.

This commit is contained in:
Mounir IDRASSI
2025-07-03 17:32:47 +09:00
parent eadb02d8ef
commit 3867c1cca3
30 changed files with 134 additions and 75 deletions
+2 -2
View File
@@ -133,7 +133,7 @@ static Hash Hashes[] =
{ BLAKE2S, L"BLAKE2s-256", FALSE, TRUE },
{ WHIRLPOOL, L"Whirlpool", FALSE, FALSE },
{ STREEBOG, L"Streebog", FALSE, FALSE },
{ ARGON2, L"Argon2", FALSE, FALSE },
{ ARGON2, L"BLAKE2b-512", FALSE, FALSE },
#endif
{ 0, 0, 0 }
};
@@ -780,7 +780,7 @@ BOOL HashForSystemEncryption (int hashId)
BOOL HashIsAvailable (int hashId)
{
return (hashId != ARGON2) && (HashGet(hashId) != 0); // Argon2 is not a hash function
return (HashGet(hashId) != 0);
}
// Returns the largest key size needed by an EA for the specified mode of operation
+2 -1
View File
@@ -200,11 +200,12 @@ typedef struct
#endif
#include "Twofish.h"
#include "blake2.h"
#include "blake2s.h"
#ifndef TC_WINDOWS_BOOT
# include "Sha2.h"
# include "Whirlpool.h"
# include "argon2.h"
# include "blake2b.h"
# include "Streebog.h"
# include "kuznyechik.h"
# include "Camellia.h"
+10 -6
View File
@@ -6343,10 +6343,11 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
{
BYTE digest [MAX_DIGESTSIZE];
#ifndef WOLFCRYPT_BACKEND
WHIRLPOOL_CTX wctx;
WHIRLPOOL_CTX wctx;
STREEBOG_CTX stctx;
blake2s_state bctx;
#endif
blake2s_state bctx;
blake2b_state b2ctx;
#endif
sha512_ctx s2ctx;
sha256_ctx s256ctx;
@@ -6354,9 +6355,6 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++)
{
// Skip Argon2 since it is not a hash function
if (hid == ARGON2)
continue;
if (QueryPerformanceCounter (&performanceCountStart) == 0)
goto counter_error;
@@ -6394,6 +6392,12 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
STREEBOG_add(&stctx, lpTestBuffer, benchmarkBufferSize);
STREEBOG_finalize(&stctx, (unsigned char *)digest);
break;
case ARGON2:
// For Argon2, we measure speed of the underlying blake2b hash function
blake2b_init(&b2ctx, BLAKE2B_OUTBYTES);
blake2b_update(&b2ctx, lpTestBuffer, benchmarkBufferSize);
blake2b_final(&b2ctx, digest, BLAKE2B_OUTBYTES);
break;
}
#endif
+1 -1
View File
@@ -16,7 +16,7 @@
#include <memory.h>
#include <stdlib.h>
#endif
#include "blake2.h"
#include "blake2s.h"
#ifndef TC_WINDOWS_BOOT
#include "Sha2.h"
#include "Whirlpool.h"
+13 -6
View File
@@ -258,8 +258,9 @@ BOOL Randmix ()
{
unsigned char hashOutputBuffer [MAX_DIGESTSIZE];
#ifndef WOLFCRYPT_BACKEND
WHIRLPOOL_CTX wctx;
blake2s_state bctx;
WHIRLPOOL_CTX wctx;
blake2s_state bctx;
blake2b_state b2ctx;
STREEBOG_CTX stctx;
#endif
sha512_ctx sctx;
@@ -314,9 +315,8 @@ BOOL Randmix ()
sha256_end (hashOutputBuffer, &s256ctx);
break;
#ifndef WOLFCRYPT_BACKEND
case BLAKE2S:
case ARGON2: // in case of Argon2, we use Blake2s
#ifndef WOLFCRYPT_BACKEND
case BLAKE2S:
blake2s_init(&bctx);
blake2s_update(&bctx, pRandPool, RNG_POOL_SIZE);
blake2s_final(&bctx, hashOutputBuffer);
@@ -333,7 +333,14 @@ BOOL Randmix ()
STREEBOG_add (&stctx, pRandPool, RNG_POOL_SIZE);
STREEBOG_finalize (&stctx, hashOutputBuffer);
break;
#endif
case ARGON2:
// For Argon2, we use the underlying Blake2b hash function
blake2b_init(&b2ctx, BLAKE2B_OUTBYTES);
blake2b_update(&b2ctx, pRandPool, RNG_POOL_SIZE);
blake2b_final(&b2ctx, hashOutputBuffer, BLAKE2B_OUTBYTES);
break;
#endif
default:
// Unknown/wrong ID
TC_THROW_FATAL_EXCEPTION;