mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-22 02:09:24 +00:00
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 :^)
This commit is contained in:
parent
64747c0397
commit
0db171c36e
Notes:
github-actions[bot]
2024-11-03 20:56:39 +00:00
Author: https://github.com/rmg-x
Commit: 0db171c36e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2143
Reviewed-by: https://github.com/gmta ✅
3 changed files with 39 additions and 14 deletions
22
Tests/LibWeb/Text/input/Crypto/SubtleCrypto-aesgcm.html
Normal file
22
Tests/LibWeb/Text/input/Crypto/SubtleCrypto-aesgcm.html
Normal file
|
@ -0,0 +1,22 @@
|
|||
<!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>
|
Loading…
Add table
Add a link
Reference in a new issue