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/tests/test_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/tests/test_ffi.cpp')
-rw-r--r-- | src/tests/test_ffi.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp index 45c4c8a5b..624b01032 100644 --- a/src/tests/test_ffi.cpp +++ b/src/tests/test_ffi.cpp @@ -341,6 +341,7 @@ class FFI_Unit_Tests : public Test results.push_back(ffi_test_ciphers_cbc()); results.push_back(ffi_test_ciphers_aead()); results.push_back(ffi_test_stream_ciphers()); + results.push_back(ffi_test_pkcs_hash_id()); #if defined(BOTAN_HAS_RSA) results.push_back(ffi_test_rsa(rng)); @@ -373,6 +374,32 @@ class FFI_Unit_Tests : public Test } private: + Test::Result ffi_test_pkcs_hash_id() + { + Test::Result result("FFI PKCS hash id"); + +#if defined(BOTAN_HAS_HASH_ID) + std::vector<uint8_t> hash_id(64); + size_t hash_id_len; + + hash_id_len = 3; // too short + TEST_FFI_RC(BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE, + botan_pkcs_hash_id, ("SHA-256", hash_id.data(), &hash_id_len)); + + result.test_eq("Expected SHA-256 PKCS hash id len", hash_id_len, 19); + + TEST_FFI_OK(botan_pkcs_hash_id, ("SHA-256", hash_id.data(), &hash_id_len)); + + result.test_eq("Expected SHA-256 PKCS hash id len", hash_id_len, 19); + + hash_id.resize(hash_id_len); + result.test_eq("Expected SHA_256 PKCS hash id", + hash_id, "3031300D060960864801650304020105000420"); +#endif + + return result; + } + Test::Result ffi_test_ciphers_cbc() { Test::Result result("FFI CBC cipher"); |