mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 20:17:13 +02:00
LibWeb: Implement most of ECDSA verify for SubtleCrypto
This commit is contained in:
Notes:
sideshowbarker
2024-07-16 20:21:48 +09:00
Author: https://github.com/stelar7 Commit: https://github.com/SerenityOS/serenity/commit/ae230c9150 Pull-request: https://github.com/SerenityOS/serenity/pull/23737 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/trflynn89
45
Tests/LibWeb/Text/input/Crypto/SubtleCrypto-verify.html
Normal file
45
Tests/LibWeb/Text/input/Crypto/SubtleCrypto-verify.html
Normal file
@@ -0,0 +1,45 @@
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
asyncTest(async done => {
|
||||
const encoder = new TextEncoder();
|
||||
const message = "Hello friends";
|
||||
const encoded_message = encoder.encode(message);
|
||||
|
||||
const key_algorithm = {
|
||||
name: "ECDSA",
|
||||
namedCurve: "P-384",
|
||||
};
|
||||
const extractable = true;
|
||||
const usages = ["sign", "verify"];
|
||||
const key = await window.crypto.subtle.generateKey(key_algorithm, extractable, usages);
|
||||
|
||||
console.log(key.publicKey);
|
||||
|
||||
const signature_algorithm = {
|
||||
name: "ECDSA",
|
||||
hash: { name: "SHA-384" },
|
||||
};
|
||||
const signature = await window.crypto.subtle.sign(
|
||||
signature_algorithm,
|
||||
key.privateKey,
|
||||
encoded_message
|
||||
);
|
||||
|
||||
let result = await window.crypto.subtle.verify(
|
||||
signature_algorithm,
|
||||
key.publicKey,
|
||||
signature,
|
||||
encoded_message
|
||||
);
|
||||
|
||||
println(`FIXME: This will fail as we dont support ECDSA sign()`);
|
||||
|
||||
if (result) {
|
||||
println(`Verified OK`);
|
||||
} else {
|
||||
println(`FAIL: Verification not ok`);
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user