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 e831c42916a..ee871532413 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 9da6a195a75..ee8f0624fd9 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 a6b91763bf7..45132e5ccd6 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_inner_data.h b/src/lib/pubkey/ec_group/ec_inner_data.h index 8263b8e3ce3..47a1bf56b50 100644 --- a/src/lib/pubkey/ec_group/ec_inner_data.h +++ b/src/lib/pubkey/ec_group/ec_inner_data.h @@ -11,13 +11,15 @@ #include #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_point.cpp b/src/lib/pubkey/ec_group/legacy_ec_point/ec_point.cpp index e3d90343d66..1dd582ef7b1 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,10 +10,10 @@ #include #include -#include #include #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 9f7baa510eb..36a79b0f63b 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