@@ -17,40 +17,59 @@ fuzz_target!(|data: &[u8]| {
1717 let key_data = & data[ 1 ..129 ] ;
1818
1919 // Try to generate a keypair
20- let keypair = match generate_keypair( algorithm, key_data) {
21- Ok ( kp) => kp,
22- Err ( _) => return , // Skip if key generation fails
23- } ;
20+ let keypair_result = generate_keypair( algorithm, key_data) ;
21+ if let Err ( err) = & keypair_result {
22+ panic!(
23+ "Key generation failed for algorithm: {}, error: {:?}" ,
24+ algorithm. debug_name( ) ,
25+ err
26+ ) ;
27+ }
28+ let keypair = keypair_result. unwrap( ) ;
2429
2530 // Use remaining bytes as message to sign
2631 let message = & data[ 129 ..] ;
2732
2833 // Try to sign the message
29- let signature = match sign( & keypair. secret_key, message) {
30- Ok ( sig) => sig,
31- Err ( _) => return , // Skip if signing fails
32- } ;
34+ let signature_result = sign( & keypair. secret_key, message) ;
35+ if let Err ( err) = & signature_result {
36+ panic!(
37+ "Signing failed for algorithm: {}, error: {:?}" ,
38+ algorithm. debug_name( ) ,
39+ err
40+ ) ;
41+ }
42+ let signature = signature_result. unwrap( ) ;
3343
3444 // Try to verify the signature with the correct public key
3545 let verify_result = verify( & keypair. public_key, message, & signature) ;
36-
37- assert!(
38- verify_result. is_ok( ) ,
39- "Verification failed for a signature generated with the corresponding private key! Algorithm: {algorithm:?}" ,
40- ) ;
46+ if let Err ( err) = & verify_result {
47+ panic!( "Verification failed for a signature generated with the corresponding private key! Algorithm: {}, error: {:?}" ,
48+ algorithm. debug_name( ) , err) ;
49+ }
4150
4251 // Also try some invalid cases (if we have a valid signature)
4352 if message. len( ) > 1 {
4453 // Try with modified message
4554 let mut modified_msg = message. to_vec( ) ;
4655 modified_msg[ 0 ] ^= 0xFF ; // Flip bits in first byte
47- let _verify_result_bad_msg = verify( & keypair. public_key, & modified_msg, & signature) ;
56+ let verify_result_bad_msg = verify( & keypair. public_key, & modified_msg, & signature) ;
57+ assert!(
58+ verify_result_bad_msg. is_err( ) ,
59+ "Verification should fail with modified message! Algorithm: {}" ,
60+ algorithm. debug_name( )
61+ ) ;
4862 }
4963
5064 if signature. bytes. len( ) > 1 {
5165 // Try with modified signature
5266 let mut modified_sig = signature. clone( ) ;
5367 modified_sig. bytes[ 0 ] ^= 0xFF ; // Flip bits in first byte
54- let _verify_result_bad_sig = verify( & keypair. public_key, message, & modified_sig) ;
68+ let verify_result_bad_sig = verify( & keypair. public_key, message, & modified_sig) ;
69+ assert!(
70+ verify_result_bad_sig. is_err( ) ,
71+ "Verification should fail with modified signature! Algorithm: {}" ,
72+ algorithm. debug_name( )
73+ ) ;
5574 }
5675} ) ;
0 commit comments