mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 03:57:15 +02:00
LibCrypto: Replace {Unsigned,Signed}BigInteger impl with LibTomMath
Replace the implementation of maths in `UnsignedBigInteger` and `SignedBigInteger` with LibTomMath. This gives benefits in terms of less code to maintain, correctness and speed. These changes also remove now-unsued methods and improve the error propagation for functions allocating lots of memory. Additionally, the new implementation is always trimmed and won't have dangling zeros when exporting it.
This commit is contained in:
committed by
Jelle Raaijmakers
parent
915c6fdcf8
commit
4b3715ccba
Notes:
github-actions[bot]
2025-05-23 09:58:22 +00:00
Author: https://github.com/devgianlu Commit: https://github.com/LadybirdBrowser/ladybird/commit/4b3715ccba3 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4507 Reviewed-by: https://github.com/gmta ✅
@@ -96,10 +96,9 @@ WebIDL::ExceptionOr<void> RsaKeyAlgorithm::set_public_exponent(::Crypto::Unsigne
|
||||
auto& realm = this->realm();
|
||||
auto& vm = this->vm();
|
||||
|
||||
auto bytes = TRY_OR_THROW_OOM(vm, ByteBuffer::create_uninitialized(exponent.trimmed_byte_length()));
|
||||
auto bytes = TRY_OR_THROW_OOM(vm, ByteBuffer::create_uninitialized(exponent.byte_length()));
|
||||
|
||||
bool const remove_leading_zeroes = true;
|
||||
auto data_size = exponent.export_data(bytes.span(), remove_leading_zeroes);
|
||||
auto data_size = exponent.export_data(bytes.span());
|
||||
auto data_slice_be = bytes.bytes().slice(bytes.size() - data_size, data_size);
|
||||
|
||||
// The BigInteger typedef from the WebCrypto spec requires the bytes in the Uint8Array be ordered in Big Endian
|
||||
|
||||
Reference in New Issue
Block a user