aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests
diff options
context:
space:
mode:
authorRenĂ© Korthaus <[email protected]>2017-09-08 13:26:38 +0200
committerRenĂ© Korthaus <[email protected]>2017-09-08 13:26:38 +0200
commit808952a620af1ed9068bb17b68ed5e58e4eec69d (patch)
tree62ca7779c1e871011f57da3dca0e50b52f2c438c /src/tests
parent51f8edb0cb83c75bdf3818d7e88cac87502b4d31 (diff)
Fix loading of plaintext PKCS#8 private keys
We fixed this in the C++ API in GH #381, but apparently not in ffi. Also adds the missing tests.
Diffstat (limited to 'src/tests')
-rw-r--r--src/tests/test_ffi.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/tests/test_ffi.cpp b/src/tests/test_ffi.cpp
index 33be07cdf..c0b3de808 100644
--- a/src/tests/test_ffi.cpp
+++ b/src/tests/test_ffi.cpp
@@ -981,6 +981,11 @@ class FFI_Unit_Tests : public Test
result.test_gte("Reasonable size", privkey.size(), 32);
+ // reimport exported private key
+ botan_privkey_t copy;
+ TEST_FFI_OK(botan_privkey_load, (&copy, rng, privkey.data(), privkey.size(), nullptr));
+ botan_privkey_destroy(copy);
+
// Now again for PEM
privkey_len = 0;
@@ -990,6 +995,9 @@ class FFI_Unit_Tests : public Test
privkey.resize(privkey_len);
TEST_FFI_OK(botan_privkey_export, (priv, privkey.data(), &privkey_len, BOTAN_PRIVKEY_EXPORT_FLAG_PEM));
+ TEST_FFI_OK(botan_privkey_load, (&copy, rng, privkey.data(), privkey.size(), nullptr));
+ botan_privkey_destroy(copy);
+
// export private key encrypted
privkey_len = 0;
TEST_FFI_RC(BOTAN_FFI_ERROR_INSUFFICIENT_BUFFER_SPACE, botan_privkey_export_encrypted_pbkdf_iter, (priv, nullptr,
@@ -1001,7 +1009,7 @@ class FFI_Unit_Tests : public Test
TEST_FFI_OK(botan_privkey_export_encrypted_pbkdf_iter, (priv, privkey.data(), &privkey_len, rng, "password", pbkdf_iter,
"", "", BOTAN_PRIVKEY_EXPORT_FLAG_DER));
- botan_privkey_t copy;
+ // reimport encrypted private key
botan_privkey_load(&copy, rng, privkey.data(), privkey.size(), "password");
botan_privkey_destroy(copy);
@@ -1025,10 +1033,9 @@ class FFI_Unit_Tests : public Test
result.test_gte("Reasonable KDF iters", pbkdf_iters_out, 1000);
privkey.resize(privkey_len);
- botan_privkey_load(&copy, rng, privkey.data(), privkey.size(), "password");
+ TEST_FFI_OK(botan_privkey_load, (&copy, rng, privkey.data(), privkey.size(), "password"));
botan_privkey_destroy(copy);
-
// calculate fingerprint
size_t strength = 0;
TEST_FFI_OK(botan_pubkey_estimated_strength, (pub, &strength));