mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +00:00
LibCrypto: Add methods to convert OpenSSL BN <-> UnsignedBigInteger
These methods allow to convert between OpenSSL big numbers and ours.
This commit is contained in:
parent
7b38923144
commit
130f890497
Notes:
github-actions[bot]
2025-01-12 00:14:29 +00:00
Author: https://github.com/devgianlu
Commit: 130f890497
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3225
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/gmta ✅
3 changed files with 46 additions and 0 deletions
|
@ -8,7 +8,9 @@
|
|||
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Format.h>
|
||||
#include <LibCrypto/BigInt/UnsignedBigInteger.h>
|
||||
|
||||
#include <openssl/bn.h>
|
||||
#include <openssl/err.h>
|
||||
#include <openssl/evp.h>
|
||||
|
||||
|
@ -82,6 +84,16 @@ private: \
|
|||
\
|
||||
openssl_type* m_ptr { nullptr };
|
||||
|
||||
class OpenSSL_BN {
|
||||
OPENSSL_WRAPPER_CLASS(OpenSSL_BN, BIGNUM, BN);
|
||||
|
||||
public:
|
||||
static ErrorOr<OpenSSL_BN> create()
|
||||
{
|
||||
return OpenSSL_BN(OPENSSL_TRY_PTR(BN_new()));
|
||||
}
|
||||
};
|
||||
|
||||
class OpenSSL_PKEY {
|
||||
OPENSSL_WRAPPER_CLASS(OpenSSL_PKEY, EVP_PKEY, EVP_PKEY);
|
||||
|
||||
|
@ -104,4 +116,7 @@ public:
|
|||
|
||||
#undef OPENSSL_WRAPPER_CLASS
|
||||
|
||||
ErrorOr<OpenSSL_BN> unsigned_big_integer_to_openssl_bignum(UnsignedBigInteger const& integer);
|
||||
ErrorOr<UnsignedBigInteger> openssl_bignum_to_unsigned_big_integer(OpenSSL_BN const& bn);
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue