تخطَّ إلى المحتوى

ECB Mode (ARCH5113)

هذا المحتوى غير متوفر بلغتك بعد.

Key go.security.ecb-mode · Severity error · Category security · CWE CWE-327

ECB mode encrypts each block independently, so identical plaintext blocks produce identical ciphertext and data patterns leak. ECB is never IND-CPA secure.

block, _ := aes.NewCipher(key)
for i := 0; i < len(plaintext); i += aes.BlockSize {
block.Encrypt(ciphertext[i:], plaintext[i:]) // ECB
}
block, _ := aes.NewCipher(key)
gcm, _ := cipher.NewGCM(block)
nonce := make([]byte, gcm.NonceSize())
rand.Read(nonce)
ciphertext := gcm.Seal(nonce, nonce, plaintext, nil)

Use an authenticated mode like GCM with a unique nonce per encryption instead of ECB.