mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 01:29:17 +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: 559c5a7311
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 <AK/ByteBuffer.h>
|
||||||
#include <LibCrypto/OpenSSL.h>
|
#include <LibCrypto/OpenSSL.h>
|
||||||
|
|
||||||
|
#include <openssl/bn.h>
|
||||||
#include <openssl/evp.h>
|
#include <openssl/evp.h>
|
||||||
|
|
||||||
namespace Crypto {
|
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)
|
ErrorOr<OpenSSL_BN> unsigned_big_integer_to_openssl_bignum(UnsignedBigInteger const& integer)
|
||||||
{
|
{
|
||||||
auto bn = TRY(OpenSSL_BN::create());
|
auto bn = TRY(OpenSSL_BN::create());
|
||||||
|
|
|
@ -88,20 +88,14 @@ class OpenSSL_BN {
|
||||||
OPENSSL_WRAPPER_CLASS(OpenSSL_BN, BIGNUM, BN);
|
OPENSSL_WRAPPER_CLASS(OpenSSL_BN, BIGNUM, BN);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ErrorOr<OpenSSL_BN> create()
|
static ErrorOr<OpenSSL_BN> create();
|
||||||
{
|
|
||||||
return OpenSSL_BN(OPENSSL_TRY_PTR(BN_new()));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpenSSL_PKEY {
|
class OpenSSL_PKEY {
|
||||||
OPENSSL_WRAPPER_CLASS(OpenSSL_PKEY, EVP_PKEY, EVP_PKEY);
|
OPENSSL_WRAPPER_CLASS(OpenSSL_PKEY, EVP_PKEY, EVP_PKEY);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ErrorOr<OpenSSL_PKEY> create()
|
static ErrorOr<OpenSSL_PKEY> create();
|
||||||
{
|
|
||||||
return OpenSSL_PKEY(OPENSSL_TRY_PTR(EVP_PKEY_new()));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class OpenSSL_PKEY_CTX {
|
class OpenSSL_PKEY_CTX {
|
||||||
|
@ -112,10 +106,7 @@ class OpenSSL_MD_CTX {
|
||||||
OPENSSL_WRAPPER_CLASS(OpenSSL_MD_CTX, EVP_MD_CTX, EVP_MD_CTX);
|
OPENSSL_WRAPPER_CLASS(OpenSSL_MD_CTX, EVP_MD_CTX, EVP_MD_CTX);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ErrorOr<OpenSSL_MD_CTX> create()
|
static ErrorOr<OpenSSL_MD_CTX> create();
|
||||||
{
|
|
||||||
return OpenSSL_MD_CTX(OPENSSL_TRY_PTR(EVP_MD_CTX_new()));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#undef OPENSSL_WRAPPER_CLASS
|
#undef OPENSSL_WRAPPER_CLASS
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue