İçeriğe geç

ECB modu kullanımı (ARCH3113)

Anahtar typescript.security.ecb-mode · Önem error · Kategori security · CWE CWE-327

Blok şifreyi ECB modunda kullanmak düz metin desenlerini sızdırır ve hiçbir zaman IND-CPA güvenli değildir. Rastgele bir IV ile kimlik doğrulamalı bir mod kullanın.

import { createCipheriv } from "crypto";
const cipher = createCipheriv("aes-256-ecb", key, null);
const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);
import { createCipheriv, randomBytes } from "crypto";
const iv = randomBytes(12);
const cipher = createCipheriv("aes-256-gcm", key, iv);
const encrypted = Buffer.concat([cipher.update(plaintext), cipher.final()]);
const tag = cipher.getAuthTag();

ECB yerine her mesajda rastgele IV/nonce kullanan AES-GCM gibi kimlik doğrulamalı bir mod seçin.