mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 04:25:13 +00:00
LibCrypto: Move OpenSSL RAII helper methods out of line
This commit is contained in:
parent
977af95b5b
commit
559c5a7311
Notes:
github-actions[bot]
2025-01-13 16:02:04 +00:00
Author: https://github.com/devgianlu Commit: https://github.com/LadybirdBrowser/ladybird/commit/559c5a73115 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3234
2 changed files with 20 additions and 12 deletions
|
@ -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());
|
||||
|
|
|
@ -88,20 +88,14 @@ class OpenSSL_BN {
|
|||
OPENSSL_WRAPPER_CLASS(OpenSSL_BN, BIGNUM, BN);
|
||||
|
||||
public:
|
||||
static ErrorOr<OpenSSL_BN> create()
|
||||
{
|
||||
return OpenSSL_BN(OPENSSL_TRY_PTR(BN_new()));
|
||||
}
|
||||
static ErrorOr<OpenSSL_BN> create();
|
||||
};
|
||||
|
||||
class OpenSSL_PKEY {
|
||||
OPENSSL_WRAPPER_CLASS(OpenSSL_PKEY, EVP_PKEY, EVP_PKEY);
|
||||
|
||||
public:
|
||||
static ErrorOr<OpenSSL_PKEY> create()
|
||||
{
|
||||
return OpenSSL_PKEY(OPENSSL_TRY_PTR(EVP_PKEY_new()));
|
||||
}
|
||||
static ErrorOr<OpenSSL_PKEY> create();
|
||||
};
|
||||
|
||||
class OpenSSL_PKEY_CTX {
|
||||
|
@ -112,10 +106,7 @@ class OpenSSL_MD_CTX {
|
|||
OPENSSL_WRAPPER_CLASS(OpenSSL_MD_CTX, EVP_MD_CTX, EVP_MD_CTX);
|
||||
|
||||
public:
|
||||
static ErrorOr<OpenSSL_MD_CTX> create()
|
||||
{
|
||||
return OpenSSL_MD_CTX(OPENSSL_TRY_PTR(EVP_MD_CTX_new()));
|
||||
}
|
||||
static ErrorOr<OpenSSL_MD_CTX> create();
|
||||
};
|
||||
|
||||
#undef OPENSSL_WRAPPER_CLASS
|
||||
|
|
Loading…
Add table
Reference in a new issue