Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wallet/crypter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
if (vchCryptedBip39Words.size() || vchCryptedBip39Passphrase.size() || vchCryptedBip39VchSeed.size()) {
if (!DecryptBip39(vMasterKeyIn)) {
LogPrintf("Failed to decrypt bip 39 data");
assert(false);
return false;
}
}
if (keyPass && keyFail)
Expand Down
15 changes: 15 additions & 0 deletions src/wallet/test/crypto_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@

BOOST_FIXTURE_TEST_SUITE(wallet_crypto, BasicTestingSetup)

class TestCryptoKeyStore : public CCryptoKeyStore
{
public:
using CCryptoKeyStore::Unlock;
};

class TestCrypter
{
public:
Expand Down Expand Up @@ -132,4 +138,13 @@ BOOST_FIXTURE_TEST_SUITE(wallet_crypto, BasicTestingSetup)
}
}

BOOST_AUTO_TEST_CASE(unlock_rejects_invalid_encrypted_bip39_data)
{
TestCryptoKeyStore keystore;
keystore.AddCryptedWords(uint256(), std::vector<unsigned char>(1, 0));

CKeyingMaterial masterKey(WALLET_CRYPTO_KEY_SIZE, 0);
BOOST_CHECK(!keystore.Unlock(masterKey));
}

BOOST_AUTO_TEST_SUITE_END()