1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:24:57 +00:00

LibCrypto: Add observers for the *byte* length of UnsignedBigInteger

When calling the export_data method, it's a bit of a hassle to remember
that the caller's buffer needs to be the length() * Word.
This commit is contained in:
Andrew Kaster 2024-03-08 15:38:01 -07:00 committed by Andrew Kaster
parent 139ff3552c
commit 008c89edde

View file

@ -99,6 +99,9 @@ public:
// The "trimmed length" is the number of words after trimming leading zeroed words
[[nodiscard]] size_t trimmed_length() const;
[[nodiscard]] size_t byte_length() const { return length() * sizeof(Word); }
[[nodiscard]] size_t trimmed_byte_length() const { return trimmed_length() * sizeof(Word); }
void clamp_to_trimmed_length();
void resize_with_leading_zeros(size_t num_words);