mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-06-07 14:46:51 +02:00
Merge branch 'PurpleI2P:openssl' into fuzzing-6
This commit is contained in:
commit
5e9f926048
25 changed files with 226 additions and 127 deletions
|
@ -13,7 +13,7 @@
|
|||
#define bit_AES (1 << 25)
|
||||
#endif
|
||||
|
||||
#if (defined(__GNUC__) && __GNUC__ < 5)
|
||||
#if defined(__GNUC__) && __GNUC__ < 6 && IS_X86
|
||||
#include <cpuid.h>
|
||||
#endif
|
||||
|
||||
|
@ -29,16 +29,16 @@ namespace cpu
|
|||
|
||||
inline bool cpu_support_aes()
|
||||
{
|
||||
#if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_IX86) || defined(__i386__))
|
||||
#if IS_X86
|
||||
#if defined(__clang__)
|
||||
# if (__clang_major__ >= 6)
|
||||
__builtin_cpu_init();
|
||||
# endif
|
||||
return __builtin_cpu_supports("aes");
|
||||
#elif (defined(__GNUC__) && __GNUC__ >= 5)
|
||||
#elif (defined(__GNUC__) && __GNUC__ >= 6)
|
||||
__builtin_cpu_init();
|
||||
return __builtin_cpu_supports("aes");
|
||||
#elif (defined(__GNUC__) && __GNUC__ < 5)
|
||||
#elif (defined(__GNUC__) && __GNUC__ < 6)
|
||||
int cpu_info[4];
|
||||
bool flag = false;
|
||||
__cpuid(0, cpu_info[0], cpu_info[1], cpu_info[2], cpu_info[3]);
|
||||
|
|
|
@ -9,6 +9,24 @@
|
|||
#ifndef LIBI2PD_CPU_H
|
||||
#define LIBI2PD_CPU_H
|
||||
|
||||
#if defined(_M_AMD64) || defined(__x86_64__) || defined(_M_IX86) || defined(__i386__)
|
||||
# define IS_X86 1
|
||||
# if defined(_M_AMD64) || defined(__x86_64__)
|
||||
# define IS_X86_64 1
|
||||
# else
|
||||
# define IS_X86_64 0
|
||||
# endif
|
||||
#else
|
||||
# define IS_X86 0
|
||||
# define IS_X86_64 0
|
||||
#endif
|
||||
|
||||
#if defined(__AES__) && !defined(_MSC_VER) && IS_X86
|
||||
# define SUPPORTS_AES 1
|
||||
#else
|
||||
# define SUPPORTS_AES 0
|
||||
#endif
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
namespace cpu
|
||||
|
|
|
@ -28,11 +28,6 @@
|
|||
#include "I2PEndian.h"
|
||||
#include "Log.h"
|
||||
|
||||
#if defined(__AES__) && !defined(_MSC_VER) && ((defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_IX86) || defined(__i386__)))
|
||||
#define SUPPORTS_AES 1
|
||||
#else
|
||||
#define SUPPORTS_AES 0
|
||||
#endif
|
||||
|
||||
namespace i2p
|
||||
{
|
||||
|
@ -165,7 +160,7 @@ namespace crypto
|
|||
|
||||
// DH/ElGamal
|
||||
|
||||
#if !defined(__x86_64__)
|
||||
#if !IS_X86_64
|
||||
const int ELGAMAL_SHORT_EXPONENT_NUM_BITS = 226;
|
||||
const int ELGAMAL_SHORT_EXPONENT_NUM_BYTES = ELGAMAL_SHORT_EXPONENT_NUM_BITS/8+1;
|
||||
#endif
|
||||
|
@ -367,7 +362,7 @@ namespace crypto
|
|||
BIGNUM * b1 = BN_CTX_get (ctx);
|
||||
BIGNUM * b = BN_CTX_get (ctx);
|
||||
// select random k
|
||||
#if (defined(_M_AMD64) || defined(__x86_64__))
|
||||
#if IS_X86_64
|
||||
BN_rand (k, ELGAMAL_FULL_EXPONENT_NUM_BITS, -1, 1); // full exponent for x64
|
||||
#else
|
||||
BN_rand (k, ELGAMAL_SHORT_EXPONENT_NUM_BITS, -1, 1); // short exponent of 226 bits
|
||||
|
@ -434,7 +429,7 @@ namespace crypto
|
|||
|
||||
void GenerateElGamalKeyPair (uint8_t * priv, uint8_t * pub)
|
||||
{
|
||||
#if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_IX86) || defined(__i386__)) || defined(_MSC_VER)
|
||||
#if IS_X86 || defined(_MSC_VER)
|
||||
RAND_bytes (priv, 256);
|
||||
#else
|
||||
// lower 226 bits (28 bytes and 2 bits) only. short exponent
|
||||
|
@ -1309,7 +1304,7 @@ namespace crypto
|
|||
CRYPTO_set_locking_callback (OpensslLockingCallback);*/
|
||||
if (precomputation)
|
||||
{
|
||||
#if (defined(_M_AMD64) || defined(__x86_64__))
|
||||
#if IS_X86_64
|
||||
g_ElggTable = new BIGNUM * [ELGAMAL_FULL_EXPONENT_NUM_BYTES][255];
|
||||
PrecalculateElggTable (g_ElggTable, ELGAMAL_FULL_EXPONENT_NUM_BYTES);
|
||||
#else
|
||||
|
@ -1324,7 +1319,7 @@ namespace crypto
|
|||
if (g_ElggTable)
|
||||
{
|
||||
DestroyElggTable (g_ElggTable,
|
||||
#if (defined(_M_AMD64) || defined(__x86_64__))
|
||||
#if IS_X86_64
|
||||
ELGAMAL_FULL_EXPONENT_NUM_BYTES
|
||||
#else
|
||||
ELGAMAL_SHORT_EXPONENT_NUM_BYTES
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2013-2022, The PurpleI2P Project
|
||||
* Copyright (c) 2013-2023, The PurpleI2P Project
|
||||
*
|
||||
* This file is part of Purple i2pd project and licensed under BSD3
|
||||
*
|
||||
|
@ -150,7 +150,7 @@ namespace crypto
|
|||
};
|
||||
|
||||
|
||||
#ifdef __AES__
|
||||
#if SUPPORTS_AES
|
||||
class ECBCryptoAESNI
|
||||
{
|
||||
public:
|
||||
|
@ -167,7 +167,7 @@ namespace crypto
|
|||
};
|
||||
#endif
|
||||
|
||||
#ifdef __AES__
|
||||
#if SUPPORTS_AES
|
||||
class ECBEncryption: public ECBCryptoAESNI
|
||||
#else
|
||||
class ECBEncryption
|
||||
|
@ -183,7 +183,7 @@ namespace crypto
|
|||
AES_KEY m_Key;
|
||||
};
|
||||
|
||||
#ifdef __AES__
|
||||
#if SUPPORTS_AES
|
||||
class ECBDecryption: public ECBCryptoAESNI
|
||||
#else
|
||||
class ECBDecryption
|
||||
|
|
|
@ -136,6 +136,14 @@ namespace fs {
|
|||
dataDir = (home != NULL && strlen(home) > 0) ? home : "";
|
||||
dataDir += "/Library/Application Support/" + appName;
|
||||
return;
|
||||
#elif defined(__HAIKU__)
|
||||
char *home = getenv("HOME");
|
||||
if (home != NULL && strlen(home) > 0) {
|
||||
dataDir = std::string(home) + "/config/settings/" + appName;
|
||||
} else {
|
||||
dataDir = "/tmp/" + appName;
|
||||
}
|
||||
return;
|
||||
#else /* other unix */
|
||||
#if defined(ANDROID)
|
||||
const char * ext = getenv("EXTERNAL_STORAGE");
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
#if defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
#include <sys/endian.h>
|
||||
|
||||
#elif defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__GLIBC__)
|
||||
#elif defined(__linux__) || defined(__FreeBSD_kernel__) || defined(__OpenBSD__) || defined(__GLIBC__) || defined(__HAIKU__)
|
||||
#include <endian.h>
|
||||
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
|
|
|
@ -833,8 +833,12 @@ namespace transport
|
|||
}
|
||||
}
|
||||
bool ipv4Testing = i2p::context.GetTesting ();
|
||||
if (!ipv4Testing)
|
||||
ipv4Testing = i2p::context.GetRouterInfo ().IsSSU2V4 () && (i2p::context.GetStatus() == eRouterStatusUnknown);
|
||||
bool ipv6Testing = i2p::context.GetTestingV6 ();
|
||||
// if still testing, repeat peer test
|
||||
if (!ipv6Testing)
|
||||
ipv6Testing = i2p::context.GetRouterInfo ().IsSSU2V6 () && (i2p::context.GetStatusV6() == eRouterStatusUnknown);
|
||||
// if still testing or unknown, repeat peer test
|
||||
if (ipv4Testing || ipv6Testing)
|
||||
PeerTest (ipv4Testing, ipv6Testing);
|
||||
m_PeerCleanupTimer->expires_from_now (boost::posix_time::seconds(3 * SESSION_CREATION_TIMEOUT));
|
||||
|
|
|
@ -27,6 +27,17 @@
|
|||
# include <AvailabilityMacros.h>
|
||||
#endif
|
||||
|
||||
#if defined(__HAIKU__)
|
||||
#include <gnu/pthread.h>
|
||||
#include <posix/pthread.h>
|
||||
#include <posix/sys/sockio.h>
|
||||
#include <posix/sys/ioctl.h>
|
||||
#ifndef _DEFAULT_SOURCE
|
||||
#define _DEFAULT_SOURCE
|
||||
#include <bsd/ifaddrs.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#define MAKE_VERSION_NUMBER(a,b,c) ((a*100+b)*100+c)
|
||||
|
||||
#define I2PD_VERSION_MAJOR 2
|
||||
#define I2PD_VERSION_MINOR 48
|
||||
#define I2PD_VERSION_MINOR 49
|
||||
#define I2PD_VERSION_MICRO 0
|
||||
#define I2PD_VERSION_PATCH 0
|
||||
#ifdef GITVER
|
||||
|
@ -33,7 +33,7 @@
|
|||
|
||||
#define I2P_VERSION_MAJOR 0
|
||||
#define I2P_VERSION_MINOR 9
|
||||
#define I2P_VERSION_MICRO 59
|
||||
#define I2P_VERSION_MICRO 60
|
||||
#define I2P_VERSION_PATCH 0
|
||||
#define I2P_VERSION MAKE_VERSION(I2P_VERSION_MAJOR, I2P_VERSION_MINOR, I2P_VERSION_MICRO)
|
||||
#define I2P_VERSION_NUMBER MAKE_VERSION_NUMBER(I2P_VERSION_MAJOR, I2P_VERSION_MINOR, I2P_VERSION_MICRO)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue