diff --git a/runtime/include/wii_es_crypto.h b/runtime/include/wii_es_crypto.h index d1fb78c..0c515b5 100644 --- a/runtime/include/wii_es_crypto.h +++ b/runtime/include/wii_es_crypto.h @@ -132,8 +132,9 @@ using CryptoEcdsa = CryptoPP::ECDSA; inline CryptoEcdsa::PrivateKey MakePrivateKey(const uint8_t* key) { CryptoPP::DL_GroupParameters_EC parameters(CryptoPP::ASN1::sect233r1()); - const CryptoPP::Integer exponent(key, 30); - if (exponent <= CryptoPP::Integer::Zero() || exponent >= parameters.GetSubgroupOrder()) { + // Wii keys need not be canonical scalars; reduction preserves their public key. + const CryptoPP::Integer exponent = CryptoPP::Integer(key, 30) % parameters.GetSubgroupOrder(); + if (exponent == CryptoPP::Integer::Zero()) { throw std::invalid_argument("Wii ES private key is outside the sect233r1 subgroup"); }