ladybird/Tests/LibWeb/Text/input/Crypto/SubtleCrypto-aesgcm.html
rmg-x 0db171c36e LibWeb/Crypto: Fix sizes being passed into generate_aes_key()
Previously, callers were passing the size in bytes, but the method
expected bits. This caused a crash in LibCrypto when verifying the key
size later on.

Also make the naming of local variables and parameters a little more
clear between the different AES algorithms :^)
2024-11-03 21:55:43 +01:00

22 lines
1.1 KiB
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script>
asyncTest(async (done) => {
const algorithm = "AES-GCM";
// Generate keys and export them, verify length
const aesGcm128bitKey = await crypto.subtle.generateKey({ name: algorithm, length: 128 }, true, ["encrypt"]);
const aesGcm192bitKey = await crypto.subtle.generateKey({ name: algorithm, length: 192 }, true, ["encrypt"]);
const aesGcm256bitKey = await crypto.subtle.generateKey({ name: algorithm, length: 256 }, true, ["encrypt"]);
const exported128bitKey = await crypto.subtle.exportKey("raw", aesGcm128bitKey);
const exported192bitKey = await crypto.subtle.exportKey("raw", aesGcm192bitKey);
const exported256bitKey = await crypto.subtle.exportKey("raw", aesGcm256bitKey);
println("exported 128 bit key length: " + exported128bitKey.byteLength);
println("exported 192 bit key length: " + exported192bitKey.byteLength);
println("exported 256 bit key length: " + exported256bitKey.byteLength);
done();
});
</script>