MCPcopy Create free account
hub / github.com/LUX-Core/lux / Decrypt

Method Decrypt

src/crypter.cpp:75–98  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75bool CCrypter::Decrypt(const std::vector<unsigned char>& vchCiphertext, CKeyingMaterial& vchPlaintext)
76{
77 if (!fKeySet)
78 return false;
79
80 // plaintext will always be equal to or lesser than length of ciphertext
81 int nLen = vchCiphertext.size();
82 int nPLen = nLen, nFLen = 0;
83
84 vchPlaintext = CKeyingMaterial(nPLen);
85
86 bool fOk = true;
87
88 EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new();
89 if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV) != 0;
90 if (fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen) != 0;
91 if (fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0]) + nPLen, &nFLen) != 0;
92 EVP_CIPHER_CTX_free(ctx);
93
94 if (!fOk) return false;
95
96 vchPlaintext.resize(nPLen + nFLen);
97 return true;
98}
99
100
101bool EncryptSecret(const CKeyingMaterial& vMasterKey, const CKeyingMaterial& vchPlaintext, const uint256& nIV, std::vector<unsigned char>& vchCiphertext)

Callers 3

DecryptSecretFunction · 0.45
UnlockMethod · 0.45

Calls 2

sizeMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected