ECB Mode (ARCH5113)
Esta página aún no está disponible en tu idioma.
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.
Incorrect
Section titled “Incorrect”block, _ := aes.NewCipher(key)for i := 0; i < len(plaintext); i += aes.BlockSize { block.Encrypt(ciphertext[i:], plaintext[i:]) // ECB}Correct
Section titled “Correct”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.