12 template <
typename Out>
13 static bool EncryptBlob(
const void* in,
size_t inSize, Out& out,
const void* symKey,
const void* iv)
17 AES256CBCEncrypt enc((
const unsigned char*)symKey, (
const unsigned char*)iv,
false);
18 int w = enc.Encrypt((
const unsigned char*)in, (
int)inSize, (
unsigned char*)out.data());
19 return w == (int)inSize;
22 template <
typename Out>
23 static bool DecryptBlob(
const void* in,
size_t inSize, Out& out,
const void* symKey,
const void* iv)
27 AES256CBCDecrypt enc((
const unsigned char*)symKey, (
const unsigned char*)iv,
false);
28 int w = enc.Decrypt((
const unsigned char*)in, (
int)inSize, (
unsigned char*)out.data());
29 return w == (int)inSize;
47 return EncryptBlob(plainTextData, dataSize,
data, symKey.data(),
iv);
60 return DecryptBlob(
data.data(),
data.size(), decryptedDataRet, symKey.
data(),
iv);
66 if (recipients.size() != _blobs.size()) {
72 for (
size_t i = 0; i < _blobs.size(); i++) {
73 if (!
Encrypt(i, recipients[i], _blobs[i])) {
89 for (
size_t i = 0; i < count; i++) {
96 assert(idx <
blobs.size());
106 return EncryptBlob(blob.data(), blob.size(),
blobs[idx], symKey.data(),
ivVector[idx].begin());
111 if (idx >=
blobs.size()) {
124 for (
size_t i = 0; i < idx; i++) {
128 return DecryptBlob(
blobs[idx].data(),
blobs[idx].size(), blobRet, symKey.data(), iv.
begin());
std::vector< unsigned char > data
CBLSPublicKey ephemeralPubKey
bool Decrypt(const CBLSSecretKey &secretKey, CDataStream &decryptedDataRet) const
bool Encrypt(const CBLSPublicKey &peerPubKey, const void *data, size_t dataSize)
void InitEncrypt(size_t count)
CBLSSecretKey ephemeralSecretKey
bool Encrypt(const std::vector< CBLSPublicKey > &recipients, const BlobVector &_blobs)
CBLSPublicKey ephemeralPubKey
bool Decrypt(size_t idx, const CBLSSecretKey &sk, Blob &blobRet) const
std::vector< uint256 > ivVector
std::vector< Blob > BlobVector
std::vector< unsigned char > Blob
bool DHKeyExchange(const CBLSSecretKey &sk, const CBLSPublicKey &pk)
CBLSPublicKey GetPublicKey() const
std::vector< uint8_t > ToByteVector() const
unsigned int size() const
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
void GetStrongRandBytes(unsigned char *buf, int num) noexcept
Gather entropy from various sources, feed it into the internal PRNG, and generate random data using i...