mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
IOSC: Implement VerifyPublicKeySign for ECC
This commit is contained in:
@ -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);
|
||||
|
@ -13,6 +13,13 @@ namespace Common::ec
|
||||
/// Generate a signature using ECDSA.
|
||||
std::array<u8, 60> Sign(const u8* key, const u8* hash);
|
||||
|
||||
/// Check a signature using ECDSA.
|
||||
///
|
||||
/// @param public_key 30 byte ECC public key
|
||||
/// @param signature 60 byte signature
|
||||
/// @param hash Message hash
|
||||
bool VerifySignature(const u8* public_key, const u8* signature, const u8* hash);
|
||||
|
||||
/// Compute a shared secret from a private key (30 bytes) and public key (60 bytes).
|
||||
std::array<u8, 60> ComputeSharedSecret(const u8* private_key, const u8* public_key);
|
||||
|
||||
|
Reference in New Issue
Block a user