diff options
author | René Korthaus <[email protected]> | 2017-09-08 13:26:38 +0200 |
---|---|---|
committer | René Korthaus <[email protected]> | 2017-09-08 13:26:38 +0200 |
commit | 808952a620af1ed9068bb17b68ed5e58e4eec69d (patch) | |
tree | 62ca7779c1e871011f57da3dca0e50b52f2c438c /src/tests/test_ffi.cpp | |
parent | 51f8edb0cb83c75bdf3818d7e88cac87502b4d31 (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/test_ffi.cpp')
-rw-r--r-- | src/tests/test_ffi.cpp | 13 |
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, (©, 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, (©, 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(©, 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(©, rng, privkey.data(), privkey.size(), "password"); + TEST_FFI_OK(botan_privkey_load, (©, 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)); |