mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-30 11:37:16 +02:00
LibCrypto: Implement Ed25519 Small Order Points
This commit is contained in:
committed by
Jelle Raaijmakers
parent
af8b256832
commit
6b4e00bc39
Notes:
github-actions[bot]
2025-08-01 12:32:56 +00:00
Author: https://github.com/ChaseKnowlden Commit: https://github.com/LadybirdBrowser/ladybird/commit/6b4e00bc39b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5634 Reviewed-by: https://github.com/gmta ✅
@@ -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>
|
||||
@@ -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();
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user