LibCrypto: Move OpenSSL RAII helper methods out of line

This commit is contained in:
devgianlu 2025-01-12 17:20:03 +01:00 committed by Ali Mohammad Pur
commit 559c5a7311
Notes: github-actions[bot] 2025-01-13 16:02:04 +00:00
2 changed files with 20 additions and 12 deletions

View file

@ -6,10 +6,27 @@
#include <AK/ByteBuffer.h>
#include <LibCrypto/OpenSSL.h>
#include <openssl/bn.h>
#include <openssl/evp.h>
namespace Crypto {
ErrorOr<OpenSSL_BN> OpenSSL_BN::create()
{
return OpenSSL_BN(OPENSSL_TRY_PTR(BN_new()));
}
ErrorOr<OpenSSL_PKEY> OpenSSL_PKEY::create()
{
return OpenSSL_PKEY(OPENSSL_TRY_PTR(EVP_PKEY_new()));
}
ErrorOr<OpenSSL_MD_CTX> OpenSSL_MD_CTX::create()
{
return OpenSSL_MD_CTX(OPENSSL_TRY_PTR(EVP_MD_CTX_new()));
}
ErrorOr<OpenSSL_BN> unsigned_big_integer_to_openssl_bignum(UnsignedBigInteger const& integer)
{
auto bn = TRY(OpenSSL_BN::create());