diff --git a/Translations/Language.ar.xml b/Translations/Language.ar.xml index 17b791ef..5b4f8a0f 100644 --- a/Translations/Language.ar.xml +++ b/Translations/Language.ar.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.be.xml b/Translations/Language.be.xml index 629722f0..db1ef18e 100644 --- a/Translations/Language.be.xml +++ b/Translations/Language.be.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.bg.xml b/Translations/Language.bg.xml index 89be4cc6..7011fb4d 100644 --- a/Translations/Language.bg.xml +++ b/Translations/Language.bg.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.ca.xml b/Translations/Language.ca.xml index 73bdfaa8..ab8aab11 100644 --- a/Translations/Language.ca.xml +++ b/Translations/Language.ca.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.co.xml b/Translations/Language.co.xml index ed13e43c..ae670488 100644 --- a/Translations/Language.co.xml +++ b/Translations/Language.co.xml @@ -1677,6 +1677,7 @@ Information about Corsican localization: Parolla d’intesa Attivà l’editore di metoda di stampittera (IME) in u scagnu sicuru AVERTIMENTU : Attivà st’ozzione solu s’è vo scuntrate prublemi quandu si selezziuneghja schedarii chjave o gettoni in u casu d’un scagnu sicuru. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.cs.xml b/Translations/Language.cs.xml index c55cd387..e7e604c9 100644 --- a/Translations/Language.cs.xml +++ b/Translations/Language.cs.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.da.xml b/Translations/Language.da.xml index 126df94a..33b3e857 100644 --- a/Translations/Language.da.xml +++ b/Translations/Language.da.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.de.xml b/Translations/Language.de.xml index 8ad41169..7856e0b3 100644 --- a/Translations/Language.de.xml +++ b/Translations/Language.de.xml @@ -1660,6 +1660,7 @@ Passwort Eingabemethoden-Editor (IME) im Secure Desktop verwenden WARNUNG: Verwenden Sie diese Option nur, wenn Probleme bei der Auswahl von Schlüsseldateien/Tokens unter dem Secure Desktop auftreten. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.el.xml b/Translations/Language.el.xml index 01b31410..2644e95c 100644 --- a/Translations/Language.el.xml +++ b/Translations/Language.el.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.es.xml b/Translations/Language.es.xml index 276662de..b4d90357 100644 --- a/Translations/Language.es.xml +++ b/Translations/Language.es.xml @@ -1657,6 +1657,7 @@ Contraseña Habilitar el editor de métodos de entrada (IME) en el Escritorio seguro ADVERTENCIA: Habilite esta opción SOLO si encuentra problemas al seleccionar archivos clave (Keyfiles) o tokens en el Escritorio seguro. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.et.xml b/Translations/Language.et.xml index f75d08f4..5feb47cb 100644 --- a/Translations/Language.et.xml +++ b/Translations/Language.et.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.eu.xml b/Translations/Language.eu.xml index af42a9d6..a42b7498 100644 --- a/Translations/Language.eu.xml +++ b/Translations/Language.eu.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.fa.xml b/Translations/Language.fa.xml index ddb22d57..3906e271 100644 --- a/Translations/Language.fa.xml +++ b/Translations/Language.fa.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.fi.xml b/Translations/Language.fi.xml index c8846f9a..6973fe23 100644 --- a/Translations/Language.fi.xml +++ b/Translations/Language.fi.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.fr.xml b/Translations/Language.fr.xml index 356a7d11..a77e5850 100644 --- a/Translations/Language.fr.xml +++ b/Translations/Language.fr.xml @@ -1657,6 +1657,7 @@ Mot de passe Activer l'éditeur de méthode de saisie (IME) dans le bureau sécurisé AVERTISSEMENT : Activez cette option uniquement si vous rencontrez des problèmes lors de la sélection de fichiers clés/tokens dans le bureau sécurisé. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.he.xml b/Translations/Language.he.xml index 03801870..4405c54f 100644 --- a/Translations/Language.he.xml +++ b/Translations/Language.he.xml @@ -1658,6 +1658,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.hu.xml b/Translations/Language.hu.xml index c52a2435..1d90c7aa 100644 --- a/Translations/Language.hu.xml +++ b/Translations/Language.hu.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.id.xml b/Translations/Language.id.xml index 4bfc4d62..6678121c 100644 --- a/Translations/Language.id.xml +++ b/Translations/Language.id.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.it.xml b/Translations/Language.it.xml index 062f6419..42ab832f 100644 --- a/Translations/Language.it.xml +++ b/Translations/Language.it.xml @@ -1657,6 +1657,7 @@ Password Abilita l'editor del metodo di input (IME) nel Desktop sicuro ATTENZIONE: Abilita questa opzione SOLO se riscontri problemi durante la selezione di file chiave o token nel Desktop sicuro. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.ja.xml b/Translations/Language.ja.xml index ffa3381c..e3a553fa 100644 --- a/Translations/Language.ja.xml +++ b/Translations/Language.ja.xml @@ -1657,6 +1657,7 @@ パスワード セキュアデスクトップでIMEを有効にする 警告: セキュアデスクトップでキーファイルやトークンを選択する際に問題が発生する場合にのみ、このオプションを有効にしてください。 + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.ka.xml b/Translations/Language.ka.xml index cfcc4420..b6d54c03 100644 --- a/Translations/Language.ka.xml +++ b/Translations/Language.ka.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.ko.xml b/Translations/Language.ko.xml index b46b7ce2..55eb1cf2 100644 --- a/Translations/Language.ko.xml +++ b/Translations/Language.ko.xml @@ -1657,6 +1657,7 @@ 암호 보안 데스크톱에서 입력기(IME) 활성화하기 경고: 보안 데스크톱에서 키 파일/토큰 선택 시 문제가 발생하는 경우에만 이 옵션을 활성화하세요. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.lv.xml b/Translations/Language.lv.xml index aa000ce7..f5518488 100644 --- a/Translations/Language.lv.xml +++ b/Translations/Language.lv.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.my.xml b/Translations/Language.my.xml index 0c4e5c7d..86fe2e95 100644 --- a/Translations/Language.my.xml +++ b/Translations/Language.my.xml @@ -1659,6 +1659,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.nb.xml b/Translations/Language.nb.xml index a193cd34..19589a16 100644 --- a/Translations/Language.nb.xml +++ b/Translations/Language.nb.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.nl.xml b/Translations/Language.nl.xml index b6591264..7599e91e 100644 --- a/Translations/Language.nl.xml +++ b/Translations/Language.nl.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.nn.xml b/Translations/Language.nn.xml index b5c1af13..9441dad9 100644 --- a/Translations/Language.nn.xml +++ b/Translations/Language.nn.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.pl.xml b/Translations/Language.pl.xml index ba9616f4..c42696ca 100644 --- a/Translations/Language.pl.xml +++ b/Translations/Language.pl.xml @@ -1657,6 +1657,7 @@ Hasło Włącz edytor metody wprowadzania (IME) na bezpiecznym pulpicie OSTRZEŻENIE: Włącz tę opcję tylko wtedy, gdy napotykasz problemy przy wybieraniu plików-kluczy/tokenów na bezpiecznym pulpicie. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.pt-br.xml b/Translations/Language.pt-br.xml index e335b739..f30f134d 100644 --- a/Translations/Language.pt-br.xml +++ b/Translations/Language.pt-br.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.ro.xml b/Translations/Language.ro.xml index 075099e6..1e4bb8f2 100644 --- a/Translations/Language.ro.xml +++ b/Translations/Language.ro.xml @@ -1657,6 +1657,7 @@ Parola Activare editor metodă de intrare (IME) în Desktop securizat AVERTIZARE: Activați această opțiune doar dacă aveți probleme în a selecta token-uri/fișiere cheie când folosiți Desktop securizat. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.ru.xml b/Translations/Language.ru.xml index d86dba66..925bcb62 100644 --- a/Translations/Language.ru.xml +++ b/Translations/Language.ru.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.sk.xml b/Translations/Language.sk.xml index f027e342..a08dc5ef 100644 --- a/Translations/Language.sk.xml +++ b/Translations/Language.sk.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.sl.xml b/Translations/Language.sl.xml index d29f4735..de03f212 100644 --- a/Translations/Language.sl.xml +++ b/Translations/Language.sl.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.sv.xml b/Translations/Language.sv.xml index 93691dab..dfb5fd18 100644 --- a/Translations/Language.sv.xml +++ b/Translations/Language.sv.xml @@ -1657,6 +1657,7 @@ Lösenord Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.th.xml b/Translations/Language.th.xml index 42dbf189..5e73158b 100644 --- a/Translations/Language.th.xml +++ b/Translations/Language.th.xml @@ -1658,6 +1658,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.tr.xml b/Translations/Language.tr.xml index 92bc6ea4..ac356a75 100644 --- a/Translations/Language.tr.xml +++ b/Translations/Language.tr.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.uk.xml b/Translations/Language.uk.xml index 3cae3dc9..545f8136 100644 --- a/Translations/Language.uk.xml +++ b/Translations/Language.uk.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.uz.xml b/Translations/Language.uz.xml index 6766bf9f..3b014edf 100644 --- a/Translations/Language.uz.xml +++ b/Translations/Language.uz.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.vi.xml b/Translations/Language.vi.xml index 4bcc0ea9..4990a64d 100644 --- a/Translations/Language.vi.xml +++ b/Translations/Language.vi.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.zh-cn.xml b/Translations/Language.zh-cn.xml index eded32c4..02a3cba4 100644 --- a/Translations/Language.zh-cn.xml +++ b/Translations/Language.zh-cn.xml @@ -1658,6 +1658,7 @@ 密码 在安全桌面中启用输入法编辑器(IME) 警告:仅当您在安全桌面下选择密钥文件/令牌时遇到问题时,才启用此选项。 + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.zh-hk.xml b/Translations/Language.zh-hk.xml index a208330e..52ada92a 100644 --- a/Translations/Language.zh-hk.xml +++ b/Translations/Language.zh-hk.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/Translations/Language.zh-tw.xml b/Translations/Language.zh-tw.xml index 874e4fea..4086fada 100644 --- a/Translations/Language.zh-tw.xml +++ b/Translations/Language.zh-tw.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index b51f1bf1..9349f470 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -5729,6 +5729,11 @@ void handleError (HWND hwndDlg, int code, const char* srcPos) case ERR_CIPHER_INIT_WEAK_KEY: MessageBoxW (hwndDlg, AppendSrcPos (GetString ("ERR_CIPHER_INIT_WEAK_KEY"), srcPos).c_str(), lpszTitle, ICON_HAND); break; + + case ERR_KEY_DERIVATION_FAILED: + MessageBoxW (hwndDlg, AppendSrcPos (GetString ("ERR_KEY_DERIVATION_FAILED"), srcPos).c_str(), lpszTitle, ICON_HAND); + break; + case ERR_VOL_ALREADY_MOUNTED: MessageBoxW (hwndDlg, AppendSrcPos (GetString ("VOL_ALREADY_MOUNTED"), srcPos).c_str(), lpszTitle, ICON_HAND); break; @@ -6512,7 +6517,8 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) case ARGON2: /* test with ARGON2 used as the PRF */ - derive_key_argon2 ((const unsigned char*) "passphrase-1234567890", 21, (const unsigned char*)tmp_salt, 64, iterations, memoryCost, dk, MASTER_KEYDATA_SIZE, NULL); + if (derive_key_argon2 ((const unsigned char*) "passphrase-1234567890", 21, (const unsigned char*)tmp_salt, 64, iterations, memoryCost, dk, MASTER_KEYDATA_SIZE, NULL) != 0) + goto key_derivation_error; break; } #endif @@ -6639,6 +6645,26 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) NormalCursor (); return TRUE; +key_derivation_error: + + if (ci) + crypto_close (ci); + + if (lpTestBuffer) + { + VirtualUnlock (lpTestBuffer, benchmarkBufferSize - (benchmarkBufferSize % 16)); + + _aligned_free(lpTestBuffer); + } + + NormalCursor (); + + EnableWindow (GetDlgItem (hBenchDlg, IDC_PERFORM_BENCHMARK), TRUE); + EnableWindow (GetDlgItem (hBenchDlg, IDCLOSE), TRUE); + + MessageBoxW (hwndDlg, GetString ("ERR_KEY_DERIVATION_FAILED"), lpszTitle, ICON_HAND); + return FALSE; + counter_error: if (ci) diff --git a/src/Common/EncryptionThreadPool.c b/src/Common/EncryptionThreadPool.c index 7b605eaf..9feeda32 100644 --- a/src/Common/EncryptionThreadPool.c +++ b/src/Common/EncryptionThreadPool.c @@ -98,6 +98,7 @@ typedef struct EncryptionThreadPoolWorkItemStruct { TC_EVENT *CompletionEvent; LONG *CompletionFlag; + LONG *DerivationResult; unsigned char *DerivedKey; int IterationCount; int Memorycost; @@ -244,6 +245,9 @@ static TC_THREAD_PROC EncryptionThreadProc (void *threadArg) break; case DeriveKeyWork: + { + int derivationResult = 0; + switch (workItem->KeyDerivation.Pkcs5Prf) { case BLAKE2S: @@ -272,7 +276,7 @@ static TC_THREAD_PROC EncryptionThreadProc (void *threadArg) break; case ARGON2: - derive_key_argon2(workItem->KeyDerivation.Password, workItem->KeyDerivation.PasswordLength, workItem->KeyDerivation.Salt, PKCS5_SALT_SIZE, + derivationResult = 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(), workItem->KeyDerivation.pAbortKeyDerivation); break; @@ -280,6 +284,9 @@ static TC_THREAD_PROC EncryptionThreadProc (void *threadArg) TC_THROW_FATAL_EXCEPTION; } + if (workItem->KeyDerivation.DerivationResult) + InterlockedExchange (workItem->KeyDerivation.DerivationResult, derivationResult); + InterlockedExchange (workItem->KeyDerivation.CompletionFlag, TRUE); TC_SET_EVENT (*workItem->KeyDerivation.CompletionEvent); @@ -289,6 +296,7 @@ static TC_THREAD_PROC EncryptionThreadProc (void *threadArg) SetWorkItemState (workItem, WorkItemFree); TC_SET_EVENT (WorkItemCompletedEvent); continue; + } case ReadVolumeHeaderFinalizationWork: TC_WAIT_EVENT (*(workItem->ReadVolumeHeaderFinalization.NoOutstandingWorkItemEvent)); @@ -536,7 +544,7 @@ void EncryptionThreadPoolStop () } -void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, unsigned char *password, int passwordLength, unsigned char *salt, int iterationCount, int memoryCost, unsigned char *derivedKey, LONG volatile *pAbortKeyDerivation) +void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, unsigned char *password, int passwordLength, unsigned char *salt, int iterationCount, int memoryCost, unsigned char *derivedKey, LONG *derivationResult, LONG volatile *pAbortKeyDerivation) { EncryptionThreadPoolWorkItem *workItem; @@ -557,6 +565,7 @@ void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT workItem->Type = DeriveKeyWork; workItem->KeyDerivation.CompletionEvent = completionEvent; workItem->KeyDerivation.CompletionFlag = completionFlag; + workItem->KeyDerivation.DerivationResult = derivationResult; workItem->KeyDerivation.DerivedKey = derivedKey; workItem->KeyDerivation.IterationCount = iterationCount; workItem->KeyDerivation.Memorycost = memoryCost; diff --git a/src/Common/EncryptionThreadPool.h b/src/Common/EncryptionThreadPool.h index 5063daf2..7a76839e 100644 --- a/src/Common/EncryptionThreadPool.h +++ b/src/Common/EncryptionThreadPool.h @@ -32,7 +32,8 @@ typedef enum size_t GetCpuCount (WORD* pGroupCount); #endif -void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, unsigned char *password, int passwordLength, unsigned char *salt, int iterationCount, int memoryCost, unsigned char *derivedKey, LONG volatile *pAbortKeyDerivation); +/* derivationResult receives 0 on success; PRFs that can fail store their native nonzero result. */ +void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, unsigned char *password, int passwordLength, unsigned char *salt, int iterationCount, int memoryCost, unsigned char *derivedKey, LONG *derivationResult, LONG volatile *pAbortKeyDerivation); void EncryptionThreadPoolBeginReadVolumeHeaderFinalization (TC_EVENT *keyDerivationCompletedEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG* outstandingWorkItemCount, void* keyInfoBuffer, int keyInfoBufferSize, void* keyDerivationWorkItems, int keyDerivationWorkItemsSize); void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, uint8 *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo); BOOL EncryptionThreadPoolStart (size_t encryptionFreeCpuCount); diff --git a/src/Common/Language.xml b/src/Common/Language.xml index da3cf436..cf9d0078 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -1657,6 +1657,7 @@ Password Enable Input Method Editor (IME) in Secure Desktop WARNING: Enable this option only if you are encountering issues when selecting Keyfiles/Tokens under Secure Desktop. + Key derivation failed. This may be caused by insufficient memory or an interrupted operation. diff --git a/src/Common/Tcdefs.h b/src/Common/Tcdefs.h index 45f99ae5..20c94310 100644 --- a/src/Common/Tcdefs.h +++ b/src/Common/Tcdefs.h @@ -456,7 +456,8 @@ enum ERR_RAND_INIT_FAILED = 34, ERR_CAPI_INIT_FAILED = 35, ERR_XTS_MASTERKEY_VULNERABLE = 36, - ERR_SYSENC_XTS_MASTERKEY_VULNERABLE = 37 + ERR_SYSENC_XTS_MASTERKEY_VULNERABLE = 37, + ERR_KEY_DERIVATION_FAILED = 38 }; #endif // #ifndef TCDEFS_H diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c index 8e249e35..97fc4de6 100644 --- a/src/Common/Volumes.c +++ b/src/Common/Volumes.c @@ -161,11 +161,28 @@ UINT64_STRUCT GetHeaderField64 (uint8 *header, int offset) typedef struct { unsigned char DerivedKey[MASTER_KEYDATA_SIZE]; + LONG DerivationResult; BOOL Free; LONG KeyReady; int Pkcs5Prf; } KeyDerivationWorkItem; +#ifndef VC_DCS_DISABLE_ARGON2 +static int MapArgon2ResultToVcError (int result) +{ + if (result == 0) + return ERR_SUCCESS; + + if (result == ARGON2_MEMORY_ALLOCATION_ERROR) + return ERR_OUTOFMEMORY; + + if (result == ARGON2_OPERATION_CANCELLED) + return ERR_USER_ABORT; + + return ERR_KEY_DERIVATION_FAILED; +} +#endif + BOOL ReadVolumeHeaderRecoveryMode = FALSE; @@ -186,6 +203,9 @@ int ReadVolumeHeader (BOOL bBoot, unsigned char *encryptedHeader, Password *pass int iterationsCount = 0; int memoryCost = 0; LONG volatile abortKeyDerivation = 0; +#ifndef VC_DCS_DISABLE_ARGON2 + int lastArgon2DerivationResult = 0; +#endif #if !defined(_UEFI) TC_EVENT *keyDerivationCompletedEvent = NULL; TC_EVENT *noOutstandingWorkItemEvent = NULL; @@ -329,12 +349,13 @@ int ReadVolumeHeader (BOOL bBoot, unsigned char *encryptedHeader, Password *pass { item->Free = FALSE; item->KeyReady = FALSE; + item->DerivationResult = 0; item->Pkcs5Prf = enqPkcs5Prf; iterationsCount = get_pkcs5_iteration_count (enqPkcs5Prf, pim, bBoot, &memoryCost); EncryptionThreadPoolBeginKeyDerivation (keyDerivationCompletedEvent, noOutstandingWorkItemEvent, &item->KeyReady, outstandingWorkItemCount, enqPkcs5Prf, keyInfo->userKey, - keyInfo->keyLength, keyInfo->salt, iterationsCount, memoryCost, item->DerivedKey, &abortKeyDerivation); + keyInfo->keyLength, keyInfo->salt, iterationsCount, memoryCost, item->DerivedKey, &item->DerivationResult, &abortKeyDerivation); ++queuedWorkItems; break; @@ -355,6 +376,18 @@ int ReadVolumeHeader (BOOL bBoot, unsigned char *encryptedHeader, Password *pass item = &keyDerivationWorkItems[i]; if (!item->Free && InterlockedExchangeAdd (&item->KeyReady, 0) == TRUE) { + LONG derivationResult = InterlockedExchangeAdd (&item->DerivationResult, 0); + if (derivationResult != 0) + { +#ifndef VC_DCS_DISABLE_ARGON2 + if (item->Pkcs5Prf == ARGON2) + lastArgon2DerivationResult = (int) derivationResult; +#endif + item->Free = TRUE; + --queuedWorkItems; + continue; + } + pkcs5_prf = item->Pkcs5Prf; iterationsCount = get_pkcs5_iteration_count (pkcs5_prf, pim, bBoot, &memoryCost); keyInfo->noIterations = iterationsCount; @@ -413,8 +446,21 @@ KeyReady: ; #ifndef VC_DCS_DISABLE_ARGON2 case ARGON2: - derive_key_argon2(keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, - PKCS5_SALT_SIZE, keyInfo->noIterations, keyInfo->memoryCost, dk, GetMaxPkcs5OutSize(), &abortKeyDerivation); + { + int derivationResult = derive_key_argon2(keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, + PKCS5_SALT_SIZE, keyInfo->noIterations, keyInfo->memoryCost, dk, GetMaxPkcs5OutSize(), &abortKeyDerivation); + if (derivationResult != 0) + { + if (selected_pkcs5_prf == 0) + { + lastArgon2DerivationResult = derivationResult; + continue; + } + + status = MapArgon2ResultToVcError (derivationResult); + goto err; + } + } break; #endif #endif @@ -632,7 +678,12 @@ KeyReady: ; } } } - status = ERR_PASSWORD_WRONG; +#ifndef VC_DCS_DISABLE_ARGON2 + if (lastArgon2DerivationResult != 0) + status = MapArgon2ResultToVcError (lastArgon2DerivationResult); + else +#endif + status = ERR_PASSWORD_WRONG; err: #if !defined(_UEFI) @@ -1077,8 +1128,16 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, unsigned char *header, #ifndef VC_DCS_DISABLE_ARGON2 case ARGON2: - derive_key_argon2(keyInfo.userKey, keyInfo.keyLength, keyInfo.salt, - PKCS5_SALT_SIZE, keyInfo.noIterations, keyInfo.memoryCost, dk, GetMaxPkcs5OutSize(), NULL); + { + int derivationResult = derive_key_argon2(keyInfo.userKey, keyInfo.keyLength, keyInfo.salt, + PKCS5_SALT_SIZE, keyInfo.noIterations, keyInfo.memoryCost, dk, GetMaxPkcs5OutSize(), NULL); + if (derivationResult != 0) + { + crypto_close (cryptoInfo); + retVal = MapArgon2ResultToVcError (derivationResult); + goto err; + } + } break; #endif #endif @@ -1276,7 +1335,7 @@ err: VirtualUnlock (&dk, sizeof (dk)); #endif // !defined(_UEFI) - return 0; + return retVal; } #if !defined(_UEFI) diff --git a/src/Crypto/Argon2/src/argon2.c b/src/Crypto/Argon2/src/argon2.c index e3b2b177..0db594f9 100644 --- a/src/Crypto/Argon2/src/argon2.c +++ b/src/Crypto/Argon2/src/argon2.c @@ -288,6 +288,8 @@ const char *argon2_error_message(int error_code) { return "Some of encoded parameters are too long or too short"; case ARGON2_VERIFY_MISMATCH: return "The password does not match the supplied hash"; + case ARGON2_OPERATION_CANCELLED: + return "Operation cancelled"; default: return "Unknown error code"; }