-
Notifications
You must be signed in to change notification settings - Fork 386
Mitigate bruteforce attempts #708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,12 +40,19 @@ | |
| *****************************************************************************/ | ||
|
|
||
| #include "config.h" | ||
| #include "Configuration.h" | ||
| #include "SecureDataManager.h" | ||
| #include "CryptoFactory.h" | ||
| #include "AESKey.h" | ||
| #include "SymmetricAlgorithm.h" | ||
| #include "RFC4880.h" | ||
|
|
||
| #ifdef _WIN32 | ||
| #include <Windows.h> | ||
| #else | ||
| #include <unistd.h> | ||
| #endif | ||
|
|
||
| // Constructors | ||
|
|
||
| // Initialise the object; called by all constructors | ||
|
|
@@ -263,6 +270,7 @@ bool SecureDataManager::login(const ByteString& passphrase, const ByteString& en | |
|
|
||
| if (!RFC4880::PBEDeriveKey(passphrase, salt, &pbeKey)) | ||
| { | ||
| sleep(Configuration::i()->getInt("login.fail_delay", 0)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On Windows I would expect this to be a capitalized (I guess a utility function elsewhere would help.) |
||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -275,6 +283,7 @@ bool SecureDataManager::login(const ByteString& passphrase, const ByteString& en | |
| !aes->decryptUpdate(encryptedKeyData, decryptedKeyData) || | ||
| !aes->decryptFinal(finalBlock)) | ||
| { | ||
| sleep(Configuration::i()->getInt("login.fail_delay", 0)); | ||
| delete pbeKey; | ||
|
|
||
| return false; | ||
|
|
@@ -288,6 +297,7 @@ bool SecureDataManager::login(const ByteString& passphrase, const ByteString& en | |
| if (decryptedKeyData.substr(0, 3) != magic) | ||
| { | ||
| // The passphrase was incorrect | ||
| sleep(Configuration::i()->getInt("login.fail_delay", 0)); | ||
| DEBUG_MSG("Incorrect passphrase supplied"); | ||
|
|
||
| return false; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd recommend to add a default in
softhsm2.conf.inandsofthsm2.conf.5.into document this new feature as well, e.g. somewhere here:SoftHSMv2/src/lib/common/softhsm2.conf.in
Line 17 in a8cabf5
SoftHSMv2/src/lib/common/softhsm2.conf.5.in
Line 95 in a8cabf5
Also to indicate which units (e.g. seconds or milliseconds) these are supposed to be set to.