aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ffi
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-08-17 17:09:01 -0400
committerJack Lloyd <[email protected]>2018-08-17 17:09:08 -0400
commitcc96212bc6168fac918f071730bffbef7c0059c5 (patch)
tree9b1fdc8db0ed0a7d6ec60109e7f0a77764ba086f /src/lib/ffi
parentb01c0b06da185e0ed5a3cd549c5dafe2ee159f79 (diff)
Add botan_cipher_reset to FFI
Diffstat (limited to 'src/lib/ffi')
-rw-r--r--src/lib/ffi/ffi.h10
-rw-r--r--src/lib/ffi/ffi_cipher.cpp5
2 files changed, 15 insertions, 0 deletions
diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h
index 19e04ce4d..ed3e0bb71 100644
--- a/src/lib/ffi/ffi.h
+++ b/src/lib/ffi/ffi.h
@@ -467,6 +467,16 @@ BOTAN_PUBLIC_API(2,0) int botan_cipher_set_key(botan_cipher_t cipher,
const uint8_t* key, size_t key_len);
/**
+* Reset the message specific state for this cipher.
+* Without resetting the keys, this resets the nonce, and any state
+* associated with any message bits that have been processed so far.
+*
+* It is conceptually equivalent to calling botan_cipher_clear followed
+* by botan_cipher_set_key with the original key.
+*/
+BOTAN_PUBLIC_API(2,8) int botan_cipher_reset(botan_cipher_t cipher);
+
+/**
* Set the associated data. Will fail if cipher is not an AEAD
*/
BOTAN_PUBLIC_API(2,0) int botan_cipher_set_associated_data(botan_cipher_t cipher,
diff --git a/src/lib/ffi/ffi_cipher.cpp b/src/lib/ffi/ffi_cipher.cpp
index e9adc8637..ec6893405 100644
--- a/src/lib/ffi/ffi_cipher.cpp
+++ b/src/lib/ffi/ffi_cipher.cpp
@@ -41,6 +41,11 @@ int botan_cipher_clear(botan_cipher_t cipher)
return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, { c.clear(); });
}
+int botan_cipher_reset(botan_cipher_t cipher)
+ {
+ return BOTAN_FFI_DO(Botan::Cipher_Mode, cipher, c, { c.reset(); });
+ }
+
int botan_cipher_output_length(botan_cipher_t cipher, size_t in_len, size_t* out_len)
{
if(out_len == nullptr)