Browse Source

verify signature in DER format

pull/5/head
orignal 7 years ago
parent
commit
0dbd8a24bb
  1. 11
      src/key.cpp

11
src/key.cpp

@ -159,12 +159,15 @@ public: @@ -159,12 +159,15 @@ public:
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);
BIGNUM * d = BN_bin2bn (hash.begin (), 32, nullptr);
BIGNUM * r = BN_bin2bn (&vchSig[0], 32, NULL);
BIGNUM * s = BN_bin2bn (&vchSig[32], 32, NULL);
bool ret = i2p::crypto::GetGOSTR3410Curve (i2p::crypto::eGOSTR3410CryptoProA)->Verify (pub, d, r, s);
BN_free (d); BN_free (r); BN_free (s);
bool ret = i2p::crypto::GetGOSTR3410Curve (i2p::crypto::eGOSTR3410CryptoProA)->Verify (pub, d, sig->r, sig->s);
BN_free (d);
ECDSA_SIG_free(sig);
return ret;
}

Loading…
Cancel
Save