From b00edaeca5d267551ca6737f0f43ecc877cf6d47 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Mon, 20 Jan 2025 06:06:42 -0500 Subject: [PATCH] Clean up includes Various files included numthry.h or reducer.h but no longer needed them. --- src/lib/math/numbertheory/dsa_gen.cpp | 1 + src/lib/math/numbertheory/monty.cpp | 1 + src/lib/math/numbertheory/monty_exp.cpp | 2 -- src/lib/math/numbertheory/primality.cpp | 1 + src/lib/math/numbertheory/reducer.cpp | 9 +++++++++ src/lib/math/numbertheory/reducer.h | 9 ++++++--- src/lib/misc/srp6/srp6.cpp | 1 - src/lib/prov/pkcs11/p11_rsa.cpp | 1 + src/lib/pubkey/dsa/dsa.cpp | 1 - src/lib/pubkey/ec_group/ec_group.cpp | 1 + src/lib/pubkey/ec_group/ec_inner_data.h | 5 ++++- src/lib/pubkey/ec_group/legacy_ec_point/ec_inner_bn.cpp | 2 ++ src/lib/pubkey/ec_group/legacy_ec_point/ec_point.cpp | 1 - src/lib/pubkey/ecc_key/ecc_key.cpp | 1 - src/lib/pubkey/ecdh/ecdh.cpp | 1 - src/lib/pubkey/rsa/rsa.cpp | 2 +- src/lib/pubkey/sm2/sm2.cpp | 1 - 17 files changed, 27 insertions(+), 13 deletions(-) diff --git a/src/lib/math/numbertheory/dsa_gen.cpp b/src/lib/math/numbertheory/dsa_gen.cpp index 72d1da23f8a..0462b18d16f 100644 --- a/src/lib/math/numbertheory/dsa_gen.cpp +++ b/src/lib/math/numbertheory/dsa_gen.cpp @@ -7,6 +7,7 @@ #include +#include #include #include #include diff --git a/src/lib/math/numbertheory/monty.cpp b/src/lib/math/numbertheory/monty.cpp index cb2489846dd..fdbc00a8919 100644 --- a/src/lib/math/numbertheory/monty.cpp +++ b/src/lib/math/numbertheory/monty.cpp @@ -6,6 +6,7 @@ #include +#include #include #include diff --git a/src/lib/math/numbertheory/monty_exp.cpp b/src/lib/math/numbertheory/monty_exp.cpp index 467d0bbe8ee..15544901d6a 100644 --- a/src/lib/math/numbertheory/monty_exp.cpp +++ b/src/lib/math/numbertheory/monty_exp.cpp @@ -8,8 +8,6 @@ #include -#include -#include #include #include #include diff --git a/src/lib/math/numbertheory/primality.cpp b/src/lib/math/numbertheory/primality.cpp index 074c976ac70..820d431a667 100644 --- a/src/lib/math/numbertheory/primality.cpp +++ b/src/lib/math/numbertheory/primality.cpp @@ -7,6 +7,7 @@ #include #include +#include #include #include #include diff --git a/src/lib/math/numbertheory/reducer.cpp b/src/lib/math/numbertheory/reducer.cpp index ae28b12906f..f48aba10010 100644 --- a/src/lib/math/numbertheory/reducer.cpp +++ b/src/lib/math/numbertheory/reducer.cpp @@ -41,6 +41,15 @@ BigInt Modular_Reducer::reduce(const BigInt& x) const { return r; } +BigInt Modular_Reducer::square(const BigInt& x) const { + secure_vector ws; + BigInt x2 = x; + x2.square(ws); + BigInt r; + reduce(r, x2, ws); + return r; +} + namespace { /* diff --git a/src/lib/math/numbertheory/reducer.h b/src/lib/math/numbertheory/reducer.h index 7ea742b998a..149146b222b 100644 --- a/src/lib/math/numbertheory/reducer.h +++ b/src/lib/math/numbertheory/reducer.h @@ -8,7 +8,7 @@ #ifndef BOTAN_MODULAR_REDUCER_H_ #define BOTAN_MODULAR_REDUCER_H_ -#include +#include BOTAN_FUTURE_INTERNAL_HEADER(reducer.h) @@ -42,7 +42,7 @@ class BOTAN_PUBLIC_API(2, 0) Modular_Reducer final { * @param x the value to square * @return (x * x) % p */ - BigInt square(const BigInt& x) const { return reduce(Botan::square(x)); } + BigInt square(const BigInt& x) const; /** * Cube mod p @@ -54,7 +54,10 @@ class BOTAN_PUBLIC_API(2, 0) Modular_Reducer final { /** * Low level reduction function. Mostly for internal use. * Sometimes useful for performance by reducing temporaries - * Reduce x mod p and place the output in out. ** X and out must not reference each other ** + * Reduce x mod p and place the output in out. + * + * @warning X and out must not reference each other + * * ws is a temporary workspace. */ void reduce(BigInt& out, const BigInt& x, secure_vector& ws) const; diff --git a/src/lib/misc/srp6/srp6.cpp b/src/lib/misc/srp6/srp6.cpp index 040b8f2ecaa..e01009b82f3 100644 --- a/src/lib/misc/srp6/srp6.cpp +++ b/src/lib/misc/srp6/srp6.cpp @@ -9,7 +9,6 @@ #include #include -#include #include namespace Botan { diff --git a/src/lib/prov/pkcs11/p11_rsa.cpp b/src/lib/prov/pkcs11/p11_rsa.cpp index 1c77ced553e..13e103337c0 100644 --- a/src/lib/prov/pkcs11/p11_rsa.cpp +++ b/src/lib/prov/pkcs11/p11_rsa.cpp @@ -12,6 +12,7 @@ #if defined(BOTAN_HAS_RSA) + #include #include #include #include diff --git a/src/lib/pubkey/dsa/dsa.cpp b/src/lib/pubkey/dsa/dsa.cpp index b43a2e718e5..dfec550a8f9 100644 --- a/src/lib/pubkey/dsa/dsa.cpp +++ b/src/lib/pubkey/dsa/dsa.cpp @@ -8,7 +8,6 @@ #include -#include #include #include #include diff --git a/src/lib/pubkey/ec_group/ec_group.cpp b/src/lib/pubkey/ec_group/ec_group.cpp index 2528ba04cc4..29a2caaf72b 100644 --- a/src/lib/pubkey/ec_group/ec_group.cpp +++ b/src/lib/pubkey/ec_group/ec_group.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include diff --git a/src/lib/pubkey/ec_group/ec_inner_data.h b/src/lib/pubkey/ec_group/ec_inner_data.h index 5c2d7b99c76..47a1bf56b50 100644 --- a/src/lib/pubkey/ec_group/ec_inner_data.h +++ b/src/lib/pubkey/ec_group/ec_inner_data.h @@ -11,12 +11,15 @@ #include #include -#include #include #include #include #include +#if defined(BOTAN_HAS_LEGACY_EC_POINT) + #include +#endif + namespace Botan { #if defined(BOTAN_HAS_LEGACY_EC_POINT) diff --git a/src/lib/pubkey/ec_group/legacy_ec_point/ec_inner_bn.cpp b/src/lib/pubkey/ec_group/legacy_ec_point/ec_inner_bn.cpp index ada9f566290..9dc38795335 100644 --- a/src/lib/pubkey/ec_group/legacy_ec_point/ec_inner_bn.cpp +++ b/src/lib/pubkey/ec_group/legacy_ec_point/ec_inner_bn.cpp @@ -6,6 +6,8 @@ #include +#include + namespace Botan { const EC_Scalar_Data_BN& EC_Scalar_Data_BN::checked_ref(const EC_Scalar_Data& data) { diff --git a/src/lib/pubkey/ec_group/legacy_ec_point/ec_point.cpp b/src/lib/pubkey/ec_group/legacy_ec_point/ec_point.cpp index e3edc6e6b74..68a2765eeef 100644 --- a/src/lib/pubkey/ec_group/legacy_ec_point/ec_point.cpp +++ b/src/lib/pubkey/ec_group/legacy_ec_point/ec_point.cpp @@ -10,7 +10,6 @@ #include #include -#include #include #include #include diff --git a/src/lib/pubkey/ecc_key/ecc_key.cpp b/src/lib/pubkey/ecc_key/ecc_key.cpp index 5968ddb12e4..2cbc31a828f 100644 --- a/src/lib/pubkey/ecc_key/ecc_key.cpp +++ b/src/lib/pubkey/ecc_key/ecc_key.cpp @@ -11,7 +11,6 @@ #include #include -#include #include #include #include diff --git a/src/lib/pubkey/ecdh/ecdh.cpp b/src/lib/pubkey/ecdh/ecdh.cpp index bd0368b56bc..cbca6bfd227 100644 --- a/src/lib/pubkey/ecdh/ecdh.cpp +++ b/src/lib/pubkey/ecdh/ecdh.cpp @@ -9,7 +9,6 @@ #include -#include #include namespace Botan { diff --git a/src/lib/pubkey/rsa/rsa.cpp b/src/lib/pubkey/rsa/rsa.cpp index ad62c9a12f0..617d5727ce7 100644 --- a/src/lib/pubkey/rsa/rsa.cpp +++ b/src/lib/pubkey/rsa/rsa.cpp @@ -9,8 +9,8 @@ #include #include +#include #include -#include #include #include #include diff --git a/src/lib/pubkey/sm2/sm2.cpp b/src/lib/pubkey/sm2/sm2.cpp index 98ca49dd814..5e4f797ba48 100644 --- a/src/lib/pubkey/sm2/sm2.cpp +++ b/src/lib/pubkey/sm2/sm2.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include