Commit af86cf57 authored by johan's avatar johan
Browse files

Initial Commit

parents
############################################################################
# CMakeLists.txt
# Copyright (C) 2022 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
cmake_minimum_required(VERSION 3.2)
# CMP0077 policy is required by Flexisip build. Remove it once the CMake required
# version is higer or equal to 3.13.
if(NOT CMAKE_VERSION VERSION_LESS 3.13)
cmake_policy(SET CMP0077 NEW)
endif()
project(postquantumcryptoengine VERSION 5.2.0)
set(POSTQUANTUMCRYPTOENGINE_VERSION "${PROJECT_VERSION}")
set(POSTQUANTUMCRYPTOENGINE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(POSTQUANTUMCRYPTOENGINE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(POSTQUANTUMCRYPTOENGINE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(POSTQUANTUMCRYPTOENGINE_SO_VERSION 1)
option(ENABLE_SHARED "Build shared library." ON)
option(ENABLE_STATIC "Build static library." OFF)
option(ENABLE_STRICT "Pass strict flags to the compiler" ON)
option(ENABLE_TESTS "Enable compilation of tests" ON)
option(ENABLE_PACKAGE_SOURCE "Create 'package_source' target for source archive making (CMake >= 3.11)" OFF)
# Hidden non-cache options:
# * DISABLE_BC_PACKAGE_SEARCH: skip find_package() for every BC package
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_EXTENSIONS NO)
include(GNUInstallDirs)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
if(NOT CPACK_GENERATOR AND NOT CMAKE_INSTALL_RPATH AND CMAKE_INSTALL_PREFIX)
set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR})
message(STATUS "Setting install rpath to ${CMAKE_INSTALL_RPATH}")
endif()
if(NOT DISABLE_BC_PACKAGE_SEARCH)
find_package(bctoolbox 0.0.3 REQUIRED OPTIONAL_COMPONENTS tester CONFIG)
endif()
find_package(liboqs REQUIRED CONFIG)
include_directories(
include
src
${CMAKE_CURRENT_BINARY_DIR}
)
set(POSTQUANTUMCRYPTOENGINE_CPPFLAGS ${BCTOOLBOX_CPPFLAGS})
if(ENABLE_STATIC)
set(BCTBX_STATIC 1)
endif()
if(POSTQUANTUMCRYPTOENGINE_CPPFLAGS)
list(REMOVE_DUPLICATES POSTQUANTUMCRYPTOENGINE_CPPFLAGS)
add_definitions(${POSTQUANTUMCRYPTOENGINE_CPPFLAGS})
endif()
bc_init_compilation_flags(STRICT_OPTIONS_CPP STRICT_OPTIONS_C STRICT_OPTIONS_CXX ENABLE_STRICT)
if(CMAKE_VERSION VERSION_LESS 3.1 AND NOT APPLE AND NOT MSVC)
list(APPEND STRICT_OPTIONS_CXX "-std=c++11")
endif()
set(EXPORT_TARGETS_NAME "postquantumcryptoengine")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/config.h PROPERTIES GENERATED ON)
add_definitions("-DHAVE_CONFIG_H")
add_subdirectory(include)
add_subdirectory(src)
if(ENABLE_TESTS)
add_subdirectory(tester)
endif()
if(ENABLE_PACKAGE_SOURCE)
add_subdirectory(build)
endif()
include(CMakePackageConfigHelpers)
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_TARGETS_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY AnyNewerVersion
)
configure_package_config_file(cmake/postquantumcryptoengineConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_TARGETS_NAME}Config.cmake"
INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION}
NO_SET_AND_CHECK_MACRO
)
install(EXPORT ${EXPORT_TARGETS_NAME}Targets
FILE "${EXPORT_TARGETS_NAME}Targets.cmake"
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_TARGETS_NAME}Config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${EXPORT_TARGETS_NAME}ConfigVersion.cmake"
DESTINATION ${CONFIG_PACKAGE_LOCATION}
)
[![pipeline status](https://gitlab.linphone.org/BC/private/postquantumcryptoengine/badges/master/pipeline.svg)](https://gitlab.linphone.org/BC/private/postquantumcryptoengine/commits/master)
PostQuantumCryptoEngine
=======================
Extension to the bctoolbox lib providing Post Quantum Cryptography
Depends
-------
- **liboqs[1]**: implementation of a collection of Post Quantum algorithms
- **bctoolbox[2]**
To compile
----------
cmake . -DCMAKE_INSTALL_PREFIX=<install prefix> -DCMAKE_PREFIX_PATH=<search prefix>
make
make install
To make an rpm package
----------------------
cmake . -DCMAKE_INSTALL_PREFIX=/usr -DCPACK_GENERATOR="RPM"
make package
Options
-------
- `CMAKE_INSTALL_PREFIX=<string>`: install prefix.
- `CMAKE_PREFIX_PATH=<string>`: search path prefix for dependencies e.g. mbedtls.
- `ENABLE_SHARED=NO`: do not build the shared libraries.
- `ENABLE_STATIC=NO`: do not build the static libraries.
- `ENABLE_STRICT=NO`: do not build with strict compilator flags e.g. `-Wall -Werror`.
- `ENABLE_TESTS=NO`: do not build testing binaries.
Note for packagers
------------------
Our CMake scripts may automatically add some paths into research paths of generated binaries.
To ensure that the installed binaries are striped of any rpath, use `-DCMAKE_SKIP_INSTALL_RPATH=ON`
while you invoke cmake.
--------------------
- [1] <https://gitlab.linphone.org/BC/public/external/liboqs>
- [2] <https://gitlab.linphone.org/BC/public/bctoolbox>
############################################################################
# postquantumcryptoengineConfig.cmake
# Copyright (C) 2015 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
#
# Config file for the postquantumcryptoengine package.
# It defines the following variables:
#
# postquantumcryptoengine_FOUND - system has postquantumcryptoengine
# postquantumcryptoengine_INCLUDE_DIRS - the postquantumcryptoengine include directory
# postquantumcryptoengine_LIBRARIES - The libraries needed to use postquantumcryptoengine
# postquantumcryptoengine_CPPFLAGS - The compilation flags needed to use postquantumcryptoengine
@PACKAGE_INIT@
set(postquantumcryptoengine_TARGETNAME postquantumcryptoengine)
include("${CMAKE_CURRENT_LIST_DIR}/${postquantumcryptoengine_TARGETNAME}Targets.cmake")
if(@ENABLE_SHARED@)
set(postquantumcryptoengine_LIBRARIES ${postquantumcryptoengine_TARGETNAME})
else()
if(TARGET ${postquantumcryptoengine_TARGETNAME})
get_target_property(postquantumcryptoengine_LIBRARIES ${postquantumcryptoengine_TARGETNAME} LOCATION)
get_target_property(postquantumcryptoengine_LINK_LIBRARIES ${postquantumcryptoengine_TARGETNAME} INTERFACE_LINK_LIBRARIES)
if(postquantumcryptoengine_LINK_LIBRARIES)
list(APPEND postquantumcryptoengine_LIBRARIES ${postquantumcryptoengine_LINK_LIBRARIES})
endif()
endif()
endif()
get_target_property(postquantumcryptoengine_INCLUDE_DIRS ${postquantumcryptoengine_TARGETNAME} INTERFACE_INCLUDE_DIRECTORIES)
set(postquantumcryptoengine_CPPFLAGS @postquantumcryptoengine_CPPFLAGS@)
set(postquantumcryptoengine_FOUND 1)
/***************************************************************************
* config.h.cmake
* Copyright (C) 2014 Belledonne Communications, Grenoble France
*
****************************************************************************
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
****************************************************************************/
#cmakedefine HAVE_OQS 1
#cmakedefine BCTBX_STATIC
############################################################################
# CMakeLists.txt
# Copyright (C) 2016 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
############################################################################
set(HEADER_FILES
crypto.h
crypto.hh
)
set(POSTQUANTUMCRYPTOENGINE_HEADER_FILES )
foreach(HEADER_FILE ${HEADER_FILES})
list(APPEND POSTQUANTUMCRYPTOENGINE_HEADER_FILES "${CMAKE_CURRENT_LIST_DIR}/postquantumcryptoengine/${HEADER_FILE}")
endforeach()
set(POSTQUANTUMCRYPTOENGINE_HEADER_FILES ${POSTQUANTUMCRYPTOENGINE_HEADER_FILES} PARENT_SCOPE)
install(FILES ${POSTQUANTUMCRYPTOENGINE_HEADER_FILES}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/postquantumcryptoengine
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
/*
* Copyright (c) 2020 Belledonne Communications SARL.
*
* This file is part of postquantumcryptoengine.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef POSTQUANTUMCRYPTO_H
#define POSTQUANTUMCRYPTO_H
#ifdef _MSC_VER
#ifdef BCTBXPQ_STATIC
#define BCTBXPQ_EXPORT
#else /* BCTBXPQ_STATIC */
#ifdef BCTBXPQ_EXPORTS
#define BCTBXPQ_EXPORT __declspec(dllexport)
#else /* BCTBXPQ_EXPORTS */
#define BCTBXPQ_EXPORT __declspec(dllimport)
#endif /* BCTBXPQ_EXPORTS */
#endif /* BCTBXPQ_STATIC */
#ifndef BCTBXPQ_DEPRECATED
#define BCTBXPQ_DEPRECATED __declspec(deprecated)
#endif /* BCTBXPQ_DEPRECATED */
#else /* _MSC_VER*/
#define BCTBXPQ_EXPORT __attribute__ ((visibility ("default")))
#ifndef BCTBXPQ_DEPRECATED
#define BCTBXPQ_DEPRECATED __attribute__ ((deprecated))
#endif /* BCTBXPQ_DEPRECATED */
#endif /* _MSC_VER*/
#ifdef __cplusplus
extern "C" {
#endif
BCTBXPQ_EXPORT uint32_t bctbxpq_key_agreement_algo_list(void);
#ifdef __cplusplus
}
#endif
#endif // POSTQUANTUMCRYPTO_H
/*
* Copyright (c) 2020 Belledonne Communications SARL.
*
* This file is part of postquantumcryptoengine.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef POSTQUANTUMCRYPTO_HH
#define POSTQUANTUMCRYPTO_HH
#include <vector>
#include <memory>
#include <string>
#include <list>
#include "bctoolbox/crypto.hh"
#include "postquantumcryptoengine/crypto.h"
namespace bctoolbox {
/************************ KEM interface ************************/
/**
* @brief The KEM vitual class
* Declares all functions that KEM algorithms need
*/
class KEM {
public:
virtual ~KEM() = default;
virtual size_t get_skSize() const noexcept = 0;
virtual size_t get_pkSize() const noexcept = 0;
virtual size_t get_ctSize() const noexcept = 0;
virtual size_t get_ssSize() const noexcept = 0;
virtual int crypto_kem_keypair(std::vector<uint8_t> &pk, std::vector<uint8_t> &sk) const noexcept = 0;
virtual int crypto_kem_enc(std::vector<uint8_t> &ct, std::vector<uint8_t> &ss, const std::vector<uint8_t> &pk) const noexcept = 0;
virtual int crypto_kem_dec(std::vector<uint8_t> &ss, const std::vector<uint8_t> &ct, const std::vector<uint8_t> &sk) const noexcept = 0;
};
/**
* @brief The ECDH_KEM class extends the KEM class
* Declares all attributs that ECDH KEM algorithms need
* Implements all functions that ECDH KEM algorithms need
*/
class ECDH_KEM : public KEM {
protected:
uint8_t id; /**< Id of the key agreement algorithm defined in the RFC https://datatracker.ietf.org/doc/html/rfc9180#section-7.1 */
int name; /**< Name of the key agreement algorithm */
int hash_id; /**< Id of the hash algorithm */
public:
int crypto_kem_keypair(std::vector<uint8_t> &pk, std::vector<uint8_t> &sk) const noexcept override;
/* INFO : enc and dec return the derivation of shared secret | REF : https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-hpke-12 */
int crypto_kem_enc(std::vector<uint8_t> &ct, std::vector<uint8_t> &ss, const std::vector<uint8_t> &pk) const noexcept override;
int crypto_kem_dec(std::vector<uint8_t> &ss, const std::vector<uint8_t> &ct, const std::vector<uint8_t> &sk) const noexcept override;
};
/**
* @brief The K25519 class extends the ECDH_KEM class
* Initialises all key size parameters
*/
class K25519 : public ECDH_KEM {
public:
K25519(int hash_id); /**< hash_id param represents the id of the hash algorithm used in the secret derivation */
constexpr static size_t skSize = BCTBX_ECDH_X25519_PRIVATE_SIZE;
constexpr static size_t pkSize = BCTBX_ECDH_X25519_PUBLIC_SIZE;
constexpr static size_t ctSize = BCTBX_ECDH_X25519_PUBLIC_SIZE;
constexpr static size_t ssSize = BCTBX_ECDH_X25519_PUBLIC_SIZE;
size_t get_skSize() const noexcept override;
size_t get_pkSize() const noexcept override;
size_t get_ctSize() const noexcept override;
size_t get_ssSize() const noexcept override;
};
/**
* @brief The K448 class extends the ECDH_KEM class
* Initialises all key size parameters
*/
class K448 : public ECDH_KEM {
public:
K448(int hash_id); /**< hash_id param represents the id of the hash algorithm used in the secret derivation */
constexpr static size_t skSize = BCTBX_ECDH_X448_PRIVATE_SIZE;
constexpr static size_t pkSize = BCTBX_ECDH_X448_PUBLIC_SIZE;
constexpr static size_t ctSize = BCTBX_ECDH_X448_PUBLIC_SIZE;
constexpr static size_t ssSize = BCTBX_ECDH_X448_PUBLIC_SIZE;
size_t get_skSize() const noexcept override;
size_t get_pkSize() const noexcept override;
size_t get_ctSize() const noexcept override;
size_t get_ssSize() const noexcept override;
};
/**
* @brief The KYBER512 class extends the KEM class
* Initialises all key size parameters
* Implements all functions that KYBER512 algorithm needs
*/
class KYBER512 : public KEM {
public:
KYBER512() = default;
constexpr static size_t skSize = 1632;
constexpr static size_t pkSize = 800;
constexpr static size_t ctSize = 768;
constexpr static size_t ssSize = 32;
size_t get_skSize() const noexcept override;
size_t get_pkSize() const noexcept override;
size_t get_ctSize() const noexcept override;
size_t get_ssSize() const noexcept override;
int crypto_kem_keypair(std::vector<uint8_t> &pk, std::vector<uint8_t> &sk) const noexcept override;
int crypto_kem_enc(std::vector<uint8_t> &ct, std::vector<uint8_t> &ss, const std::vector<uint8_t> &pk) const noexcept override;
int crypto_kem_dec(std::vector<uint8_t> &ss, const std::vector<uint8_t> &ct, const std::vector<uint8_t> &sk) const noexcept override;
};
/**
* @brief The KYBER768 class extends the KEM class
* Initialises all key size parameters
* Implements all functions that KYBER768 algorithm needs
*/
class KYBER768 : public KEM {
public:
KYBER768() = default;
constexpr static size_t skSize = 2400;
constexpr static size_t pkSize = 1184;
constexpr static size_t ctSize = 1088;
constexpr static size_t ssSize = 32;
size_t get_skSize() const noexcept override;
size_t get_pkSize() const noexcept override;
size_t get_ctSize() const noexcept override;
size_t get_ssSize() const noexcept override;
int crypto_kem_keypair(std::vector<uint8_t> &pk, std::vector<uint8_t> &sk) const noexcept override;
int crypto_kem_enc(std::vector<uint8_t> &ct, std::vector<uint8_t> &ss, const std::vector<uint8_t> &pk) const noexcept override;
int crypto_kem_dec(std::vector<uint8_t> &ss, const std::vector<uint8_t> &ct, const std::vector<uint8_t> &sk) const noexcept override;
};
/**
* @brief The KYBER1024 class extends the KEM class
* Initialises all key size parameters
* Implements all functions that KYBER1024 algorithm needs
*/
class KYBER1024 : public KEM {
public:
KYBER1024() = default;
constexpr static size_t skSize = 3168;
constexpr static size_t pkSize = 1568;
constexpr static size_t ctSize = 1568;
constexpr static size_t ssSize = 32;
size_t get_skSize() const noexcept override;
size_t get_pkSize() const noexcept override;
size_t get_ctSize() const noexcept override;
size_t get_ssSize() const noexcept override;
int crypto_kem_keypair(std::vector<uint8_t> &pk, std::vector<uint8_t> &sk) const noexcept override;
int crypto_kem_enc(std::vector<uint8_t> &ct, std::vector<uint8_t> &ss, const std::vector<uint8_t> &pk) const noexcept override;
int crypto_kem_dec(std::vector<uint8_t> &ss, const std::vector<uint8_t> &ct, const std::vector<uint8_t> &sk) const noexcept override;
};
/**
* @brief The SIKE434 class extends the KEM class
* Initialises all key size parameters
* Implements all functions that SIKE434 algorithm needs
*/
class SIKE434 : public KEM {
public:
SIKE434() = default;
constexpr static size_t skSize = 374;
constexpr static size_t pkSize = 330;
constexpr static size_t ctSize = 346;
constexpr static size_t ssSize = 16;
size_t get_skSize() const noexcept override;
size_t get_pkSize() const noexcept override;
size_t get_ctSize() const noexcept override;
size_t get_ssSize() const noexcept override;
int crypto_kem_keypair(std::vector<uint8_t> &pk, std::vector<uint8_t> &sk) const noexcept override;
int crypto_kem_enc(std::vector<uint8_t> &ct, std::vector<uint8_t> &ss, const std::vector<uint8_t> &pk) const noexcept override;
int crypto_kem_dec(std::vector<uint8_t> &ss, const std::vector<uint8_t> &ct, const std::vector<uint8_t> &sk) const noexcept override;
};
/**
* @brief The SIKE610 class extends the KEM class
* Initialises all key size parameters
* Implements all functions that SIKE610 algorithm needs
*/
class SIKE610 : public KEM {
public:
SIKE610() = default;
constexpr static size_t skSize = 524;
constexpr static size_t pkSize = 462;
constexpr static size_t ctSize = 486;
constexpr static size_t ssSize = 24;
size_t get_skSize() const noexcept override;
size_t get_pkSize() const noexcept override;
size_t get_ctSize() const noexcept override;
size_t get_ssSize() const noexcept override;
int crypto_kem_keypair(std::vector<uint8_t> &pk, std::vector<uint8_t> &sk) const noexcept override;
int crypto_kem_enc(std::vector<uint8_t> &ct, std::vector<uint8_t> &ss, const std::vector<uint8_t> &pk) const noexcept override;
int crypto_kem_dec(std::vector<uint8_t> &ss, const std::vector<uint8_t> &ct, const std::vector<uint8_t> &sk) const noexcept override;
};
/**
* @brief The SIKE751 class extends the KEM class
* Initialises all key size parameters
* Implements all functions that SIKE751 algorithm needs
*/
class SIKE751 : public KEM {
public:
SIKE751() = default;
constexpr static size_t skSize = 644;
constexpr static size_t pkSize = 564;
constexpr static size_t ctSize = 596;
constexpr static size_t ssSize = 32;
size_t get_skSize() const noexcept override;
size_t get_pkSize() const noexcept override;
size_t get_ctSize() const noexcept override;
size_t get_ssSize() const noexcept override;
int crypto_kem_keypair(std::vector<uint8_t> &pk, std::vector<uint8_t> &sk) const noexcept override;
int crypto_kem_enc(std::vector<uint8_t> &ct, std::vector<uint8_t> &ss, const std::vector<uint8_t> &pk) const noexcept override;
int crypto_kem_dec(std::vector<uint8_t> &ss, const std::vector<uint8_t> &ct, const std::vector<uint8_t> &sk) const noexcept override;
};
/**
* @brief The HYBRID_KEM class extends the KEM class
* Represents a hybrid KEM
* The KEM functions encapsulate, decapsulate several keys from several key exchange algorithms and combine them using the N-combiner
*/
class HYBRID_KEM : public KEM {
private:
std::list<std::shared_ptr<KEM>> algo; /**< List of the algorithms used in the hybrid KEM */
int hash_id; /**< Id of the hash algorithm */
public:
HYBRID_KEM(const std::list<std::shared_ptr<KEM>> &, int); /**< the int in param is the hash id */
size_t get_skSize() const noexcept override;
size_t get_pkSize() const noexcept override;
size_t get_ctSize() const noexcept override;
size_t get_ssSize() const noexcept override;
int crypto_kem_keypair(std::vector<uint8_t> &pk, std::vector<uint8_t> &sk) const noexcept override;
int crypto_kem_enc(std::vector<uint8_t> &ct, std::vector<uint8_t> &ss, const std::vector<uint8_t> &pk) const noexcept override;
int crypto_kem_dec(std::vector<uint8_t> &ss, const std::vector<uint8_t> &