Skip to content

Commit

Permalink
fixing unititialized BIGNUMs
Browse files Browse the repository at this point in the history
  • Loading branch information
StealthSend authored and StealthSend committed Oct 20, 2018
1 parent 85eafd6 commit 4eb5c16
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,12 @@ bool CKey::Sign(uint256 hash, std::vector<unsigned char>& vchSig)
if (BN_cmp(sig_s, halforder) > 0)
{
BIGNUM *sig_r_new, *sig_s_new;
sig_r_new = BN_new();
sig_s_new = BN_new();
// enforce low S values, by negating the value (modulo the order) if above order/2.
BN_sub(sig_s_new, order, sig_s);
// no need to free sig_*_new according to OpenSSL docs
// https://www.openssl.org/docs/man1.1.0/crypto/ECDSA_SIG_set0.html
BN_copy(sig_r_new, sig_r);
ECDSA_SIG_set0(sig, sig_r_new, sig_s_new);
}
Expand Down

0 comments on commit 4eb5c16

Please sign in to comment.