aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Wyatt <[email protected]>2017-04-30 22:03:58 -0400
committerDaniel Wyatt <[email protected]>2017-04-30 22:03:58 -0400
commit832f10eb1792aeedf5ab2970a9889fe4b10375a3 (patch)
treecba46da5e1cfa828179792c2e72a7ac99130fd11
parent29cc6bebe132a34f882d450b35a69bf71bb3e27b (diff)
Add FFI botan_hash_block_size.
-rw-r--r--src/lib/ffi/ffi.cpp5
-rw-r--r--src/lib/ffi/ffi.h8
-rw-r--r--src/tests/test_ffi.cpp5
3 files changed, 18 insertions, 0 deletions
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp
index 42b01be62..8b4b4028f 100644
--- a/src/lib/ffi/ffi.cpp
+++ b/src/lib/ffi/ffi.cpp
@@ -828,6 +828,11 @@ int botan_hash_output_length(botan_hash_t hash, size_t* out)
return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { *out = h.output_length(); });
}
+int botan_hash_block_size(botan_hash_t hash, size_t* out)
+ {
+ return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { *out = h.hash_block_size(); });
+ }
+
int botan_hash_clear(botan_hash_t hash)
{
return BOTAN_FFI_DO(Botan::HashFunction, hash, h, { h.clear(); });
diff --git a/src/lib/ffi/ffi.h b/src/lib/ffi/ffi.h
index 8fb7ca832..5638810f9 100644
--- a/src/lib/ffi/ffi.h
+++ b/src/lib/ffi/ffi.h
@@ -233,6 +233,14 @@ BOTAN_DLL int botan_hash_init(botan_hash_t* hash, const char* hash_name, uint32_
BOTAN_DLL int botan_hash_output_length(botan_hash_t hash, size_t* output_length);
/**
+* Writes the block size of the hash function to *block_size
+* @param hash hash object
+* @param output_length output buffer to hold the hash function output length
+* @return 0 on success, a negative value on failure
+*/
+BOTAN_DLL int botan_hash_block_size(botan_hash_t hash, size_t* block_size);
+
+/**
* Send more input to the hash function
* @param hash hash object
* @param in input buffer
diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp
index d5ddace04..7d18eb6c7 100644
--- a/src/tests/test_ffi.cpp
+++ b/src/tests/test_ffi.cpp
@@ -106,6 +106,11 @@ class FFI_Unit_Tests : public Test
result.test_eq("hash name", std::string(namebuf), "SHA-256");
}
*/
+ size_t block_size;
+ if (TEST_FFI_OK(botan_hash_block_size, (hash, &block_size)))
+ {
+ result.test_eq("hash block size", block_size, 64);
+ }
size_t output_len;
if(TEST_FFI_OK(botan_hash_output_length, (hash, &output_len)))