mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 10:07:15 +02:00
LibCrypto: Implement arbitrarily sized right shifts
Previously we could only shift by words at a time
This commit is contained in:
committed by
Andrew Kaster
parent
9045840e33
commit
1af9fa1968
Notes:
sideshowbarker
2024-07-17 06:40:35 +09:00
Author: https://github.com/Hendiadyoin1 Commit: https://github.com/SerenityOS/serenity/commit/1af9fa1968 Pull-request: https://github.com/SerenityOS/serenity/pull/23619 Issue: https://github.com/SerenityOS/serenity/issues/23575 Reviewed-by: https://github.com/ADKaster ✅ Reviewed-by: https://github.com/DanShaders ✅
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "UnsignedBigIntegerAlgorithms.h"
|
||||
#include <AK/BigIntBase.h>
|
||||
#include <AK/BuiltinWrappers.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
|
||||
@@ -207,6 +208,15 @@ FLATTEN void UnsignedBigIntegerAlgorithms::shift_left_without_allocation(
|
||||
}
|
||||
}
|
||||
|
||||
FLATTEN void UnsignedBigIntegerAlgorithms::shift_right_without_allocation(
|
||||
UnsignedBigInteger const& number,
|
||||
size_t num_bits,
|
||||
UnsignedBigInteger& output)
|
||||
{
|
||||
output.m_words.resize_and_keep_capacity(number.length() - (num_bits / UnsignedBigInteger::BITS_IN_WORD));
|
||||
Ops::shift_right(number.words_span(), num_bits, output.words_span());
|
||||
}
|
||||
|
||||
void UnsignedBigIntegerAlgorithms::shift_left_by_n_words(
|
||||
UnsignedBigInteger const& number,
|
||||
size_t number_of_words,
|
||||
|
||||
Reference in New Issue
Block a user