LibCrypto: Implement Ed25519 Small Order Points

This commit is contained in:
Chase Knowlden
2025-07-28 21:35:21 -04:00
committed by Jelle Raaijmakers
parent af8b256832
commit 6b4e00bc39
Notes: github-actions[bot] 2025-08-01 12:32:56 +00:00
7 changed files with 270 additions and 17 deletions

View File

@@ -0,0 +1,17 @@
<!doctype html>
<meta charset=utf-8>
<title>WebCryptoAPI: verify() Using EdDSA with small-order points</title>
<meta name="timeout" content="long">
<script>
self.GLOBAL = {
isWindow: function() { return true; },
isWorker: function() { return false; },
isShadowRealm: function() { return false; },
};
</script>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="eddsa_vectors.js"></script>
<script src="eddsa_small_order_points.js"></script>
<div id=log></div>
<script src="../../WebCryptoAPI/sign_verify/eddsa_small_order_points.https.any.js"></script>

View File

@@ -0,0 +1,6 @@
// META: title=WebCryptoAPI: verify() Using EdDSA with small-order points
// META: script=eddsa_vectors.js
// META: script=eddsa_small_order_points.js
// META: timeout=long
run_test();

View File

@@ -0,0 +1,26 @@
function run_test() {
var subtle = self.crypto.subtle; // Change to test prefixed implementations
// When verifying an Ed25519 or Ed448 signature, if the public key or the first half of the signature (R) is
// an invalid or small-order element, return false.
Object.keys(kSmallOrderTestCases).forEach(function (algorithmName) {
var algorithm = {name: algorithmName};
kSmallOrderTestCases[algorithmName].forEach(function(test) {
promise_test(async() => {
let isVerified = true;
let publicKey;
try {
publicKey = await subtle.importKey("raw", test.keyData, algorithm, false, ["verify"])
isVerified = await subtle.verify(algorithm, publicKey, test.signature, test.message);
} catch (err) {
assert_true(publicKey !== undefined, "Public key should be valid.");
assert_unreached("The operation shouldn't fail, but it thown this error: " + err.name + ": " + err.message + ".");
}
assert_equals(isVerified, test.verified, "Signature verification result.");
}, algorithmName + " Verification checks with small-order key of order - Test " + test.id);
});
});
return;
}