mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-29 20:47:31 -03:00
Make signing fail if a too small buffer is passed.
Bug discovered by Sergio Demian Lerner.
This commit is contained in:
parent
6d1660663f
commit
603c33bc80
2 changed files with 3 additions and 1 deletions
|
@ -88,7 +88,7 @@ int secp256k1_ecdsa_sign(const unsigned char *msg32, unsigned char *signature, i
|
||||||
ret = secp256k1_ecdsa_sig_sign(&sig, &sec, &msg, &non, NULL);
|
ret = secp256k1_ecdsa_sig_sign(&sig, &sec, &msg, &non, NULL);
|
||||||
}
|
}
|
||||||
if (ret) {
|
if (ret) {
|
||||||
secp256k1_ecdsa_sig_serialize(signature, signaturelen, &sig);
|
ret = secp256k1_ecdsa_sig_serialize(signature, signaturelen, &sig);
|
||||||
}
|
}
|
||||||
secp256k1_scalar_clear(&msg);
|
secp256k1_scalar_clear(&msg);
|
||||||
secp256k1_scalar_clear(&non);
|
secp256k1_scalar_clear(&non);
|
||||||
|
|
|
@ -1298,6 +1298,8 @@ void test_ecdsa_edge_cases(void) {
|
||||||
msg[31] = 0xaa;
|
msg[31] = 0xaa;
|
||||||
siglen = 72;
|
siglen = 72;
|
||||||
CHECK(secp256k1_ecdsa_sign(msg, sig, &siglen, key, nonce) == 1);
|
CHECK(secp256k1_ecdsa_sign(msg, sig, &siglen, key, nonce) == 1);
|
||||||
|
siglen = 10;
|
||||||
|
CHECK(secp256k1_ecdsa_sign(msg, sig, &siglen, key, nonce) != 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Privkey export where pubkey is the point at infinity. */
|
/* Privkey export where pubkey is the point at infinity. */
|
||||||
|
|
Loading…
Add table
Reference in a new issue