bandit/examples/cipher-modes.py
Eric Brown 057e63f3ae Check for insecure cipher modes
ECB is a known insecure cipher mode and needs to be checked for.

Currently this test will only scan for pyca/cryptography's use of
ECB.  Future patches should check for PyCrypto and others.

Change-Id: I27c30cb93e814eb3b3ce6732e94a76128b5b9e81
2015-10-08 23:16:38 -07:00

13 lines
257 B
Python

from cryptography.hazmat.primitives.ciphers.modes import CBC
from cryptography.hazmat.primitives.ciphers.modes import ECB
# Insecure mode
mode = ECB(iv)
# Secure cipher and mode
cipher = AES.new(key, blockalgo.MODE_CTR, iv)
# Secure mode
mode = CBC(iv)