16 lines
1.1 KiB
JavaScript
16 lines
1.1 KiB
JavaScript
// Fixtura: WebCrypto (browser sau globalThis.crypto in Node).
|
|
const subtle = globalThis.crypto.subtle;
|
|
|
|
export async function webcrypto(data) {
|
|
const rsa = await subtle.generateKey(
|
|
{ name: 'RSA-OAEP', modulusLength: 3072, publicExponent: new Uint8Array([1, 0, 1]), hash: 'SHA-256' }, // EXPECT: RSA-3072 | quantum-vulnerable
|
|
true, ['encrypt', 'decrypt']);
|
|
const ec = await subtle.generateKey({ name: 'ECDSA', namedCurve: 'P-384' }, true, ['sign', 'verify']); // EXPECT: ECDSA-secp384r1 | quantum-vulnerable
|
|
const ed = await subtle.generateKey('Ed25519', true, ['sign', 'verify']); // EXPECT: Ed25519 | quantum-vulnerable
|
|
const x = await subtle.generateKey({ name: 'X25519' }, true, ['deriveBits']); // EXPECT: X25519 | quantum-vulnerable
|
|
const aes = await subtle.generateKey({ name: 'AES-GCM', length: 256 }, true, ['encrypt']); // EXPECT: AES-256-GCM | quantum-safe
|
|
const d1 = await subtle.digest('SHA-1', data); // EXPECT: SHA-1 | weak-now
|
|
const d2 = await subtle.digest({ name: 'SHA-384' }, data); // EXPECT: SHA-384 | quantum-safe
|
|
return [rsa, ec, ed, x, aes, d1, d2];
|
|
}
|