Nostro/interfaces/Nostro-Crypto.cppm
2026-10-06 15:39:17 +02:00

33 lines
No EOL
761 B
C++

//SPDX-License-Identifier: LGPL-3.0-only
//SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
module;
#ifdef NOSTRO_OPENSSL_ENABLED
#include <openssl/types.h>
#include <openssl/err.h>
#endif
export module Nostro:Crypto;
#ifdef NOSTRO_OPENSSL_ENABLED
import std;
export namespace Nostro::Crypto {
long ThrowOnOpenssl(long status);
template <typename T>
T* ThrowOnOpenssl(T* pointer) {
if(pointer == nullptr) {
ERR_print_errors_fp(stderr);
throw std::runtime_error("openssl error");
}
return pointer;
}
std::string SignBody(EVP_PKEY* privateKey, std::string_view body);
std::tuple<EVP_PKEY*, std::string> CreateKey();
EVP_PKEY* LoadKeyFromPem(std::string_view pem);
};
#endif