15void initialize_crypter()
17 static const auto testing_setup = MakeNoLogFileContext<const TestingSetup>();
18 g_setup = testing_setup.get();
28 std::vector<unsigned char> cipher_text_ed;
32 if (fuzzed_data_provider.ConsumeBool()) {
33 const std::string random_string = fuzzed_data_provider.ConsumeRandomLengthString(100);
34 SecureString secure_string(random_string.begin(), random_string.end());
36 const unsigned int derivation_method = fuzzed_data_provider.ConsumeBool() ? 0 : fuzzed_data_provider.ConsumeIntegral<
unsigned int>();
39 crypt.SetKeyFromPassphrase(secure_string,
41 fuzzed_data_provider.ConsumeIntegralInRange<
unsigned int>(0, 25000),
45 LIMITED_WHILE(good_data && fuzzed_data_provider.ConsumeBool(), 100)
51 plain_text_ed =
CKeyingMaterial(random_vector.begin(), random_vector.end());
57 (void)crypt.Encrypt(plain_text_ed, cipher_text_ed);
60 (void)crypt.Decrypt(cipher_text_ed, plain_text_ed);
65 (void)
EncryptSecret(master_key, plain_text_ed, iv, cipher_text_ed);
70 (void)
DecryptSecret(master_key, cipher_text_ed, iv, plain_text_ed);
73 std::optional<CPubKey> random_pub_key = ConsumeDeserializable<CPubKey>(fuzzed_data_provider);
74 if (!random_pub_key) {
78 const CPubKey pub_key = *random_pub_key;
82 (void)
DecryptKey(master_key, crypted_secret, pub_key, key);
An encapsulated private key.
An encapsulated public key.
#define LIMITED_WHILE(condition, limit)
Can be used to limit a theoretically unbounded loop.
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
const unsigned int WALLET_CRYPTO_KEY_SIZE
bool DecryptSecret(const CKeyingMaterial &master_key, const std::span< const unsigned char > ciphertext, const uint256 &iv, CKeyingMaterial &plaintext)
FUZZ_TARGET(coin_grinder)
bool DecryptKey(const CKeyingMaterial &master_key, const std::span< const unsigned char > crypted_secret, const CPubKey &pub_key, CKey &key)
const unsigned int WALLET_CRYPTO_SALT_SIZE
bool EncryptSecret(const CKeyingMaterial &vMasterKey, const CKeyingMaterial &vchPlaintext, const uint256 &nIV, std::vector< unsigned char > &vchCiphertext)
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
Testing setup that configures a complete environment.
std::vector< B > ConsumeFixedLengthByteVector(FuzzedDataProvider &fuzzed_data_provider, const size_t length) noexcept
Returns a byte vector of specified size regardless of the number of remaining bytes available from th...
uint256 ConsumeUInt256(FuzzedDataProvider &fuzzed_data_provider) noexcept
size_t CallOneOf(FuzzedDataProvider &fuzzed_data_provider, Callables... callables)
std::vector< B > ConsumeRandomLengthByteVector(FuzzedDataProvider &fuzzed_data_provider, const std::optional< size_t > &max_length=std::nullopt) noexcept