32 lines
2.3 KiB
JavaScript
32 lines
2.3 KiB
JavaScript
// Fixtura: node:crypto. Fiecare rand cu o folosire poarta marcajul EXPECT al gasirii asteptate.
|
|
// Fisierul nu se executa niciodata; e doar text pentru scaner.
|
|
import crypto from 'node:crypto';
|
|
import { createHash, generateKeyPairSync } from 'crypto';
|
|
|
|
const HASH_ALG = 'sha256';
|
|
|
|
export function exemple(data, key, iv, algDinParametru, pemDinConfig) {
|
|
const a = createHash('md5').update(data).digest('hex'); // EXPECT: MD5 | weak-now
|
|
const b = crypto.createHash('sha1'); // EXPECT: SHA-1 | weak-now
|
|
const c = crypto.createHash(HASH_ALG); // EXPECT: SHA-256 | quantum-safe
|
|
const d = crypto.createHash(algDinParametru); // EXPECT: createHash | unknown
|
|
const { publicKey } = generateKeyPairSync('rsa', { modulusLength: 2048 }); // EXPECT: RSA-2048 | quantum-vulnerable
|
|
const k2 = crypto.generateKeyPairSync('ec', { namedCurve: 'secp256k1' }); // EXPECT: EC-secp256k1 | quantum-vulnerable
|
|
const k3 = crypto.generateKeyPairSync('ed25519'); // EXPECT: Ed25519 | quantum-vulnerable
|
|
const k4 = crypto.generateKeyPairSync('ml-dsa-65'); // EXPECT: ML-DSA-65 | quantum-safe
|
|
const k5 = crypto.generateKeyPairSync('ml-kem-768'); // EXPECT: ML-KEM-768 | quantum-safe
|
|
const s = crypto.createSign('RSA-SHA256'); // EXPECT: RSA | quantum-vulnerable
|
|
const v = crypto.createVerify('SHA1'); // EXPECT: signature-with-SHA-1 | weak-now
|
|
const e = crypto.createECDH('prime256v1'); // EXPECT: ECDH-secp256r1 | quantum-vulnerable
|
|
const c1 = crypto.createCipheriv('aes-256-gcm', key, iv); // EXPECT: AES-256-GCM | quantum-safe
|
|
const c2 = crypto.createCipheriv('des-ede3-cbc', key, iv); // EXPECT: 3DES-CBC | weak-now
|
|
const c3 = crypto.createCipheriv('aes-128-ecb', key, null); // EXPECT: AES-128-ECB | weak-now
|
|
const c4 = crypto.createDecipheriv('aes-128-cbc', key, iv); // EXPECT: AES-128-CBC | quantum-safe
|
|
const enc = crypto.publicEncrypt(publicKey, data); // EXPECT: RSA | quantum-vulnerable
|
|
const h = crypto.createHmac('sha256', key); // EXPECT: HMAC-SHA-256 | quantum-safe
|
|
const dh = crypto.getDiffieHellman('modp2'); // EXPECT: DH-1024 | weak-now
|
|
const sig = crypto.sign(null, data, key); // EXPECT: crypto.sign | unknown
|
|
const pk = crypto.createPrivateKey(pemDinConfig); // EXPECT: createPrivateKey | unknown
|
|
return [a, b, c, d, k2, k3, k4, k5, s, v, e, c1, c2, c3, c4, enc, h, dh, sig, pk];
|
|
}
|