mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-22 16:09:23 +00:00
LibCrypto: Convert UnsignedBigInteger::export_data to return a span
This helps make callers only use the slice of the output buffer that was written to. As part of updating the callers of the API several bugs were fixed and useless code paths were removed: - The exported data is not host-endianess dependent (always big endian) - The exported data does not contain leading zeros - The output buffer is only written up to the result's size
This commit is contained in:
parent
15cee5cc15
commit
660a499223
Notes:
github-actions[bot]
2025-08-05 07:10:42 +00:00
Author: https://github.com/IdanHo
Commit: 660a499223
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5708
Reviewed-by: https://github.com/alimpfard
Reviewed-by: https://github.com/gmta
Reviewed-by: https://github.com/trflynn89
8 changed files with 45 additions and 59 deletions
|
@ -116,9 +116,8 @@ ErrorOr<String> base64_url_uint_encode(::Crypto::UnsignedBigInteger integer)
|
|||
// octet), which is "AA".
|
||||
|
||||
auto bytes = TRY(ByteBuffer::create_uninitialized(integer.byte_length()));
|
||||
auto data_size = integer.export_data(bytes.span());
|
||||
auto data_slice_be = bytes.bytes().slice(bytes.size() - data_size, data_size);
|
||||
return TRY(encode_base64url(data_slice_be, AK::OmitPadding::Yes));
|
||||
auto result = integer.export_data(bytes.span());
|
||||
return TRY(encode_base64url(result, AK::OmitPadding::Yes));
|
||||
}
|
||||
|
||||
WebIDL::ExceptionOr<ByteBuffer> base64_url_bytes_decode(JS::Realm& realm, String const& base64_url_string)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue