mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
fix(wallet): truncate mnemonic passphrase instead of crashing
This commit is contained in:
parent
6f639ea5f1
commit
d53e657513
@ -147,11 +147,11 @@ bool CMnemonic::Check(SecureString mnemonic)
|
||||
return fResult;
|
||||
}
|
||||
|
||||
// passphrase must be at most 256 characters or code may crash
|
||||
// passphrase must be at most 256 characters otherwise it would be truncated
|
||||
void CMnemonic::ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet)
|
||||
{
|
||||
SecureString ssSalt = SecureString("mnemonic") + passphrase;
|
||||
SecureVector vchSalt(ssSalt.begin(), ssSalt.end());
|
||||
SecureVector vchSalt(ssSalt.begin(), ssSalt.begin() + strnlen(ssSalt.data(), 256));
|
||||
seedRet.resize(64);
|
||||
PKCS5_PBKDF2_HMAC_SHA512(mnemonic.c_str(), mnemonic.size(), vchSalt.data(), vchSalt.size(), 2048, 64, seedRet.data());
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ public:
|
||||
static SecureString Generate(int strength); // strength in bits
|
||||
static SecureString FromData(const SecureVector& data, int len);
|
||||
static bool Check(SecureString mnemonic);
|
||||
// passphrase must be at most 256 characters or code may crash
|
||||
// passphrase must be at most 256 characters otherwise it would be truncated
|
||||
static void ToSeed(SecureString mnemonic, SecureString passphrase, SecureVector& seedRet);
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user