mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-06-21 21:38:20 +02:00
use EVP functions to extract RSA keys if openssl 3
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / buster (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / buster (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/amd64 (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
This commit is contained in:
parent
660dbd27d1
commit
d2296f81ad
1 changed files with 27 additions and 8 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2013-2024, The PurpleI2P Project
|
* Copyright (c) 2013-2025, The PurpleI2P Project
|
||||||
*
|
*
|
||||||
* This file is part of Purple i2pd project and licensed under BSD3
|
* This file is part of Purple i2pd project and licensed under BSD3
|
||||||
*
|
*
|
||||||
|
@ -14,6 +14,9 @@
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
|
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||||
|
#include <openssl/core_names.h>
|
||||||
|
#endif
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
#include "Crypto.h"
|
#include "Crypto.h"
|
||||||
|
@ -480,15 +483,31 @@ 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)
|
||||||
const RSA * key = EVP_PKEY_get0_RSA (X509_get_pubkey (cert));
|
EVP_PKEY * pubKey = X509_get_pubkey (cert);
|
||||||
const BIGNUM * n, * e, * d;
|
const BIGNUM * n = nullptr;
|
||||||
|
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||||
|
BIGNUM * n1 = BN_new ();
|
||||||
|
if (EVP_PKEY_get_bn_param (pubKey, OSSL_PKEY_PARAM_RSA_N, &n1) > 0)
|
||||||
|
n = n1;
|
||||||
|
#else
|
||||||
|
const RSA * key = EVP_PKEY_get0_RSA (pubKey);
|
||||||
|
const BIGNUM * e, * d;
|
||||||
RSA_get0_key(key, &n, &e, &d);
|
RSA_get0_key(key, &n, &e, &d);
|
||||||
PublicKey value;
|
#endif
|
||||||
i2p::crypto::bn2buf (n, value, 512);
|
if (n)
|
||||||
if (cn)
|
{
|
||||||
m_SigningKeys[cn] = value;
|
PublicKey value;
|
||||||
|
i2p::crypto::bn2buf (n, value, 512);
|
||||||
|
if (cn)
|
||||||
|
m_SigningKeys[cn] = value;
|
||||||
|
else
|
||||||
|
LogPrint (eLogError, "Reseed: Can't find CN field in ", filename);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogError, "Reseed: Can't find CN field in ", filename);
|
LogPrint (eLogError, "Reseed: Can't extract RSA key from ", filename);
|
||||||
|
#if (OPENSSL_VERSION_NUMBER >= 0x030000000) // since 3.0.0
|
||||||
|
BN_free (n1);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
SSL_free (ssl);
|
SSL_free (ssl);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue