LibCrypto: Move GCD to method of UnsignedBigInteger

Having it as a method instead of a free function is necessary for the
next commits and generally allows for optimizations that require deeper
access into the `UnsignedBigInteger`.
This commit is contained in:
devgianlu 2025-04-26 11:01:48 +02:00 committed by Jelle Raaijmakers
parent e251b451ef
commit a952d000be
Notes: github-actions[bot] 2025-05-23 09:58:43 +00:00
7 changed files with 15 additions and 33 deletions

View file

@ -1,28 +0,0 @@
/*
* Copyright (c) 2020, Ali Mohammad Pur <mpfard@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Debug.h>
#include <AK/Random.h>
#include <LibCrypto/BigInt/Algorithms/UnsignedBigIntegerAlgorithms.h>
#include <LibCrypto/NumberTheory/ModularFunctions.h>
#include <LibCrypto/SecureRandom.h>
namespace Crypto::NumberTheory {
UnsignedBigInteger GCD(UnsignedBigInteger const& a, UnsignedBigInteger const& b)
{
UnsignedBigInteger temp_a { a };
UnsignedBigInteger temp_b { b };
UnsignedBigInteger temp_quotient;
UnsignedBigInteger temp_remainder;
UnsignedBigInteger output;
UnsignedBigIntegerAlgorithms::destructive_GCD_without_allocation(temp_a, temp_b, temp_quotient, temp_remainder, output);
return output;
}
}