aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-11 07:31:41 -0400
committerJack Lloyd <[email protected]>2018-08-11 07:31:41 -0400
commit2c10ec625d799d513a56ec93f8117999143be244 (patch)
tree2c1714e61cb7cb612172125d989b7576a587a70d /src/lib
parent4bae26bc1a884d534dc482ba3cd4cbeaa50f4963 (diff)
Add botan_cipher_get_keyspec
botan_cipher_query_keylen doesn't return the modulus. Renames (recently added/unreleased) botan_{block_cipher,mac}_query_keylen to x_get_keyspec so the names are consistent.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ffi/ffi.h16
-rw-r--r--src/lib/ffi/ffi_block.cpp8
-rw-r--r--src/lib/ffi/ffi_cipher.cpp15
-rw-r--r--src/lib/ffi/ffi_mac.cpp8
4 files changed, 34 insertions, 13 deletions
diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h
index 83c84b3fa..080c71cef 100644
--- a/src/lib/ffi/ffi.h
+++ b/src/lib/ffi/ffi.h
@@ -403,7 +403,7 @@ BOTAN_PUBLIC_API(2,8) int botan_mac_name(botan_mac_t mac, char* name, size_t* na
* @param out_maximum_keylength if non-NULL, will be set to maximum keylength of MAC
* @param out_keylength_modulo if non-NULL will be set to byte multiple of valid keys
*/
-BOTAN_PUBLIC_API(2,8) int botan_mac_query_keylen(botan_mac_t mac,
+BOTAN_PUBLIC_API(2,8) int botan_mac_get_keyspec(botan_mac_t mac,
size_t* out_minimum_keylength,
size_t* out_maximum_keylength,
size_t* out_keylength_modulo);
@@ -435,10 +435,16 @@ BOTAN_PUBLIC_API(2,0) int botan_cipher_get_tag_length(botan_cipher_t cipher, siz
BOTAN_PUBLIC_API(2,0) int botan_cipher_get_default_nonce_length(botan_cipher_t cipher, size_t* nl);
BOTAN_PUBLIC_API(2,0) int botan_cipher_get_update_granularity(botan_cipher_t cipher, size_t* ug);
+// Prefer botan_cipher_get_keyspec
BOTAN_PUBLIC_API(2,0) int botan_cipher_query_keylen(botan_cipher_t,
size_t* out_minimum_keylength,
size_t* out_maximum_keylength);
+BOTAN_PUBLIC_API(2,8) int botan_cipher_get_keyspec(botan_cipher_t,
+ size_t* min_keylen,
+ size_t* max_keylen,
+ size_t* mod_keylen);
+
BOTAN_PUBLIC_API(2,0) int botan_cipher_set_key(botan_cipher_t cipher,
const uint8_t* key, size_t key_len);
@@ -606,10 +612,10 @@ BOTAN_PUBLIC_API(2,8) int botan_block_cipher_name(botan_block_cipher_t cipher,
* @param out_maximum_keylength if non-NULL, will be set to maximum keylength of cipher
* @param out_keylength_modulo if non-NULL will be set to byte multiple of valid keys
*/
-BOTAN_PUBLIC_API(2,8) int botan_block_cipher_query_keylen(botan_block_cipher_t cipher,
- size_t* out_minimum_keylength,
- size_t* out_maximum_keylength,
- size_t* out_keylength_modulo);
+BOTAN_PUBLIC_API(2,8) int botan_block_cipher_get_keyspec(botan_block_cipher_t cipher,
+ size_t* out_minimum_keylength,
+ size_t* out_maximum_keylength,
+ size_t* out_keylength_modulo);
/*
* Multiple precision integers
diff --git a/src/lib/ffi/ffi_block.cpp b/src/lib/ffi/ffi_block.cpp
index e19747d2b..8e45fd1cc 100644
--- a/src/lib/ffi/ffi_block.cpp
+++ b/src/lib/ffi/ffi_block.cpp
@@ -85,10 +85,10 @@ int botan_block_cipher_name(botan_block_cipher_t cipher, char* name, size_t* nam
return write_str_output(name, name_len, bc.name()); });
}
-int botan_block_cipher_query_keylen(botan_block_cipher_t cipher,
- size_t* out_minimum_keylength,
- size_t* out_maximum_keylength,
- size_t* out_keylength_modulo)
+int botan_block_cipher_get_keyspec(botan_block_cipher_t cipher,
+ size_t* out_minimum_keylength,
+ size_t* out_maximum_keylength,
+ size_t* out_keylength_modulo)
{
return BOTAN_FFI_DO(Botan::BlockCipher, cipher, bc, {
if(out_minimum_keylength)
diff --git a/src/lib/ffi/ffi_cipher.cpp b/src/lib/ffi/ffi_cipher.cpp
index 8dee35a81..e9adc8637 100644
--- a/src/lib/ffi/ffi_cipher.cpp
+++ b/src/lib/ffi/ffi_cipher.cpp
@@ -59,6 +59,21 @@ int botan_cipher_query_keylen(botan_cipher_t cipher,
});
}
+int botan_cipher_get_keyspec(botan_cipher_t cipher,
+ size_t* out_minimum_keylength,
+ size_t* out_maximum_keylength,
+ size_t* out_keylength_modulo)
+ {
+ return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, {
+ if(out_minimum_keylength)
+ *out_minimum_keylength = c.key_spec().minimum_keylength();
+ if(out_maximum_keylength)
+ *out_maximum_keylength = c.key_spec().maximum_keylength();
+ if(out_keylength_modulo)
+ *out_keylength_modulo = c.key_spec().keylength_multiple();
+ });
+ }
+
int botan_cipher_set_key(botan_cipher_t cipher,
const uint8_t* key, size_t key_len)
{
diff --git a/src/lib/ffi/ffi_mac.cpp b/src/lib/ffi/ffi_mac.cpp
index 4fbe171ec..b1b021720 100644
--- a/src/lib/ffi/ffi_mac.cpp
+++ b/src/lib/ffi/ffi_mac.cpp
@@ -67,10 +67,10 @@ int botan_mac_name(botan_mac_t mac, char* name, size_t* name_len)
return write_str_output(name, name_len, m.name()); });
}
-int botan_mac_query_keylen(botan_mac_t mac,
- size_t* out_minimum_keylength,
- size_t* out_maximum_keylength,
- size_t* out_keylength_modulo)
+int botan_mac_get_keyspec(botan_mac_t mac,
+ size_t* out_minimum_keylength,
+ size_t* out_maximum_keylength,
+ size_t* out_keylength_modulo)
{
return BOTAN_FFI_DO(Botan::MessageAuthenticationCode, mac, m, {
if(out_minimum_keylength)