diff --git a/Crypto.cpp b/Crypto.cpp index 6b5fb7d6..42514857 100644 --- a/Crypto.cpp +++ b/Crypto.cpp @@ -270,8 +270,10 @@ namespace crypto { if (m_IsUpdated) { - bn2buf (m_DH->pub_key, m_PublicKey, 256); - BN_free (m_DH->pub_key); m_DH->pub_key = NULL; + const BIGNUM * priv_key, * pub_key; + DH_get0_key (m_DH, &pub_key, &priv_key); + bn2buf (pub_key, m_PublicKey, 256); + DH_set0_key (m_DH, NULL, NULL); m_IsUpdated= false; } return m_PublicKey; diff --git a/Crypto.h b/Crypto.h index 7d9a38d7..115fefda 100644 --- a/Crypto.h +++ b/Crypto.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include "Base.h" @@ -281,6 +282,8 @@ namespace crypto void InitCrypto (bool precomputation); void TerminateCrypto (); +} +} // take care about openssl version #include @@ -318,9 +321,10 @@ inline int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key) inline void DH_get0_key(const DH *dh, const BIGNUM **pub_key, const BIGNUM **priv_key) { *pub_key = dh->pub_key; *priv_key = dh->priv_key; } +inline int EVP_PKEY_base_id(const EVP_PKEY *pkey) + { return EVP_PKEY_type(pkey->type); } +inline RSA *EVP_PKEY_get0_RSA(EVP_PKEY *pkey) + { return pkey->pkey.rsa; } #endif -} -} - #endif diff --git a/Family.cpp b/Family.cpp index c1840e51..ce995a4a 100644 --- a/Family.cpp +++ b/Family.cpp @@ -40,7 +40,7 @@ namespace data if (family) family[0] = 0; } auto pkey = X509_get_pubkey (cert); - int keyType = EVP_PKEY_type(pkey->type); + int keyType = EVP_PKEY_base_id (pkey); switch (keyType) { case EVP_PKEY_DSA: diff --git a/Reseed.cpp b/Reseed.cpp index d8a265db..65de62b4 100644 --- a/Reseed.cpp +++ b/Reseed.cpp @@ -350,9 +350,11 @@ namespace data if (terminator) terminator[0] = 0; } // extract RSA key (we need n only, e = 65537) - RSA * key = X509_get_pubkey (cert)->pkey.rsa; + RSA * key = EVP_PKEY_get0_RSA (X509_get_pubkey (cert)); + const BIGNUM * n, * e, * d; + RSA_get0_key(key, &n, &e, &d); PublicKey value; - i2p::crypto::bn2buf (key->n, value, 512); + i2p::crypto::bn2buf (n, value, 512); if (cn) m_SigningKeys[cn] = value; else