From 18e17c6701c66481d09ed01697e3ec42ec3b73c7 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Fri, 16 May 2014 11:37:29 -0400 Subject: Fix --- cryptography/hazmat/primitives/ciphers/modes.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cryptography/hazmat/primitives/ciphers/modes.py b/cryptography/hazmat/primitives/ciphers/modes.py index 96b07ce1..20dab8ae 100644 --- a/cryptography/hazmat/primitives/ciphers/modes.py +++ b/cryptography/hazmat/primitives/ciphers/modes.py @@ -84,7 +84,11 @@ class CTR(object): def __init__(self, nonce): self.nonce = nonce - validate_for_algorithm = _check_iv_length + 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 + )) @utils.register_interface(interfaces.Mode) -- cgit v1.2.3