mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-21 16:58:58 +00:00
LibWeb: Implement skeleton of ECDSA sign for SubtleCrypto
This commit is contained in:
parent
41449814db
commit
bc2a5e24bc
Notes:
sideshowbarker
2024-07-17 01:06:10 +09:00
Author: https://github.com/stelar7
Commit: bc2a5e24bc
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 113 additions and 0 deletions
32
Tests/LibWeb/Text/input/Crypto/SubtleCrypto-sign.html
Normal file
32
Tests/LibWeb/Text/input/Crypto/SubtleCrypto-sign.html
Normal file
|
@ -0,0 +1,32 @@
|
|||
<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);
|
||||
|
||||
const signature_algorithm = {
|
||||
name: "ECDSA",
|
||||
hash: { name: "SHA-384" },
|
||||
};
|
||||
const signature = await window.crypto.subtle.sign(
|
||||
signature_algorithm,
|
||||
key.privateKey,
|
||||
encoded_message
|
||||
);
|
||||
|
||||
const data_view = String.fromCharCode.apply(null, new Uint8Array(signature));
|
||||
|
||||
println(`Signed OK ... [${signature.byteLength} bytes total] (${data_view})`);
|
||||
|
||||
done();
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue