Fixed secp256k1_ecdh fuzztarget

This commit is contained in:
Elichai Turkel 2019-11-10 12:05:52 +02:00
parent f80428258c
commit ca8ea92418
No known key found for this signature in database
GPG Key ID: 9383CDE9E8E66A7F
1 changed files with 7 additions and 7 deletions

View File

@ -440,7 +440,7 @@ mod fuzz_dummy {
use self::std::{ptr, mem};
use self::std::boxed::Box;
use types::*;
use ::{Signature, Context, NonceFn, EcdhHashFn, PublicKey, SharedSecret,
use ::{Signature, Context, NonceFn, EcdhHashFn, PublicKey,
SECP256K1_START_NONE, SECP256K1_START_VERIFY, SECP256K1_START_SIGN,
SECP256K1_SER_COMPRESSED, SECP256K1_SER_UNCOMPRESSED};
@ -769,7 +769,7 @@ mod fuzz_dummy {
/// Sets out to point[0..16]||scalar[0..16]
pub unsafe fn secp256k1_ecdh(
cx: *const Context,
out: *mut SharedSecret,
out: *mut c_uchar,
point: *const PublicKey,
scalar: *const c_uchar,
_hashfp: EcdhHashFn,
@ -782,13 +782,13 @@ mod fuzz_dummy {
ptr::copy(scalar, scalar_prefix[..].as_mut_ptr(), 16);
if (*point).0[0..16] > scalar_prefix[0..16] {
(*out).0[0..16].copy_from_slice(&(*point).0[0..16]);
ptr::copy(scalar, (*out).0[16..32].as_mut_ptr(), 16);
ptr::copy((*point).as_ptr(), out, 16);
ptr::copy(scalar, out.offset(16), 16);
} else {
ptr::copy(scalar, (*out).0[0..16].as_mut_ptr(), 16);
(*out).0[16..32].copy_from_slice(&(*point).0[0..16]);
ptr::copy(scalar, out, 16);
ptr::copy((*point).as_ptr(), out.offset(16), 16);
}
(*out).0[16] = 0x00; // result should always be a valid secret key
(*out.offset(16)) = 0x00; // result should always be a valid secret key
1
}
}