Mercurial > hg > bitcoin
changeset 2878:5d248ed5c9f4 draft
Merge branch '0.4.x' into 0.5.0.x
author | Luke Dashjr <luke-jr+git@utopios.org> |
---|---|
date | Thu, 05 Apr 2012 18:20:18 -0400 |
parents | 46c699d74456 (current diff) 843b53c1c3d1 (diff) |
children | 44fc2f0d171c 03c9dac98a44 |
files | src/crypter.cpp src/keystore.cpp |
diffstat | 2 files changed, 18 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/crypter.cpp +++ b/src/crypter.cpp @@ -73,13 +73,15 @@ EVP_CIPHER_CTX ctx; - EVP_CIPHER_CTX_init(&ctx); - EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); + bool fOk = true; - EVP_EncryptUpdate(&ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen); - EVP_EncryptFinal_ex(&ctx, (&vchCiphertext[0])+nCLen, &nFLen); + EVP_CIPHER_CTX_init(&ctx); + if (fOk) fOk = EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); + if (fOk) fOk = EVP_EncryptUpdate(&ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen); + if (fOk) fOk = EVP_EncryptFinal_ex(&ctx, (&vchCiphertext[0])+nCLen, &nFLen); + EVP_CIPHER_CTX_cleanup(&ctx); - EVP_CIPHER_CTX_cleanup(&ctx); + if (!fOk) return false; vchCiphertext.resize(nCLen + nFLen); return true; @@ -98,13 +100,15 @@ EVP_CIPHER_CTX ctx; - EVP_CIPHER_CTX_init(&ctx); - EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); + bool fOk = true; - EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen); - EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0])+nPLen, &nFLen); + EVP_CIPHER_CTX_init(&ctx); + if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); + if (fOk) fOk = EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen); + if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0])+nPLen, &nFLen); + EVP_CIPHER_CTX_cleanup(&ctx); - EVP_CIPHER_CTX_cleanup(&ctx); + if (!fOk) return false; vchPlaintext.resize(nPLen + nFLen); return true;
--- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -71,6 +71,8 @@ CSecret vchSecret; if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, Hash(vchPubKey.begin(), vchPubKey.end()), vchSecret)) return false; + if (vchSecret.size() != 32) + return false; CKey key; key.SetSecret(vchSecret); if (key.GetPubKey() == vchPubKey) @@ -131,6 +133,8 @@ CSecret vchSecret; if (!DecryptSecret(vMasterKey, vchCryptedSecret, Hash(vchPubKey.begin(), vchPubKey.end()), vchSecret)) return false; + if (vchSecret.size() != 32) + return false; keyOut.SetSecret(vchSecret); return true; }