mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Make secp256k1_ec_pubkey_create reject oversized secrets.
This commit is contained in:
parent
3b7ea633fb
commit
354ffa33e6
1 changed files with 6 additions and 1 deletions
|
@ -220,12 +220,17 @@ int secp256k1_ec_pubkey_create(unsigned char *pubkey, int *pubkeylen, const unsi
|
|||
secp256k1_gej_t pj;
|
||||
secp256k1_ge_t p;
|
||||
secp256k1_scalar_t sec;
|
||||
int overflow;
|
||||
DEBUG_CHECK(secp256k1_ecmult_gen_consts != NULL);
|
||||
DEBUG_CHECK(pubkey != NULL);
|
||||
DEBUG_CHECK(pubkeylen != NULL);
|
||||
DEBUG_CHECK(seckey != NULL);
|
||||
|
||||
secp256k1_scalar_set_b32(&sec, seckey, NULL);
|
||||
secp256k1_scalar_set_b32(&sec, seckey, &overflow);
|
||||
if (overflow) {
|
||||
*pubkeylen = 0;
|
||||
return 0;
|
||||
}
|
||||
secp256k1_ecmult_gen(&pj, &sec);
|
||||
secp256k1_scalar_clear(&sec);
|
||||
secp256k1_ge_set_gej(&p, &pj);
|
||||
|
|
Loading…
Add table
Reference in a new issue