mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-23 13:24:20 +00:00
OpenSSL 1.1 for EVP_PKEY
This commit is contained in:
parent
3562ac1438
commit
6377631ae7
@ -270,8 +270,10 @@ namespace crypto
|
|||||||
{
|
{
|
||||||
if (m_IsUpdated)
|
if (m_IsUpdated)
|
||||||
{
|
{
|
||||||
bn2buf (m_DH->pub_key, m_PublicKey, 256);
|
const BIGNUM * priv_key, * pub_key;
|
||||||
BN_free (m_DH->pub_key); m_DH->pub_key = NULL;
|
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;
|
m_IsUpdated= false;
|
||||||
}
|
}
|
||||||
return m_PublicKey;
|
return m_PublicKey;
|
||||||
|
10
Crypto.h
10
Crypto.h
@ -10,6 +10,7 @@
|
|||||||
#include <openssl/ecdsa.h>
|
#include <openssl/ecdsa.h>
|
||||||
#include <openssl/rsa.h>
|
#include <openssl/rsa.h>
|
||||||
#include <openssl/sha.h>
|
#include <openssl/sha.h>
|
||||||
|
#include <openssl/evp.h>
|
||||||
#include <openssl/rand.h>
|
#include <openssl/rand.h>
|
||||||
|
|
||||||
#include "Base.h"
|
#include "Base.h"
|
||||||
@ -281,6 +282,8 @@ namespace crypto
|
|||||||
|
|
||||||
void InitCrypto (bool precomputation);
|
void InitCrypto (bool precomputation);
|
||||||
void TerminateCrypto ();
|
void TerminateCrypto ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// take care about openssl version
|
// take care about openssl version
|
||||||
#include <openssl/opensslv.h>
|
#include <openssl/opensslv.h>
|
||||||
@ -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)
|
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; }
|
{ *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
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,7 +40,7 @@ namespace data
|
|||||||
if (family) family[0] = 0;
|
if (family) family[0] = 0;
|
||||||
}
|
}
|
||||||
auto pkey = X509_get_pubkey (cert);
|
auto pkey = X509_get_pubkey (cert);
|
||||||
int keyType = EVP_PKEY_type(pkey->type);
|
int keyType = EVP_PKEY_base_id (pkey);
|
||||||
switch (keyType)
|
switch (keyType)
|
||||||
{
|
{
|
||||||
case EVP_PKEY_DSA:
|
case EVP_PKEY_DSA:
|
||||||
|
@ -350,9 +350,11 @@ namespace data
|
|||||||
if (terminator) terminator[0] = 0;
|
if (terminator) terminator[0] = 0;
|
||||||
}
|
}
|
||||||
// extract RSA key (we need n only, e = 65537)
|
// 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;
|
PublicKey value;
|
||||||
i2p::crypto::bn2buf (key->n, value, 512);
|
i2p::crypto::bn2buf (n, value, 512);
|
||||||
if (cn)
|
if (cn)
|
||||||
m_SigningKeys[cn] = value;
|
m_SigningKeys[cn] = value;
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user