From 70b4133a32476bc5abad18e1f4465a4ec2ceeab1 Mon Sep 17 00:00:00 2001 From: Michał Górny Date: Tue, 20 Aug 2013 20:50:46 +0200 Subject: OkupyCipher: make block_size a public property. --- okupy/common/crypto.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'okupy/common') diff --git a/okupy/common/crypto.py b/okupy/common/crypto.py index 2596680..705f173 100644 --- a/okupy/common/crypto.py +++ b/okupy/common/crypto.py @@ -16,7 +16,6 @@ class OkupyCipher(object): _hasher_algo = SHA384Hash _cipher_algo = BlowfishCipher - _cipher_block_size = 8 def __init__(self): hasher = self._hasher_algo() @@ -25,6 +24,13 @@ class OkupyCipher(object): self.cipher = self._cipher_algo(key_hash) self.rng = Crypto.Random.new() + @property + def block_size(self): + """ + Cipher's block size. + """ + return self.cipher.block_size + def encrypt(self, data): """ Encrypt random-length data block padding it with random data @@ -34,7 +40,7 @@ class OkupyCipher(object): # ensure it's bytestring before we append random bits data = bytes(data) # minus is intentional. (-X % S) == S - (X % S) - padding = -len(data) % self._cipher_block_size + padding = -len(data) % self.block_size if padding: data += self.rng.read(padding) return self.cipher.encrypt(data) -- cgit v1.2.3-65-gdbad