1. Andriy Kornatskyy
  2. wheezy.security

Commits

Andriy Kornatskyy  committed 2bd4d87

Warn if AES key and initialization vector overlap; assert minimum key length.

  • Participants
  • Parent commits 890c8e8
  • Branches default

Comments (0)

Files changed (1)

File src/wheezy/security/crypto/comp.py

View file
 
 import sys
 
+from warnings import warn
+
 
 PY3 = sys.version_info[0] >= 3
 
 
     # suppored cyphers
     def aes(key, key_size=32):
+        assert len(key) >= key_size
+        if len(key) < key_size + 16:
+            warn('AES%d: key and iv overlap.' % (key_size * 8))
         key = key[-key_size:]
-        iv = key[-16:]
+        iv = key[:16]
         return lambda: AES.new(key, AES.MODE_CBC, iv)
 
     aes128 = lambda key: aes(key, 16)