aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/crypter.cpp
diff options
context:
space:
mode:
authorCory Fields <cory-nospam-@coryfields.com>2015-03-20 01:05:47 -0400
committerPieter Wuille <pieter.wuille@gmail.com>2016-05-13 10:23:03 +0200
commit1c391a5866e1342617b51041afebee2215e9a30c (patch)
tree6edb45995b9cbd64d8b275ba200243d7d8ae91c0 /src/wallet/crypter.cpp
parentdaa384120a63542257d4ca73047d775f16fac654 (diff)
downloadbitcoin-1c391a5866e1342617b51041afebee2215e9a30c.tar.xz
crypter: fix the stored initialization vector size
AES IV's are 16bytes, not 32. This was harmless but confusing. Add WALLET_CRYPTO_IV_SIZE to make its usage explicit.
Diffstat (limited to 'src/wallet/crypter.cpp')
-rw-r--r--src/wallet/crypter.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/wallet/crypter.cpp b/src/wallet/crypter.cpp
index 95aa4c2593..8f555579fa 100644
--- a/src/wallet/crypter.cpp
+++ b/src/wallet/crypter.cpp
@@ -37,7 +37,7 @@ bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::v
bool CCrypter::SetKey(const CKeyingMaterial& chNewKey, const std::vector<unsigned char>& chNewIV)
{
- if (chNewKey.size() != WALLET_CRYPTO_KEY_SIZE || chNewIV.size() != WALLET_CRYPTO_KEY_SIZE)
+ if (chNewKey.size() != WALLET_CRYPTO_KEY_SIZE || chNewIV.size() != WALLET_CRYPTO_IV_SIZE)
return false;
memcpy(&chKey[0], &chNewKey[0], sizeof chKey);
@@ -105,8 +105,8 @@ bool CCrypter::Decrypt(const std::vector<unsigned char>& vchCiphertext, CKeyingM
static bool EncryptSecret(const CKeyingMaterial& vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256& nIV, std::vector<unsigned char> &vchCiphertext)
{
CCrypter cKeyCrypter;
- std::vector<unsigned char> chIV(WALLET_CRYPTO_KEY_SIZE);
- memcpy(&chIV[0], &nIV, WALLET_CRYPTO_KEY_SIZE);
+ std::vector<unsigned char> chIV(WALLET_CRYPTO_IV_SIZE);
+ memcpy(&chIV[0], &nIV, WALLET_CRYPTO_IV_SIZE);
if(!cKeyCrypter.SetKey(vMasterKey, chIV))
return false;
return cKeyCrypter.Encrypt(*((const CKeyingMaterial*)&vchPlaintext), vchCiphertext);
@@ -115,8 +115,8 @@ static bool EncryptSecret(const CKeyingMaterial& vMasterKey, const CKeyingMateri
static bool DecryptSecret(const CKeyingMaterial& vMasterKey, const std::vector<unsigned char>& vchCiphertext, const uint256& nIV, CKeyingMaterial& vchPlaintext)
{
CCrypter cKeyCrypter;
- std::vector<unsigned char> chIV(WALLET_CRYPTO_KEY_SIZE);
- memcpy(&chIV[0], &nIV, WALLET_CRYPTO_KEY_SIZE);
+ std::vector<unsigned char> chIV(WALLET_CRYPTO_IV_SIZE);
+ memcpy(&chIV[0], &nIV, WALLET_CRYPTO_IV_SIZE);
if(!cKeyCrypter.SetKey(vMasterKey, chIV))
return false;
return cKeyCrypter.Decrypt(vchCiphertext, *((CKeyingMaterial*)&vchPlaintext));