diff options
-rw-r--r-- | cryptography/hazmat/primitives/ciphers/modes.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cryptography/hazmat/primitives/ciphers/modes.py b/cryptography/hazmat/primitives/ciphers/modes.py index 597b4e3e..f357dcf7 100644 --- a/cryptography/hazmat/primitives/ciphers/modes.py +++ b/cryptography/hazmat/primitives/ciphers/modes.py @@ -77,3 +77,10 @@ class CTR(object): def __init__(self, nonce): self.nonce = nonce + + + def validate_for_algorithm(self, algorithm): + if len(self.nonce) * 8 != algorithm.block_size: + raise ValueError("Invalid nonce size ({0}) for {1}".format( + len(self.nonce), self.name + )) |