Skip to content

Commit

Permalink
Clean up includes
Browse files Browse the repository at this point in the history
Various files included numthry.h or reducer.h but no longer needed them.
  • Loading branch information
randombit committed Jan 20, 2025
1 parent 1dc31ad commit b00edae
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 13 deletions.
1 change: 1 addition & 0 deletions src/lib/math/numbertheory/dsa_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include <botan/internal/primality.h>

#include <botan/bigint.h>
#include <botan/hash.h>
#include <botan/numthry.h>
#include <botan/reducer.h>
Expand Down
1 change: 1 addition & 0 deletions src/lib/math/numbertheory/monty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <botan/internal/monty.h>

#include <botan/numthry.h>
#include <botan/reducer.h>
#include <botan/internal/mp_core.h>

Expand Down
2 changes: 0 additions & 2 deletions src/lib/math/numbertheory/monty_exp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@

#include <botan/internal/monty_exp.h>

#include <botan/numthry.h>
#include <botan/reducer.h>
#include <botan/internal/ct_utils.h>
#include <botan/internal/monty.h>
#include <botan/internal/rounding.h>
Expand Down
1 change: 1 addition & 0 deletions src/lib/math/numbertheory/primality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <botan/internal/primality.h>

#include <botan/bigint.h>
#include <botan/numthry.h>
#include <botan/reducer.h>
#include <botan/rng.h>
#include <botan/internal/monty.h>
Expand Down
9 changes: 9 additions & 0 deletions src/lib/math/numbertheory/reducer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,15 @@ BigInt Modular_Reducer::reduce(const BigInt& x) const {
return r;
}

BigInt Modular_Reducer::square(const BigInt& x) const {
secure_vector<word> ws;
BigInt x2 = x;
x2.square(ws);
BigInt r;
reduce(r, x2, ws);
return r;
}

namespace {

/*
Expand Down
9 changes: 6 additions & 3 deletions src/lib/math/numbertheory/reducer.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#ifndef BOTAN_MODULAR_REDUCER_H_
#define BOTAN_MODULAR_REDUCER_H_

#include <botan/numthry.h>
#include <botan/bigint.h>

BOTAN_FUTURE_INTERNAL_HEADER(reducer.h)

Expand Down Expand Up @@ -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
Expand All @@ -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<word>& ws) const;
Expand Down
1 change: 0 additions & 1 deletion src/lib/misc/srp6/srp6.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <botan/dl_group.h>
#include <botan/hash.h>
#include <botan/numthry.h>
#include <botan/internal/fmt.h>

namespace Botan {
Expand Down
1 change: 1 addition & 0 deletions src/lib/prov/pkcs11/p11_rsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#if defined(BOTAN_HAS_RSA)

#include <botan/numthry.h>
#include <botan/p11_mechanism.h>
#include <botan/pubkey.h>
#include <botan/rng.h>
Expand Down
1 change: 0 additions & 1 deletion src/lib/pubkey/dsa/dsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <botan/dsa.h>

#include <botan/numthry.h>
#include <botan/internal/divide.h>
#include <botan/internal/dl_scheme.h>
#include <botan/internal/keypair.h>
Expand Down
1 change: 1 addition & 0 deletions src/lib/pubkey/ec_group/ec_group.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <botan/ber_dec.h>
#include <botan/der_enc.h>
#include <botan/mutex.h>
#include <botan/numthry.h>
#include <botan/pem.h>
#include <botan/reducer.h>
#include <botan/rng.h>
Expand Down
5 changes: 4 additions & 1 deletion src/lib/pubkey/ec_group/ec_inner_data.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@

#include <botan/asn1_obj.h>
#include <botan/bigint.h>
#include <botan/reducer.h>
#include <botan/internal/monty.h>
#include <botan/internal/stl_util.h>
#include <memory>
#include <span>

#if defined(BOTAN_HAS_LEGACY_EC_POINT)
#include <botan/reducer.h>
#endif

namespace Botan {

#if defined(BOTAN_HAS_LEGACY_EC_POINT)
Expand Down
2 changes: 2 additions & 0 deletions src/lib/pubkey/ec_group/legacy_ec_point/ec_inner_bn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

#include <botan/internal/ec_inner_bn.h>

#include <botan/numthry.h>

namespace Botan {

const EC_Scalar_Data_BN& EC_Scalar_Data_BN::checked_ref(const EC_Scalar_Data& data) {
Expand Down
1 change: 0 additions & 1 deletion src/lib/pubkey/ec_group/legacy_ec_point/ec_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <botan/ec_point.h>

#include <botan/numthry.h>
#include <botan/reducer.h>
#include <botan/rng.h>
#include <botan/internal/ct_utils.h>
#include <botan/internal/ec_inner_data.h>
Expand Down
1 change: 0 additions & 1 deletion src/lib/pubkey/ecc_key/ecc_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include <botan/ber_dec.h>
#include <botan/der_enc.h>
#include <botan/numthry.h>
#include <botan/secmem.h>
#include <botan/internal/ec_key_data.h>
#include <botan/internal/fmt.h>
Expand Down
1 change: 0 additions & 1 deletion src/lib/pubkey/ecdh/ecdh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

#include <botan/ecdh.h>

#include <botan/numthry.h>
#include <botan/internal/pk_ops_impl.h>

namespace Botan {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/pubkey/rsa/rsa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include <botan/ber_dec.h>
#include <botan/der_enc.h>
#include <botan/numthry.h>
#include <botan/pss_params.h>
#include <botan/reducer.h>
#include <botan/internal/blinding.h>
#include <botan/internal/divide.h>
#include <botan/internal/emsa.h>
Expand Down
1 change: 0 additions & 1 deletion src/lib/pubkey/sm2/sm2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include <botan/sm2.h>

#include <botan/hash.h>
#include <botan/numthry.h>
#include <botan/internal/keypair.h>
#include <botan/internal/loadstor.h>
#include <botan/internal/parsing.h>
Expand Down

0 comments on commit b00edae

Please sign in to comment.