1
0
mirror of https://github.com/GOSTSec/gostcoin synced 2025-02-06 20:04:51 +00:00

verify signature in DER format

This commit is contained in:
orignal 2017-03-31 21:34:00 -04:00
parent 80eb335455
commit 0dbd8a24bb

View File

@ -159,12 +159,15 @@ public:
bool Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig) bool Verify(const uint256 &hash, const std::vector<unsigned char>& vchSig)
{ {
// decode from DER
ECDSA_SIG *sig = nullptr;
auto p = &vchSig[0];
d2i_ECDSA_SIG (&sig, &p, vchSig.size());
const EC_POINT * pub = EC_KEY_get0_public_key(pkey); const EC_POINT * pub = EC_KEY_get0_public_key(pkey);
BIGNUM * d = BN_bin2bn (hash.begin (), 32, nullptr); BIGNUM * d = BN_bin2bn (hash.begin (), 32, nullptr);
BIGNUM * r = BN_bin2bn (&vchSig[0], 32, NULL); bool ret = i2p::crypto::GetGOSTR3410Curve (i2p::crypto::eGOSTR3410CryptoProA)->Verify (pub, d, sig->r, sig->s);
BIGNUM * s = BN_bin2bn (&vchSig[32], 32, NULL); BN_free (d);
bool ret = i2p::crypto::GetGOSTR3410Curve (i2p::crypto::eGOSTR3410CryptoProA)->Verify (pub, d, r, s); ECDSA_SIG_free(sig);
BN_free (d); BN_free (r); BN_free (s);
return ret; return ret;
} }