mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 13:57:35 +00:00
LibCrypto: Avoid overly big allocs in intermediate ModularPower results
If we don't limit the sizes of the intermediate results, they will grow indefinitely, causing each iteration to take longer and longer (in both memcpy time, and algorithm runtime). While calculating the trimmed length is fairly expensive, it's a small cost to pay for uniform iteration times.
This commit is contained in:
parent
2020176f0f
commit
2601441486
3 changed files with 17 additions and 1 deletions
|
@ -81,6 +81,8 @@ public:
|
|||
// The "trimmed length" is the number of words after trimming leading zeroed words
|
||||
size_t trimmed_length() const;
|
||||
|
||||
void clamp_to_trimmed_length();
|
||||
|
||||
UnsignedBigInteger plus(const UnsignedBigInteger& other) const;
|
||||
UnsignedBigInteger minus(const UnsignedBigInteger& other) const;
|
||||
UnsignedBigInteger bitwise_or(const UnsignedBigInteger& other) const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue