diff options
| author | Léo Lam <leo@innovatetechnologi.es> | 2018-05-20 23:11:49 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-05-20 23:11:49 +0200 |
| commit | 3d8e63fffd129ae2a40983d3ac82663698329e37 (patch) | |
| tree | 7c5b6df0d8672b5fc2f4b3366f1621425e83a6bd /Source/Core/Common/Crypto/ec.cpp | |
| parent | 79edd57b96efa7a246671646bcf2d9c41e057d7c (diff) | |
| parent | 4b0f8d9f853499c6d7604168d02baa7205dda460 (diff) | |
Merge pull request #6914 from leoetlino/verifysign
ES: Implement VerifySign (last remaining unimplemented, actually used ioctlv)
Diffstat (limited to 'Source/Core/Common/Crypto/ec.cpp')
| -rw-r--r-- | Source/Core/Common/Crypto/ec.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/Source/Core/Common/Crypto/ec.cpp b/Source/Core/Common/Crypto/ec.cpp index 9906ccd5e9..b9a0ca6491 100644 --- a/Source/Core/Common/Crypto/ec.cpp +++ b/Source/Core/Common/Crypto/ec.cpp @@ -278,8 +278,10 @@ std::array<u8, 60> Sign(const u8* key, const u8* hash) return signature; } -UNUSED static int check_ecdsa(u8* Q, u8* R, u8* S, const u8* hash) +bool VerifySignature(const u8* public_key, const u8* signature, const u8* hash) { + const u8* R = signature; + const u8* S = signature + 30; u8 Sinv[30]; bn_inv(Sinv, S, ec_N, 30); @@ -290,7 +292,7 @@ UNUSED static int check_ecdsa(u8* Q, u8* R, u8* S, const u8* hash) bn_mul(w1, e, Sinv, ec_N, 30); bn_mul(w2, R, Sinv, ec_N, 30); - Point r1 = w1 * ec_G + w2 * Point{Q}; + Point r1 = w1 * ec_G + w2 * Point{public_key}; auto& rx = r1.X().data; if (bn_compare(rx.data(), ec_N, 30) >= 0) bn_sub_modulus(rx.data(), ec_N, 30); |
