diff options
author | lloyd <[email protected]> | 2015-03-09 23:14:18 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2015-03-09 23:14:18 +0000 |
commit | 45c6dcf839e6b2e701db6c9158dc890cb8be36a2 (patch) | |
tree | 39decbb66b97bfeb83fa8001b0086b051476e225 | |
parent | f89059ffe3df9f623779848cf35bef86d429717e (diff) |
Fix Python cipher update_granularity() and default_nonce_length()
which were completely broken. Pointed out by Uri B on mailing list.
-rw-r--r-- | src/lib/ffi/ffi.cpp | 5 | ||||
-rw-r--r-- | src/lib/ffi/ffi.h | 1 | ||||
-rwxr-xr-x | src/python/botan.py | 9 |
3 files changed, 11 insertions, 4 deletions
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp index eba3f5f94..69c559521 100644 --- a/src/lib/ffi/ffi.cpp +++ b/src/lib/ffi/ffi.cpp @@ -577,6 +577,11 @@ int botan_cipher_get_default_nonce_length(botan_cipher_t cipher, size_t* nl) return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { *nl = cipher.default_nonce_length(); }); } +int botan_cipher_get_update_granularity(botan_cipher_t cipher, size_t* ug) + { + return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { *ug = cipher.update_granularity(); }); + } + int botan_cipher_get_tag_length(botan_cipher_t cipher, size_t* tl) { return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { *tl = cipher.tag_size(); }); diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h index b4e99defd..ca92977f4 100644 --- a/src/lib/ffi/ffi.h +++ b/src/lib/ffi/ffi.h @@ -99,6 +99,7 @@ BOTAN_DLL int botan_cipher_init(botan_cipher_t* cipher, const char* name, uint32 BOTAN_DLL int botan_cipher_valid_nonce_length(botan_cipher_t cipher, size_t nl); BOTAN_DLL int botan_cipher_get_tag_length(botan_cipher_t cipher, size_t* tag_size); BOTAN_DLL int botan_cipher_get_default_nonce_length(botan_cipher_t cipher, size_t* nl); +BOTAN_DLL int botan_cipher_get_update_granularity(botan_cipher_t cipher, size_t* ug); BOTAN_DLL int botan_cipher_set_key(botan_cipher_t cipher, const uint8_t* key, size_t key_len); diff --git a/src/python/botan.py b/src/python/botan.py index 129aeaebb..94887870b 100755 --- a/src/python/botan.py +++ b/src/python/botan.py @@ -156,15 +156,15 @@ class cipher(object): botan.botan_cipher_destroy(self.cipher) def default_nonce_length(self): - botan.botan_cipher_default_nonce_length.argtypes = [c_void_p, POINTER(c_size_t)] + botan.botan_cipher_get_default_nonce_length.argtypes = [c_void_p, POINTER(c_size_t)] l = c_size_t(0) - botan.botan_cipher_default_nonce_length(self.cipher, byref(l)) + botan.botan_cipher_get_default_nonce_length(self.cipher, byref(l)) return l.value def update_granularity(self): - botan.botan_cipher_update_granularity.argtypes = [c_void_p, POINTER(c_size_t)] + botan.botan_cipher_get_update_granularity.argtypes = [c_void_p, POINTER(c_size_t)] l = c_size_t(0) - botan.botan_cipher_update_granularity(self.cipher, byref(l)) + botan.botan_cipher_get_update_granularity(self.cipher, byref(l)) return l.value def tag_length(self): @@ -517,6 +517,7 @@ def test(): print "md5", h.final().encode('hex') gcm = cipher('AES-128/GCM') + print gcm.default_nonce_length(), gcm.update_granularity() gcm_dec = cipher('AES-128/GCM', encrypt=False) iv = r.get(12) |