Browse Source

initialize m_Pkey

pull/1277/head
orignal 6 years ago
parent
commit
8a987af244
  1. 8
      libi2pd/Crypto.cpp

8
libi2pd/Crypto.cpp

@ -283,6 +283,7 @@ namespace crypto
{ {
#if OPENSSL_X25519 #if OPENSSL_X25519
m_Ctx = EVP_PKEY_CTX_new_id (NID_X25519, NULL); m_Ctx = EVP_PKEY_CTX_new_id (NID_X25519, NULL);
m_Pkey = nullptr;
#else #else
m_Ctx = BN_CTX_new (); m_Ctx = BN_CTX_new ();
#endif #endif
@ -305,8 +306,7 @@ namespace crypto
{ {
#if OPENSSL_X25519 #if OPENSSL_X25519
EVP_PKEY_CTX_free (m_Ctx); EVP_PKEY_CTX_free (m_Ctx);
if (m_Pkey) if (m_Pkey) EVP_PKEY_free (m_Pkey);
EVP_PKEY_free (m_Pkey);
#else #else
BN_CTX_free (m_Ctx); BN_CTX_free (m_Ctx);
#endif #endif
@ -315,7 +315,11 @@ namespace crypto
void X25519Keys::GenerateKeys () void X25519Keys::GenerateKeys ()
{ {
#if OPENSSL_X25519 #if OPENSSL_X25519
if (m_Pkey)
{
EVP_PKEY_free (m_Pkey);
m_Pkey = nullptr; m_Pkey = nullptr;
}
EVP_PKEY_keygen_init (m_Ctx); EVP_PKEY_keygen_init (m_Ctx);
EVP_PKEY_keygen (m_Ctx, &m_Pkey); EVP_PKEY_keygen (m_Ctx, &m_Pkey);
EVP_PKEY_CTX_free (m_Ctx); EVP_PKEY_CTX_free (m_Ctx);

Loading…
Cancel
Save