LibCrypto: Convert SignedBigInteger::export_data to return a span

This brings it up to par with UnsignedBigInteger.
This commit is contained in:
Idan Horowitz 2025-08-05 02:45:43 +03:00 committed by Ali Mohammad Pur
commit 2a3b072d0e
Notes: github-actions[bot] 2025-08-05 07:10:37 +00:00
2 changed files with 5 additions and 5 deletions

View file

@ -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;
}

View file

@ -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;