33 lines
761 B
Text
33 lines
761 B
Text
|
|
//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
|