diff options
author | Jack Lloyd <[email protected]> | 2017-05-18 11:42:36 -0400 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-05-18 11:42:36 -0400 |
commit | 2c21c5ca62062f82d160b8ef8d0e386e9d38f111 (patch) | |
tree | 67079d158f02e9794d864b3ad473d4b630fcb399 /src/lib/ffi/ffi.cpp | |
parent | 2f53dc937f33816445c7646b88e0ad826d197482 (diff) |
Add botan_pkcs_hash_id to FFI
Extend EMSA_PKCS1v15_Raw to optionally take a hash function for which
the PKCS hash id is prefixed to the message as usual. This allows signing
a message using PKCSv1.5 padding where the hash is provided externally.
Diffstat (limited to 'src/lib/ffi/ffi.cpp')
-rw-r--r-- | src/lib/ffi/ffi.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/lib/ffi/ffi.cpp b/src/lib/ffi/ffi.cpp index 94e83122e..a48a438be 100644 --- a/src/lib/ffi/ffi.cpp +++ b/src/lib/ffi/ffi.cpp @@ -73,6 +73,10 @@ #include <botan/bcrypt.h> #endif +#if defined(BOTAN_HAS_HASH_ID) + #include <botan/hash_id.h> +#endif + #if defined(BOTAN_HAS_TLS) #include <botan/tls_client.h> #include <botan/tls_server.h> @@ -2249,6 +2253,23 @@ int botan_x509_cert_allowed_usage(botan_x509_cert_t cert, unsigned int key_usage }); } +int botan_pkcs_hash_id(const char* hash_name, uint8_t pkcs_id[], size_t* pkcs_id_len) + { +#if defined(BOTAN_HAS_HASH_ID) + try + { + const std::vector<uint8_t> hash_id = Botan::pkcs_hash_id(hash_name); + return write_output(pkcs_id, pkcs_id_len, hash_id.data(), hash_id.size()); + } + catch(...) + { + return BOTAN_FFI_ERROR_EXCEPTION_THROWN; + } +#else + return BOTAN_FFI_ERROR_NOT_IMPLEMENTED; +#endif + } + int botan_mceies_decrypt(botan_privkey_t mce_key_obj, const char* aead, const uint8_t ct[], size_t ct_len, |