LibWeb: Implement RSAOAEP.encrypt()

This commit is contained in:
stelar7
2024-04-09 02:08:56 +02:00
committed by Andreas Kling
parent 6fc268f588
commit 48bd094712
Notes: github-actions[bot] 2024-10-27 10:32:23 +00:00
4 changed files with 68 additions and 3 deletions

View File

@@ -0,0 +1,32 @@
<script src="../include.js"></script>
<script>
asyncTest(async done => {
const encoder = new TextEncoder();
const message = "Hello friends";
const encodedMessage = encoder.encode(message);
const generated = await window.crypto.subtle.generateKey(
{
name: "RSA-OAEP",
modulusLength: 512,
publicExponent: new Uint8Array([1, 0, 1]),
hash: "SHA-1",
},
true,
["encrypt", "decrypt"]
);
const ciphertext = await window.crypto.subtle.encrypt(
{
name: "RSA-OAEP",
},
generated.publicKey,
encodedMessage
);
const buffer = new Uint8Array(ciphertext);
println(`Encrypted OK with ${buffer.byteLength} bytes`);
done();
});
</script>