diff options
author | René Korthaus <[email protected]> | 2018-05-29 20:50:39 +0200 |
---|---|---|
committer | René Korthaus <[email protected]> | 2018-07-04 23:17:40 +0200 |
commit | 0328e3c42dd47070f731d6eef47d91a4a6178cd8 (patch) | |
tree | aeb75931cf2d47e62bf48354fed37432319049f4 /src/tests/test_ffi.cpp | |
parent | 74a369bd77b43849a216c688af4bc85468291973 (diff) |
Add RSA PKCS#1 key load and export functions to ffi
Diffstat (limited to 'src/tests/test_ffi.cpp')
-rw-r--r-- | src/tests/test_ffi.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp index 9eb7847a2..45a5f0139 100644 --- a/src/tests/test_ffi.cpp +++ b/src/tests/test_ffi.cpp @@ -1313,6 +1313,23 @@ class FFI_Unit_Tests final : public Test botan_mp_destroy(e); botan_mp_destroy(n); + size_t pkcs1_len = 0; + TEST_FFI_RC(BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE, + botan_privkey_rsa_get_privkey, (loaded_privkey, nullptr, &pkcs1_len, BOTAN_PRIVKEY_EXPORT_FLAG_DER)); + + std::vector<uint8_t> pkcs1(pkcs1_len); + TEST_FFI_OK(botan_privkey_rsa_get_privkey, (loaded_privkey, pkcs1.data(), &pkcs1_len, BOTAN_PRIVKEY_EXPORT_FLAG_DER)); + + botan_privkey_t privkey_from_pkcs1; + TEST_FFI_OK(botan_privkey_load_rsa_pkcs1, (&privkey_from_pkcs1, pkcs1.data(), pkcs1_len)); + TEST_FFI_OK(botan_privkey_destroy, (privkey_from_pkcs1)); + + pkcs1_len = 0; + TEST_FFI_RC(BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE, + botan_privkey_rsa_get_privkey, (loaded_privkey, nullptr, &pkcs1_len, BOTAN_PRIVKEY_EXPORT_FLAG_PEM)); + pkcs1.resize(pkcs1_len); + TEST_FFI_OK(botan_privkey_rsa_get_privkey, (loaded_privkey, pkcs1.data(), &pkcs1_len, BOTAN_PRIVKEY_EXPORT_FLAG_PEM)); + char namebuf[32] = { 0 }; size_t name_len = sizeof(namebuf); if(TEST_FFI_OK(botan_pubkey_algo_name, (loaded_pubkey, namebuf, &name_len))) |