1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 12:35:13 +00:00

Tests: Only use a 256-bit RSA key in SubtleCrypto generateKey test

Until we get a better performing RSA keygen algorithm, this test times
out occasionally in CI with a 512-bit key.
This commit is contained in:
Andrew Kaster 2024-03-14 14:39:23 -06:00 committed by Andrew Kaster
parent 1521a60a67
commit c4be9318a2
2 changed files with 22 additions and 20 deletions

View file

@ -1,11 +1,11 @@
generateKey with RSA-OAEP algorithm generateKey with RSA-OAEP algorithm
publicKey: [object CryptoKey] publicKey: [object CryptoKey]
publicKey algorithm: {"name":"RSA-OAEP","modulusLength":512,"publicExponent":{"0":1,"1":0,"2":1},"hash":"SHA-256"} publicKey algorithm: {"name":"RSA-OAEP","modulusLength":256,"publicExponent":{"0":1,"1":0,"2":1},"hash":"SHA-256"}
publicKey type: public publicKey type: public
publicKey extractable: true publicKey extractable: true
publicKey usages: encrypt,wrapKey publicKey usages: encrypt,wrapKey
privateKey: [object CryptoKey] privateKey: [object CryptoKey]
privateKey algorithm: {"name":"RSA-OAEP","modulusLength":512,"publicExponent":{"0":1,"1":0,"2":1},"hash":"SHA-256"} privateKey algorithm: {"name":"RSA-OAEP","modulusLength":256,"publicExponent":{"0":1,"1":0,"2":1},"hash":"SHA-256"}
privateKey type: private privateKey type: private
privateKey extractable: true privateKey extractable: true
privateKey usages: decrypt,unwrapKey privateKey usages: decrypt,unwrapKey

View file

@ -5,11 +5,11 @@
} }
asyncTest(async done => { asyncTest(async done => {
// FIXME: Generate a key with module lengths longer than 256, when they don't take an eternity to generate.
// FIXME: Generate a key with module lengths longer than 512, when they don't take an eternity to generate. // This is #23561
let algorithm = { let algorithm = {
name: "RSA-OAEP", name: "RSA-OAEP",
modulusLength: 512, modulusLength: 256,
publicExponent: new Uint8Array([1, 0, 1]), publicExponent: new Uint8Array([1, 0, 1]),
hash: "SHA-256", hash: "SHA-256",
}; };
@ -17,11 +17,12 @@
println("generateKey with RSA-OAEP algorithm"); println("generateKey with RSA-OAEP algorithm");
var key = undefined; var key = undefined;
try { try {
key = await window.crypto.subtle.generateKey( key = await window.crypto.subtle.generateKey(algorithm, true, [
algorithm, "encrypt",
true, "decrypt",
["encrypt", "decrypt", "wrapKey", "unwrapKey"] "wrapKey",
); "unwrapKey",
]);
} catch (e) { } catch (e) {
println(`FAIL: ${e}`); println(`FAIL: ${e}`);
} }
@ -41,22 +42,23 @@
println("invalid usages throw"); println("invalid usages throw");
try { try {
const key2 = await window.crypto.subtle.generateKey( const key2 = await window.crypto.subtle.generateKey(algorithm, true, [
algorithm, "encrypt",
true, "decrypt",
["encrypt", "decrypt", "wrapKey", "unwrapKey", "sign"] "wrapKey",
); "unwrapKey",
"sign",
]);
} catch (e) { } catch (e) {
println(`Error: ${e}`); println(`Error: ${e}`);
} }
println("no usages for private key throws"); println("no usages for private key throws");
try { try {
const key3 = await window.crypto.subtle.generateKey( const key3 = await window.crypto.subtle.generateKey(algorithm, true, [
algorithm, "encrypt",
true, "wrapKey",
["encrypt", "wrapKey"] ]);
);
} catch (e) { } catch (e) {
println(`Error: ${e}`); println(`Error: ${e}`);
} }