@@ -20,6 +20,7 @@ void initialize_crypter()
20
20
21
21
FUZZ_TARGET (crypter, .init = initialize_crypter)
22
22
{
23
+ SeedRandomStateForTest (SeedRand::ZEROS);
23
24
FuzzedDataProvider fuzzed_data_provider (buffer.data (), buffer.size ());
24
25
bool good_data{true };
25
26
@@ -42,6 +43,11 @@ FUZZ_TARGET(crypter, .init = initialize_crypter)
42
43
/* derivation_method=*/ derivation_method);
43
44
}
44
45
46
+ CKey random_ckey;
47
+ random_ckey.Set (random_key.begin (), random_key.end (), /* fCompressedIn=*/ fuzzed_data_provider.ConsumeBool ());
48
+ if (!random_ckey.IsValid ()) return ;
49
+ CPubKey pubkey{random_ckey.GetPubKey ()};
50
+
45
51
LIMITED_WHILE (good_data && fuzzed_data_provider.ConsumeBool (), 100 )
46
52
{
47
53
CallOneOf (
@@ -60,26 +66,21 @@ FUZZ_TARGET(crypter, .init = initialize_crypter)
60
66
(void )crypt.Decrypt (cipher_text_ed, plain_text_ed);
61
67
},
62
68
[&] {
63
- const CKeyingMaterial master_key (random_key.begin (), random_key.end ());
64
- const uint256 iv = ConsumeUInt256 (fuzzed_data_provider);
65
- (void )EncryptSecret (master_key, plain_text_ed, iv, cipher_text_ed);
69
+ const CKeyingMaterial master_key (random_key.begin (), random_key.end ());;
70
+ (void )EncryptSecret (master_key, plain_text_ed, pubkey.GetHash (), cipher_text_ed);
66
71
},
67
72
[&] {
68
- const CKeyingMaterial master_key (random_key.begin (), random_key.end ());
69
- const uint256 iv = ConsumeUInt256 (fuzzed_data_provider);
70
- (void )DecryptSecret (master_key, cipher_text_ed, iv, plain_text_ed);
71
- },
72
- [&] {
73
- std::optional<CPubKey> random_pub_key = ConsumeDeserializable<CPubKey>(fuzzed_data_provider);
73
+ std::optional<CPubKey> random_pub_key{ConsumeDeserializable<CPubKey>(fuzzed_data_provider)};
74
74
if (!random_pub_key) {
75
75
good_data = false ;
76
76
return ;
77
77
}
78
- const CPubKey pub_key = *random_pub_key;
78
+ pubkey = *random_pub_key;
79
+ },
80
+ [&] {
79
81
const CKeyingMaterial master_key (random_key.begin (), random_key.end ());
80
- const std::vector<unsigned char > crypted_secret = ConsumeRandomLengthByteVector (fuzzed_data_provider, 64 );
81
82
CKey key;
82
- (void )DecryptKey (master_key, crypted_secret, pub_key , key);
83
+ (void )DecryptKey (master_key, cipher_text_ed, pubkey , key);
83
84
});
84
85
}
85
86
}
0 commit comments