@@ -327,7 +327,7 @@ mod fuzz_dummy {
327
327
assert ! ( !cx. is_null( ) && ( * cx) . 0 as u32 & !( SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN ) == 0 ) ;
328
328
match in_len {
329
329
33 => {
330
- if * input != 2 && * input != 3 {
330
+ if ( * input. offset ( 1 ) > 0x7f && * input != 2 ) || ( * input . offset ( 1 ) <= 0x7f && * input != 3 ) {
331
331
0
332
332
} else {
333
333
ptr:: copy ( input. offset ( 1 ) , ( * pk) . 0 [ 0 ..32 ] . as_mut_ptr ( ) , 32 ) ;
@@ -642,8 +642,17 @@ mod fuzz_dummy {
642
642
assert ! ( !cx. is_null( ) && ( * cx) . 0 as u32 & !( SECP256K1_START_NONE | SECP256K1_START_VERIFY | SECP256K1_START_SIGN ) == 0 ) ;
643
643
assert ! ( ( * cx) . 0 as u32 & SECP256K1_START_SIGN == SECP256K1_START_SIGN ) ;
644
644
if secp256k1_ec_seckey_verify ( cx, scalar) != 1 { return 0 ; }
645
- ( * out) . 0 [ 0 ..16 ] . copy_from_slice ( & ( * point) . 0 [ 0 ..16 ] ) ;
646
- ptr:: copy ( scalar, ( * out) . 0 [ 16 ..32 ] . as_mut_ptr ( ) , 16 ) ;
645
+
646
+ let mut scalar_prefix = [ 0 ; 16 ] ;
647
+ ptr:: copy ( scalar, scalar_prefix[ ..] . as_mut_ptr ( ) , 16 ) ;
648
+
649
+ if ( * point) . 0 [ 0 ..16 ] > scalar_prefix[ 0 ..16 ] {
650
+ ( * out) . 0 [ 0 ..16 ] . copy_from_slice ( & ( * point) . 0 [ 0 ..16 ] ) ;
651
+ ptr:: copy ( scalar, ( * out) . 0 [ 16 ..32 ] . as_mut_ptr ( ) , 16 ) ;
652
+ } else {
653
+ ptr:: copy ( scalar, ( * out) . 0 [ 0 ..16 ] . as_mut_ptr ( ) , 16 ) ;
654
+ ( * out) . 0 [ 16 ..32 ] . copy_from_slice ( & ( * point) . 0 [ 0 ..16 ] ) ;
655
+ }
647
656
( * out) . 0 [ 16 ] = 0x00 ; // result should always be a valid secret key
648
657
1
649
658
}
0 commit comments