@@ -5,9 +5,9 @@ use bitcoin_encrypted_backup::{
55 Content , Encryption , Version ,
66 ll:: {
77 decode_v1, encode_derivation_paths, encode_encrypted_payload, encode_individual_secrets,
8- encode_v1, increment_offset, nonce, parse_derivation_paths, parse_individual_secrets,
8+ encode_v1, increment_offset, nonce, parse_content_metadata, parse_derivation_paths,
9+ parse_individual_secrets,
910 } ,
10- miniscript:: bitcoin:: bip32:: DerivationPath ,
1111} ;
1212
1313use libfuzzer_sys:: fuzz_target;
@@ -23,7 +23,7 @@ fn content(bytes: &[u8]) -> (usize, Content) {
2323 if bytes. is_empty ( ) {
2424 return ( 1 , Content :: Unknown ) ;
2525 }
26- ( 1 , Content :: from ( bytes [ 0 ] ) )
26+ parse_content_metadata ( bytes ) . unwrap_or ( ( 1 , Content :: Unknown ) )
2727}
2828fn encryption ( bytes : & [ u8 ] ) -> ( usize , Encryption ) {
2929 if bytes. is_empty ( ) {
@@ -52,14 +52,14 @@ fuzz_target!(|bytes: &[u8]| {
5252 } else {
5353 return ;
5454 } ;
55- let ( incr, content ) = content( & bytes[ offset..] ) ;
55+ let ( incr, _content ) = content( & bytes[ offset..] ) ;
5656 offset = if let Ok ( o) = increment_offset( bytes, offset, incr) {
5757 o
5858 } else {
5959 return ;
6060 } ;
6161 let ( incr, encryption) = encryption( & bytes[ offset..] ) ;
62- offset = if let Ok ( o) = increment_offset( bytes, offset, incr) {
62+ let _offset = if let Ok ( o) = increment_offset( bytes, offset, incr) {
6363 o
6464 } else {
6565 return ;
@@ -74,16 +74,7 @@ fuzz_target!(|bytes: &[u8]| {
7474
7575 let payload = encode_encrypted_payload( nonce( ) , "0" . as_bytes( ) ) . unwrap( ) ;
7676
77- let bytes = encode_v1(
78- version. into( ) ,
79- deriv,
80- secrets,
81- content. into( ) ,
82- encryption. into( ) ,
83- payload,
84- ) ;
85-
86- // println!("encoded: {bytes:?}");
77+ let bytes = encode_v1( version. into( ) , deriv, secrets, encryption. into( ) , payload) ;
8778
8879 let _ = decode_v1( & bytes) . unwrap( ) ;
8980} ) ;
0 commit comments