security: Add wrapper for public/private key in transformation

Change-Id: I6610cccc8bb20b4e9e227895cf24b595a6e13698
Refs: #3009, #3010
diff --git a/src/security/detail/openssl-helper.cpp b/src/security/detail/openssl-helper.cpp
index ce51d1b..3a7140d 100644
--- a/src/security/detail/openssl-helper.cpp
+++ b/src/security/detail/openssl-helper.cpp
@@ -36,6 +36,44 @@
   }
 }
 
+EvpPkey::EvpPkey()
+  : m_key(nullptr)
+{
+}
+
+EvpPkey::~EvpPkey()
+{
+  EVP_PKEY_free(m_key);
+}
+
+EvpPkeyCtx::EvpPkeyCtx(EVP_PKEY* key)
+  : m_ctx(EVP_PKEY_CTX_new(key, nullptr))
+{
+  BOOST_ASSERT(m_ctx != nullptr);
+}
+
+EvpPkeyCtx::EvpPkeyCtx(int id)
+  : m_ctx(EVP_PKEY_CTX_new_id(id, nullptr))
+{
+  BOOST_ASSERT(m_ctx != nullptr);
+}
+
+EvpPkeyCtx::~EvpPkeyCtx()
+{
+  EVP_PKEY_CTX_free(m_ctx);
+}
+
+Bio::Bio(BIO_METHOD* method)
+  : m_bio(BIO_new(method))
+{
+  BOOST_ASSERT(m_bio != nullptr);
+}
+
+Bio::~Bio()
+{
+  BIO_free_all(m_bio);
+}
+
 } // namespace detail
 } // namespace security
 } // namespace ndn
diff --git a/src/security/detail/openssl-helper.hpp b/src/security/detail/openssl-helper.hpp
index e9e5900..d74bcf6 100644
--- a/src/security/detail/openssl-helper.hpp
+++ b/src/security/detail/openssl-helper.hpp
@@ -32,6 +32,68 @@
 const EVP_MD*
 toDigestEvpMd(DigestAlgorithm algo);
 
+class EvpPkey
+{
+public:
+  EvpPkey();
+
+  ~EvpPkey();
+
+  EVP_PKEY*
+  get() const
+  {
+    return m_key;
+  }
+
+  EVP_PKEY**
+  operator&()
+  {
+    return &m_key;
+  }
+
+private:
+  EVP_PKEY* m_key;
+};
+
+class EvpPkeyCtx
+{
+public:
+  explicit
+  EvpPkeyCtx(EVP_PKEY* key);
+
+  explicit
+  EvpPkeyCtx(int id);
+
+  ~EvpPkeyCtx();
+
+  EVP_PKEY_CTX*
+  get() const
+  {
+    return m_ctx;
+  }
+
+private:
+  EVP_PKEY_CTX* m_ctx;
+};
+
+class Bio
+{
+public:
+  explicit
+  Bio(BIO_METHOD* method);
+
+  ~Bio();
+
+  BIO*
+  get() const
+  {
+    return m_bio;
+  }
+
+private:
+  BIO* m_bio;
+};
+
 } // namespace detail
 } // namespace security
 } // namespace ndn