PQ: preproccessor magic

This commit is contained in:
user committed 2026-06-07 13:55:31 +00:00
1 parent ade8e0e10b
commit 433f3e554b
2 files changed
+14 -5

No files matched your search

+5
View File
@@ -34,6 +34,11 @@
#if (OPENSSL_VERSION_NUMBER >= 0x030500000) // 3.5.0
# define OPENSSL_PQ 1
#endif
#ifdef LIBRESSL_VERSION_NUMBER
#if (defined(LIBRESSL_VERSION_NUMBER) && (LIBRESSL_VERSION_NUMBER >= 0x4030200fL))
# define OPENSSL_PQ
#endif
#endif
namespace i2p
{
+9 -5
View File
@@ -15,9 +15,12 @@
#include <openssl/core_names.h>
#if defined(LIBRESSL_VERSION_NUMBER)
// only for openbsd
#warning like you use libressl
#include<openssl/mlkem.h>
#define is_openbsd ""
#define is_libre ""
#error libressl
#else
#warning like you use openssl
#endif
namespace i2p
@@ -31,7 +34,7 @@ namespace crypto
}
MLKEMKEYS::FreeKeys(void)
{
#ifndef is_openbsd
#ifndef is_libre
if (m_Pkey) EVP_PKEY_free (m_Pkey);
#else
if (m_Pkey) MLKEM_private_key_free (m_Pkey);
@@ -45,7 +48,7 @@ namespace crypto
void MLKEMKeys::GenerateKeys ()
{
FreeKeys();
#ifndef is_openbsd
#ifndef is_libre
m_Pkey = EVP_PKEY_Q_keygen(NULL, NULL, m_Name.c_str ());
#else
m_Pkey = MLKEM_private_key_new(MLKEM768_RANK);
@@ -263,5 +266,6 @@ namespace crypto
}
}
}
#else
#warning You are compile without PQ support
#endif