mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-16 05:51:55 +00:00
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 :^)
22 lines
1.1 KiB
HTML
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>
|