mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-10-24 04:29:03 +01:00
Improve OpenBSD support
This commit is contained in:
parent
d10a7fe8e5
commit
80840b761e
8 changed files with 149 additions and 22 deletions
|
|
@ -11,18 +11,18 @@
|
|||
#include <vector>
|
||||
#include <mutex>
|
||||
#include <memory>
|
||||
#include "Crypto.h"
|
||||
#include <openssl/dh.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/crypto.h>
|
||||
#include "TunnelBase.h"
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/kdf.h>
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
#include <openssl/param_build.h>
|
||||
#include <openssl/core_names.h>
|
||||
#endif
|
||||
#include "CPU.h"
|
||||
#include "Crypto.h"
|
||||
#include "Ed25519.h"
|
||||
#include "I2PEndian.h"
|
||||
#include "Log.h"
|
||||
|
|
@ -148,7 +148,7 @@ namespace crypto
|
|||
#define dsap GetCryptoConstants ().dsap
|
||||
#define dsaq GetCryptoConstants ().dsaq
|
||||
#define dsag GetCryptoConstants ().dsag
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
EVP_PKEY * CreateDSA (BIGNUM * pubKey, BIGNUM * privKey)
|
||||
{
|
||||
EVP_PKEY * pkey = nullptr;
|
||||
|
|
|
|||
|
|
@ -24,14 +24,22 @@
|
|||
#include <openssl/rand.h>
|
||||
#include <openssl/opensslv.h>
|
||||
|
||||
#if defined(LIBRESSL_VERSION_NUMBER)
|
||||
#define I2PD_OPENSSL_GE_3 0
|
||||
#define I2PD_OPENSSL_GE_3_5 0
|
||||
#else
|
||||
#define I2PD_OPENSSL_GE_3 (OPENSSL_VERSION_NUMBER >= 0x030000000L)
|
||||
#define I2PD_OPENSSL_GE_3_5 (OPENSSL_VERSION_NUMBER >= 0x030500000L)
|
||||
#endif
|
||||
|
||||
#include "Base.h"
|
||||
#include "Tag.h"
|
||||
|
||||
// recognize openssl version and features
|
||||
#if (!defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER != 0x030000000)) // 3.0.0, regression in SipHash, not implemented in LibreSSL
|
||||
#if (!defined(LIBRESSL_VERSION_NUMBER) && (OPENSSL_VERSION_NUMBER != 0x030000000L)) // 3.0.0, regression in SipHash, not implemented in LibreSSL
|
||||
# define OPENSSL_SIPHASH 1
|
||||
#endif
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030500000) // 3.5.0
|
||||
#if I2PD_OPENSSL_GE_3_5
|
||||
# define OPENSSL_PQ 1
|
||||
#endif
|
||||
|
||||
|
|
@ -42,7 +50,7 @@ namespace crypto
|
|||
bool bn2buf (const BIGNUM * bn, uint8_t * buf, size_t len);
|
||||
|
||||
// DSA
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
EVP_PKEY * CreateDSA (BIGNUM * pubKey = nullptr, BIGNUM * privKey = nullptr);
|
||||
#else
|
||||
DSA * CreateDSA ();
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ namespace data
|
|||
if (pkey)
|
||||
{
|
||||
int curve = 0;
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
char groupName[20];
|
||||
if (EVP_PKEY_get_group_name(pkey, groupName, sizeof(groupName), NULL) == 1)
|
||||
curve = OBJ_txt2nid (groupName);
|
||||
|
|
@ -157,7 +157,7 @@ namespace data
|
|||
SSL * ssl = SSL_new (ctx);
|
||||
EVP_PKEY * pkey = SSL_get_privatekey (ssl);
|
||||
int curve = 0;
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
char groupName[20];
|
||||
if (EVP_PKEY_get_group_name(pkey, groupName, sizeof(groupName), NULL) == 1)
|
||||
curve = OBJ_txt2nid (groupName);
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@
|
|||
#include <boost/algorithm/string.hpp>
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/err.h>
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#include "Crypto.h"
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
#include <openssl/core_names.h>
|
||||
#endif
|
||||
#include <zlib.h>
|
||||
|
||||
#include "Crypto.h"
|
||||
#include "I2PEndian.h"
|
||||
#include "Reseed.h"
|
||||
#include "FS.h"
|
||||
|
|
@ -485,7 +485,7 @@ namespace data
|
|||
// extract RSA key (we need n only, e = 65537)
|
||||
EVP_PKEY * pubKey = X509_get_pubkey (cert);
|
||||
const BIGNUM * n = nullptr;
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
BIGNUM * n1 = BN_new ();
|
||||
if (EVP_PKEY_get_bn_param (pubKey, OSSL_PKEY_PARAM_RSA_N, &n1) > 0)
|
||||
n = n1;
|
||||
|
|
@ -505,7 +505,7 @@ namespace data
|
|||
}
|
||||
else
|
||||
LogPrint (eLogError, "Reseed: Can't extract RSA key from ", filename);
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
BN_free (n1);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,8 +7,9 @@
|
|||
*/
|
||||
|
||||
#include <memory>
|
||||
#include "Crypto.h"
|
||||
#include <openssl/evp.h>
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
#include <openssl/core_names.h>
|
||||
#include <openssl/param_build.h>
|
||||
#endif
|
||||
|
|
@ -19,7 +20,7 @@ namespace i2p
|
|||
{
|
||||
namespace crypto
|
||||
{
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
DSAVerifier::DSAVerifier ():
|
||||
m_PublicKey (nullptr)
|
||||
{
|
||||
|
|
@ -172,7 +173,7 @@ namespace crypto
|
|||
}
|
||||
#endif
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
ECDSAVerifier::ECDSAVerifier (int curve, size_t keyLen, const EVP_MD * hash):
|
||||
m_Curve(curve), m_KeyLen (keyLen), m_Hash (hash), m_PublicKey (nullptr)
|
||||
{
|
||||
|
|
@ -405,7 +406,7 @@ namespace crypto
|
|||
LogPrint (eLogError, "EdDSA signing key is not set");
|
||||
}
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000)
|
||||
#if I2PD_OPENSSL_GE_3
|
||||
static const OSSL_PARAM EDDSA25519phParams[] =
|
||||
{
|
||||
OSSL_PARAM_utf8_string ("instance", (char *)"Ed25519ph", 9),
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ namespace crypto
|
|||
|
||||
private:
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
EVP_PKEY * m_PublicKey;
|
||||
#else
|
||||
DSA * m_PublicKey;
|
||||
|
|
@ -82,7 +82,7 @@ namespace crypto
|
|||
|
||||
private:
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
EVP_PKEY * m_PrivateKey;
|
||||
#else
|
||||
DSA * m_PrivateKey;
|
||||
|
|
@ -96,7 +96,7 @@ namespace crypto
|
|||
constexpr size_t ECDSAP384_KEY_LENGTH = 96;
|
||||
constexpr size_t ECDSAP521_KEY_LENGTH = 132;
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
class ECDSAVerifier: public Verifier
|
||||
{
|
||||
public:
|
||||
|
|
@ -377,7 +377,7 @@ namespace crypto
|
|||
EVP_PKEY * GetPkey () const { return m_Pkey; };
|
||||
};
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
class EDDSA25519phVerifier: public EDDSA25519Verifier
|
||||
{
|
||||
public:
|
||||
|
|
@ -423,7 +423,7 @@ namespace crypto
|
|||
EDDSA25519SignerCompat * m_Fallback;
|
||||
};
|
||||
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||
#if I2PD_OPENSSL_GE_3 // since 3.0.0
|
||||
class EDDSA25519phSigner: public EDDSA25519Signer
|
||||
{
|
||||
public:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue