From 433f3e554b6573ab6cc7b85ac5f3e9140695ca01 Mon Sep 17 00:00:00 2001 From: user <60944239+wipedlifepotato@users.noreply.github.com> Date: Sun, 7 Jun 2026 13:55:31 +0000 Subject: [PATCH] PQ: preproccessor magic --- libi2pd/Crypto.h | 5 +++++ libi2pd/PostQuantum.cpp | 14 +++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/libi2pd/Crypto.h b/libi2pd/Crypto.h index 3b9dfb93..db3ef5cd 100644 --- a/libi2pd/Crypto.h +++ b/libi2pd/Crypto.h @@ -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 { diff --git a/libi2pd/PostQuantum.cpp b/libi2pd/PostQuantum.cpp index d69871d2..db2e79e6 100644 --- a/libi2pd/PostQuantum.cpp +++ b/libi2pd/PostQuantum.cpp @@ -15,9 +15,12 @@ #include #if defined(LIBRESSL_VERSION_NUMBER) - // only for openbsd + #warning like you use libressl #include - #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