Files
ladybird/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-sign.html

33 lines
980 B
HTML

<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>