mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 12:32:21 +00:00
LibWeb: Implement most of ECDSA verify for SubtleCrypto
This commit is contained in:
parent
6906b7c1e6
commit
ae230c9150
Notes:
sideshowbarker
2024-07-16 20:21:48 +09:00
Author: https://github.com/stelar7
Commit: ae230c9150
Pull-request: https://github.com/SerenityOS/serenity/pull/23737
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/trflynn89
5 changed files with 156 additions and 1 deletions
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>
|
Loading…
Add table
Add a link
Reference in a new issue