mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-02 15:46:33 +00:00
LibCrypto: Convert SignedBigInteger::export_data to return a span
This brings it up to par with UnsignedBigInteger.
This commit is contained in:
parent
660a499223
commit
2a3b072d0e
Notes:
github-actions[bot]
2025-08-05 07:10:37 +00:00
Author: https://github.com/IdanHo
Commit: 2a3b072d0e
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
2 changed files with 5 additions and 5 deletions
|
@ -97,11 +97,11 @@ SignedBigInteger::~SignedBigInteger()
|
|||
mp_clear(&m_mp);
|
||||
}
|
||||
|
||||
size_t SignedBigInteger::export_data(Bytes data) const
|
||||
Bytes SignedBigInteger::export_data(Bytes data) const
|
||||
{
|
||||
size_t written = 0;
|
||||
MP_MUST(mp_to_sbin(&m_mp, data.data(), data.size(), &written));
|
||||
return written;
|
||||
return data.slice(0, written);
|
||||
}
|
||||
|
||||
ErrorOr<SignedBigInteger> SignedBigInteger::from_base(u16 N, StringView str)
|
||||
|
@ -364,8 +364,8 @@ u32 SignedBigInteger::hash() const
|
|||
return *m_hash;
|
||||
|
||||
auto buffer = MUST(ByteBuffer::create_zeroed(byte_length()));
|
||||
auto length = export_data(buffer);
|
||||
m_hash = string_hash(reinterpret_cast<char const*>(buffer.data()), length);
|
||||
auto result = export_data(buffer);
|
||||
m_hash = string_hash(reinterpret_cast<char const*>(result.data()), result.size());
|
||||
return *m_hash;
|
||||
}
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
[[nodiscard]] static SignedBigInteger import_data(StringView data) { return import_data(reinterpret_cast<u8 const*>(data.characters_without_null_termination()), data.length()); }
|
||||
[[nodiscard]] static SignedBigInteger import_data(u8 const* ptr, size_t length) { return SignedBigInteger(ptr, length); }
|
||||
|
||||
size_t export_data(Bytes) const;
|
||||
[[nodiscard]] Bytes export_data(Bytes) const;
|
||||
|
||||
[[nodiscard]] static ErrorOr<SignedBigInteger> from_base(u16 N, StringView str);
|
||||
[[nodiscard]] ErrorOr<String> to_base(u16 N) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue