aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-11-19 16:52:32 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-11-19 16:52:32 -0800
commit707253283ec2921bf76e2c8049eb47388d9da580 (patch)
treed114ac4964ad7099a2b9db0e7d536a9eaee42fbe
parent9626b5a50460d2f90baa1f1b8c6a09ccc900c178 (diff)
downloadcryptography-707253283ec2921bf76e2c8049eb47388d9da580.tar.gz
cryptography-707253283ec2921bf76e2c8049eb47388d9da580.tar.bz2
cryptography-707253283ec2921bf76e2c8049eb47388d9da580.zip
Implement this for CTR
-rw-r--r--cryptography/hazmat/primitives/ciphers/modes.py7
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
+ ))