MCPcopy Create free account
hub / github.com/ElementsProject/elements / Encrypt

Method Encrypt

src/wallet/crypter.cpp:72–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector<unsigned char> &vchCiphertext) const
73{
74 if (!fKeySet)
75 return false;
76
77 // max ciphertext len for a n bytes of plaintext is
78 // n + AES_BLOCKSIZE bytes
79 vchCiphertext.resize(vchPlaintext.size() + AES_BLOCKSIZE);
80
81 AES256CBCEncrypt enc(vchKey.data(), vchIV.data(), true);
82 size_t nLen = enc.Encrypt(vchPlaintext.data(), vchPlaintext.size(), vchCiphertext.data());
83 if(nLen < vchPlaintext.size())
84 return false;
85 vchCiphertext.resize(nLen);
86
87 return true;
88}
89
90bool CCrypter::Decrypt(const std::vector<unsigned char>& vchCiphertext, CKeyingMaterial& vchPlaintext) const
91{

Callers 5

EncryptSecretFunction · 0.45
EncryptWalletMethod · 0.45
TestEncryptSingleMethod · 0.45

Calls 3

resizeMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45

Tested by 1

TestEncryptSingleMethod · 0.36