mirror of
https://github.com/GOSTSec/gostcoin
synced 2025-03-13 05:41:11 +00:00
check both possible public keys
This commit is contained in:
parent
ccfaa09d0a
commit
88823de063
@ -60,8 +60,9 @@ static int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsi
|
|||||||
BIGNUM * d = BN_bin2bn (msg, msglen, nullptr);
|
BIGNUM * d = BN_bin2bn (msg, msglen, nullptr);
|
||||||
const auto& curve = i2p::crypto::GetGOSTR3410Curve (i2p::crypto::eGOSTR3410CryptoProA);
|
const auto& curve = i2p::crypto::GetGOSTR3410Curve (i2p::crypto::eGOSTR3410CryptoProA);
|
||||||
EC_POINT * pub = curve->RecoverPublicKey (d, ecsig->r, ecsig->s, recid % 2);
|
EC_POINT * pub = curve->RecoverPublicKey (d, ecsig->r, ecsig->s, recid % 2);
|
||||||
EC_KEY_set_public_key(eckey, pub);
|
|
||||||
BN_free (d);
|
BN_free (d);
|
||||||
|
if (!pub) return 0;
|
||||||
|
EC_KEY_set_public_key(eckey, pub);
|
||||||
EC_POINT_free (pub);
|
EC_POINT_free (pub);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -179,7 +180,7 @@ public:
|
|||||||
if (nBitsR <= 256 && nBitsS <= 256) {
|
if (nBitsR <= 256 && nBitsS <= 256) {
|
||||||
CPubKey pubkey;
|
CPubKey pubkey;
|
||||||
GetPubKey(pubkey, true);
|
GetPubKey(pubkey, true);
|
||||||
for (int i=0; i<1; i++) {
|
for (int i=0; i<2; i++) {
|
||||||
CECKey keyRec;
|
CECKey keyRec;
|
||||||
if (ECDSA_SIG_recover_key_GFp(keyRec.pkey, sig, (unsigned char*)&hash, sizeof(hash), i, 1) == 1) {
|
if (ECDSA_SIG_recover_key_GFp(keyRec.pkey, sig, (unsigned char*)&hash, sizeof(hash), i, 1) == 1) {
|
||||||
CPubKey pubkeyRec;
|
CPubKey pubkeyRec;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user