@@ -27,36 +27,36 @@ FUZZ_TARGET(crypter, .init = initialize_crypter)
27
27
// These values are regularly updated within `CallOneOf`
28
28
std::vector<unsigned char > cipher_text_ed;
29
29
CKeyingMaterial plain_text_ed;
30
- const std::vector<unsigned char > random_key = ConsumeRandomLengthByteVector (fuzzed_data_provider);
30
+ const std::vector<unsigned char > random_key = ConsumeFixedLengthByteVector (fuzzed_data_provider, WALLET_CRYPTO_KEY_SIZE );
31
31
32
32
LIMITED_WHILE (good_data && fuzzed_data_provider.ConsumeBool (), 10000 )
33
33
{
34
34
CallOneOf (
35
35
fuzzed_data_provider,
36
36
[&] {
37
- const std::string random_string = fuzzed_data_provider.ConsumeRandomLengthString ();
37
+ const std::string random_string = fuzzed_data_provider.ConsumeRandomLengthString (100 );
38
38
SecureString secure_string (random_string.begin (), random_string.end ());
39
39
40
40
const unsigned int derivation_method = fuzzed_data_provider.ConsumeBool () ? 0 : fuzzed_data_provider.ConsumeIntegral <unsigned int >();
41
41
42
42
// Limiting the value of nRounds since it is otherwise uselessly expensive and causes a timeout when fuzzing.
43
43
crypt.SetKeyFromPassphrase (/* strKeyData=*/ secure_string,
44
- /* chSalt=*/ ConsumeRandomLengthByteVector (fuzzed_data_provider),
44
+ /* chSalt=*/ ConsumeFixedLengthByteVector (fuzzed_data_provider, WALLET_CRYPTO_SALT_SIZE ),
45
45
/* nRounds=*/ fuzzed_data_provider.ConsumeIntegralInRange <unsigned int >(0 , 25000 ),
46
46
/* nDerivationMethod=*/ derivation_method);
47
47
},
48
48
[&] {
49
- const std::vector<unsigned char > random_vector = ConsumeFixedLengthByteVector (fuzzed_data_provider, 32 );
49
+ const std::vector<unsigned char > random_vector = ConsumeFixedLengthByteVector (fuzzed_data_provider, WALLET_CRYPTO_KEY_SIZE );
50
50
const CKeyingMaterial new_key (random_vector.begin (), random_vector.end ());
51
- const std::vector<unsigned char >& new_IV = ConsumeFixedLengthByteVector (fuzzed_data_provider, 16 );
51
+ const std::vector<unsigned char >& new_IV = ConsumeFixedLengthByteVector (fuzzed_data_provider, WALLET_CRYPTO_IV_SIZE );
52
52
crypt.SetKey (new_key, new_IV);
53
53
},
54
54
[&] {
55
- const std::vector<unsigned char > random_vector = ConsumeRandomLengthByteVector (fuzzed_data_provider);
55
+ const std::vector<unsigned char > random_vector = ConsumeFixedLengthByteVector (fuzzed_data_provider, WALLET_CRYPTO_KEY_SIZE );
56
56
plain_text_ed = CKeyingMaterial (random_vector.begin (), random_vector.end ());
57
57
},
58
58
[&] {
59
- cipher_text_ed = ConsumeRandomLengthByteVector (fuzzed_data_provider);
59
+ cipher_text_ed = ConsumeRandomLengthByteVector (fuzzed_data_provider, 64 );
60
60
},
61
61
[&] {
62
62
(void )crypt.Encrypt (plain_text_ed, cipher_text_ed);
@@ -82,7 +82,7 @@ FUZZ_TARGET(crypter, .init = initialize_crypter)
82
82
}
83
83
const CPubKey pub_key = *random_pub_key;
84
84
const CKeyingMaterial master_key (random_key.begin (), random_key.end ());
85
- const std::vector<unsigned char > crypted_secret = ConsumeRandomLengthByteVector (fuzzed_data_provider);
85
+ const std::vector<unsigned char > crypted_secret = ConsumeRandomLengthByteVector (fuzzed_data_provider, 64 );
86
86
CKey key;
87
87
DecryptKey (master_key, crypted_secret, pub_key, key);
88
88
});
0 commit comments