From 4dfe046390d467dd8572b9b4876a8e823098d3e2 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sat, 24 Aug 2024 11:26:55 +0200 Subject: Windows: Implement foundations for Argon2 support as a KDF in addition to PBKDF2 --- src/Common/EncryptionThreadPool.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/Common/EncryptionThreadPool.c') diff --git a/src/Common/EncryptionThreadPool.c b/src/Common/EncryptionThreadPool.c index 79f1c890..a4be9a54 100644 --- a/src/Common/EncryptionThreadPool.c +++ b/src/Common/EncryptionThreadPool.c @@ -100,6 +100,7 @@ typedef struct EncryptionThreadPoolWorkItemStruct LONG *CompletionFlag; char *DerivedKey; int IterationCount; + int Memorycost; TC_EVENT *NoOutstandingWorkItemEvent; LONG *OutstandingWorkItemCount; char *Password; @@ -273,6 +274,11 @@ static TC_THREAD_PROC EncryptionThreadProc (void *threadArg) workItem->KeyDerivation.IterationCount, workItem->KeyDerivation.DerivedKey, GetMaxPkcs5OutSize()); break; + case ARGON2: + derive_key_argon2(workItem->KeyDerivation.Password, workItem->KeyDerivation.PasswordLength, workItem->KeyDerivation.Salt, PKCS5_SALT_SIZE, + workItem->KeyDerivation.IterationCount, workItem->KeyDerivation.Memorycost, workItem->KeyDerivation.DerivedKey, GetMaxPkcs5OutSize()); + break; + default: TC_THROW_FATAL_EXCEPTION; } @@ -533,7 +539,7 @@ void EncryptionThreadPoolStop () } -void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, char *password, int passwordLength, char *salt, int iterationCount, char *derivedKey) +void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, char *password, int passwordLength, char *salt, int iterationCount, int memoryCost, char *derivedKey) { EncryptionThreadPoolWorkItem *workItem; @@ -556,6 +562,7 @@ void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT workItem->KeyDerivation.CompletionFlag = completionFlag; workItem->KeyDerivation.DerivedKey = derivedKey; workItem->KeyDerivation.IterationCount = iterationCount; + workItem->KeyDerivation.Memorycost = memoryCost; workItem->KeyDerivation.NoOutstandingWorkItemEvent = noOutstandingWorkItemEvent; workItem->KeyDerivation.OutstandingWorkItemCount = outstandingWorkItemCount; workItem->KeyDerivation.Password = password; -- cgit v1.2.3