aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2015-10-20 16:19:11 -0400
committerJack Lloyd <[email protected]>2015-10-20 16:19:11 -0400
commit514474b98ccdfa6c0f76576c0ebfbec2af637d81 (patch)
treed911b1e8294fad454dd8891aa9dcd25939f85a4f /src/lib
parent194d7d3682bddbd534e211357dd5f817d01ab7ed (diff)
Fix botan.py for Python3
Remove any need for callers to do version checks or encode values specially to handle Python2 vs Python3 ctypes differences. API users shouldn't have to care about that - encapsulate the differences in a few functions for handling the conversions. Add botan_cipher_query_keylen to ffi
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ffi/ffi.cpp10
-rw-r--r--src/lib/ffi/ffi.h4
-rw-r--r--src/lib/ffi/info.txt2
3 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp
index eb30b4831..7ed279bbd 100644
--- a/src/lib/ffi/ffi.cpp
+++ b/src/lib/ffi/ffi.cpp
@@ -429,6 +429,16 @@ int botan_cipher_clear(botan_cipher_t cipher)
return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, { cipher.clear(); });
}
+int botan_cipher_query_keylen(botan_cipher_t cipher,
+ size_t* out_minimum_keylength,
+ size_t* out_maximum_keylength)
+ {
+ return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, {
+ *out_minimum_keylength = cipher.key_spec().minimum_keylength();
+ *out_maximum_keylength = cipher.key_spec().maximum_keylength();
+ });
+ }
+
int botan_cipher_set_key(botan_cipher_t cipher,
const uint8_t* key, size_t key_len)
{
diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h
index ce2253725..2def4f4d5 100644
--- a/src/lib/ffi/ffi.h
+++ b/src/lib/ffi/ffi.h
@@ -220,6 +220,10 @@ BOTAN_DLL int botan_cipher_get_tag_length(botan_cipher_t cipher, size_t* tag_siz
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_query_keylen(botan_cipher_t,
+ size_t* out_minimum_keylength,
+ size_t* out_maximum_keylength);
+
BOTAN_DLL int botan_cipher_set_key(botan_cipher_t cipher,
const uint8_t* key, size_t key_len);
diff --git a/src/lib/ffi/info.txt b/src/lib/ffi/info.txt
index 4018e4064..7c8968ff0 100644
--- a/src/lib/ffi/info.txt
+++ b/src/lib/ffi/info.txt
@@ -1,4 +1,4 @@
-define FFI 20151001
+define FFI 20151015
<requires>
aead