diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-06-29 20:43:29 -0700 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-06-29 20:43:29 -0700 |
| commit | 8f1b8e88e6e9ed7d73661bb90f0e558059b610f3 (patch) | |
| tree | 5b3fd5321c77e1f1b0da4d93497d03bd20f75282 /cryptography | |
| parent | 2d6e91f81266129c48ae775228a18d92c2d0f2c7 (diff) | |
| download | cryptography-8f1b8e88e6e9ed7d73661bb90f0e558059b610f3.tar.gz cryptography-8f1b8e88e6e9ed7d73661bb90f0e558059b610f3.tar.bz2 cryptography-8f1b8e88e6e9ed7d73661bb90f0e558059b610f3.zip | |
Fixes #1200 -- disallow GCM truncation by default
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/__about__.py | 2 | ||||
| -rw-r--r-- | cryptography/hazmat/primitives/ciphers/modes.py | 7 |
2 files changed, 5 insertions, 4 deletions
diff --git a/cryptography/__about__.py b/cryptography/__about__.py index ee53902b..ccbcdfe8 100644 --- a/cryptography/__about__.py +++ b/cryptography/__about__.py @@ -28,4 +28,4 @@ __author__ = "The cryptography developers" __email__ = "cryptography-dev@python.org" __license__ = "Apache License, Version 2.0" -__copyright__ = "Copyright 2013-2014 %s" % __author__ +__copyright__ = "Copyright 2013-2014 {0}".format(__author__) diff --git a/cryptography/hazmat/primitives/ciphers/modes.py b/cryptography/hazmat/primitives/ciphers/modes.py index e70a9db5..f09478fc 100644 --- a/cryptography/hazmat/primitives/ciphers/modes.py +++ b/cryptography/hazmat/primitives/ciphers/modes.py @@ -97,13 +97,14 @@ class CTR(object): class GCM(object): name = "GCM" - def __init__(self, initialization_vector, tag=None): + def __init__(self, initialization_vector, tag=None, min_tag_length=16): # len(initialization_vector) must in [1, 2 ** 64), but it's impossible # to actually construct a bytes object that large, so we don't check # for it - if tag is not None and len(tag) < 4: + if tag is not None and len(tag) < min_tag_length: raise ValueError( - "Authentication tag must be 4 bytes or longer." + "Authentication tag must be {0} bytes or longer.".format( + min_tag_length) ) self.initialization_vector = initialization_vector |
