diff options
23 files changed, 282 insertions, 220 deletions
diff --git a/src/core/libstate/engine.h b/src/core/libstate/engine.h index 12c69385b..72f5b28ca 100644 --- a/src/core/libstate/engine.h +++ b/src/core/libstate/engine.h @@ -8,17 +8,33 @@ #include <botan/base.h> #include <botan/mutex.h> -#include <botan/pk_ops.h> #include <botan/pow_mod.h> #include <botan/basefilt.h> #include <botan/enums.h> +#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY) + #include <botan/if_op.h> +#endif + +#if defined(BOTAN_HAS_DSA) + #include <botan/dsa_op.h> +#endif + #if defined(BOTAN_HAS_DH) #include <botan/dh_op.h> #endif +#if defined(BOTAN_HAS_NR) + #include <botan/nr_op.h> +#endif + +#if defined(BOTAN_HAS_ELGAMAL) + #include <botan/elg_op.h> +#endif + + #if defined(BOTAN_HAS_ECDSA) - #include <botan/ec_dompar.h> + #include <botan/ecc_op.h> #endif #include <utility> diff --git a/src/pubkey/dh/dh_op.h b/src/pubkey/dh/dh_op.h index 4fbd3f5dc..b19961452 100644 --- a/src/pubkey/dh/dh_op.h +++ b/src/pubkey/dh/dh_op.h @@ -26,7 +26,7 @@ class BOTAN_DLL DH_Operation /************************************************* * Botan's Default DH Operation * *************************************************/ -class Default_DH_Op : public DH_Operation +class BOTAN_DLL Default_DH_Op : public DH_Operation { public: BigInt agree(const BigInt& i) const { return powermod_x_p(i); } diff --git a/src/pubkey/dsa/dsa_core.h b/src/pubkey/dsa/dsa_core.h index 467f3c23f..d1aa413e5 100644 --- a/src/pubkey/dsa/dsa_core.h +++ b/src/pubkey/dsa/dsa_core.h @@ -6,8 +6,7 @@ #ifndef BOTAN_DSA_CORE_H__ #define BOTAN_DSA_CORE_H__ -#include <botan/bigint.h> -#include <botan/pk_ops.h> +#include <botan/dsa_op.h> #include <botan/dl_group.h> namespace Botan { diff --git a/src/pubkey/pubkey/dsa_op.cpp b/src/pubkey/dsa/dsa_op.cpp index ee94cb256..8b6e5403b 100644 --- a/src/pubkey/pubkey/dsa_op.cpp +++ b/src/pubkey/dsa/dsa_op.cpp @@ -3,34 +3,11 @@ * (C) 1999-2007 Jack Lloyd * *************************************************/ +#include <botan/dsa_op.h> #include <botan/eng_def.h> -#include <botan/pow_mod.h> -#include <botan/numthry.h> -#include <botan/reducer.h> namespace Botan { -namespace { - -/************************************************* -* Default DSA Operation * -*************************************************/ -class Default_DSA_Op : public DSA_Operation - { - public: - bool verify(const byte[], u32bit, const byte[], u32bit) const; - SecureVector<byte> sign(const byte[], u32bit, const BigInt&) const; - - DSA_Operation* clone() const { return new Default_DSA_Op(*this); } - - Default_DSA_Op(const DL_Group&, const BigInt&, const BigInt&); - private: - const BigInt x, y; - const DL_Group group; - Fixed_Base_Power_Mod powermod_g_p, powermod_y_p; - Modular_Reducer mod_p, mod_q; - }; - /************************************************* * Default_DSA_Op Constructor * *************************************************/ @@ -92,8 +69,6 @@ SecureVector<byte> Default_DSA_Op::sign(const byte in[], u32bit length, return output; } -} - /************************************************* * Acquire a DSA op * *************************************************/ diff --git a/src/pubkey/dsa/dsa_op.h b/src/pubkey/dsa/dsa_op.h new file mode 100644 index 000000000..98e671bf0 --- /dev/null +++ b/src/pubkey/dsa/dsa_op.h @@ -0,0 +1,51 @@ +/************************************************* +* DSA Operations Header File * +* (C) 1999-2008 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_DSA_OPS_H__ +#define BOTAN_DSA_OPS_H__ + +#include <botan/numthry.h> +#include <botan/pow_mod.h> +#include <botan/reducer.h> +#include <botan/dl_group.h> + +namespace Botan { + +/************************************************* +* DSA Operation * +*************************************************/ +class BOTAN_DLL DSA_Operation + { + public: + virtual bool verify(const byte[], u32bit, + const byte[], u32bit) const = 0; + virtual SecureVector<byte> sign(const byte[], u32bit, + const BigInt&) const = 0; + virtual DSA_Operation* clone() const = 0; + virtual ~DSA_Operation() {} + }; + +/************************************************* +* Botan's Default DSA Operation * +*************************************************/ +class BOTAN_DLL Default_DSA_Op : public DSA_Operation + { + public: + bool verify(const byte[], u32bit, const byte[], u32bit) const; + SecureVector<byte> sign(const byte[], u32bit, const BigInt&) const; + + DSA_Operation* clone() const { return new Default_DSA_Op(*this); } + + Default_DSA_Op(const DL_Group&, const BigInt&, const BigInt&); + private: + const BigInt x, y; + const DL_Group group; + Fixed_Base_Power_Mod powermod_g_p, powermod_y_p; + Modular_Reducer mod_p, mod_q; + }; + +} + +#endif diff --git a/src/pubkey/dsa/info.txt b/src/pubkey/dsa/info.txt index e98f33ca9..f1b505800 100644 --- a/src/pubkey/dsa/info.txt +++ b/src/pubkey/dsa/info.txt @@ -4,13 +4,6 @@ define DSA load_on auto -<add> -dsa.cpp -dsa.h -dsa_core.cpp -dsa_core.h -</add> - <requires> asn1 bigint @@ -19,3 +12,12 @@ keypair numbertheory pubkey </requires> + +<add> +dsa.cpp +dsa.h +dsa_core.cpp +dsa_core.h +dsa_op.cpp +dsa_op.h +</add> diff --git a/src/pubkey/ecdsa/ecc_core.h b/src/pubkey/ecdsa/ecc_core.h index 4f840bf06..46be43b8a 100644 --- a/src/pubkey/ecdsa/ecc_core.h +++ b/src/pubkey/ecdsa/ecc_core.h @@ -7,9 +7,8 @@ #ifndef BOTAN_ECC_CORE_H__ #define BOTAN_ECC_CORE_H__ -#include <botan/bigint.h> +#include <botan/ecc_op.h> #include <botan/blinding.h> -#include <botan/pk_ops.h> #include <botan/ec_dompar.h> namespace Botan { diff --git a/src/pubkey/ecdsa/ecc_op.h b/src/pubkey/ecdsa/ecc_op.h new file mode 100644 index 000000000..319e02da9 --- /dev/null +++ b/src/pubkey/ecdsa/ecc_op.h @@ -0,0 +1,44 @@ +/************************************************* +* ECDSA/ECKAEG Operations Header File * +* (C) 1999-2008 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_ECDSA_OPERATIONS_H__ +#define BOTAN_ECDSA_OPERATIONS_H__ + +#include <botan/bigint.h> +#include <botan/point_gfp.h> + +namespace Botan { + +/************************************************* +* ECDSA Operation * +*************************************************/ +class BOTAN_DLL ECDSA_Operation + { + public: + virtual bool verify(const byte sig[], u32bit sig_len, + const byte msg[], u32bit msg_len) const = 0; + + virtual SecureVector<byte> sign(const byte message[], + u32bit mess_len) const = 0; + + virtual ECDSA_Operation* clone() const = 0; + + virtual ~ECDSA_Operation() {} + }; + +/************************************************* +* ECKAEG Operation * +*************************************************/ +class BOTAN_DLL ECKAEG_Operation + { + public: + virtual SecureVector<byte> agree(const PointGFp&) const = 0; + virtual ECKAEG_Operation* clone() const = 0; + virtual ~ECKAEG_Operation() {} + }; + +} + +#endif diff --git a/src/pubkey/ecdsa/info.txt b/src/pubkey/ecdsa/info.txt index 699c62214..6c3aec8c6 100644 --- a/src/pubkey/ecdsa/info.txt +++ b/src/pubkey/ecdsa/info.txt @@ -4,15 +4,6 @@ define ECDSA load_on auto -<add> -ec.cpp -ec.h -ecc_core.cpp -ecc_core.h -ecdsa.cpp -ecdsa.h -</add> - <requires> asn1 bigint @@ -21,3 +12,13 @@ numbertheory gfpmath pubkey </requires> + +<add> +ec.cpp +ec.h +ecc_core.cpp +ecc_core.h +ecc_op.h +ecdsa.cpp +ecdsa.h +</add> diff --git a/src/pubkey/elgamal/elg_core.h b/src/pubkey/elgamal/elg_core.h index 67966a452..5b7c36947 100644 --- a/src/pubkey/elgamal/elg_core.h +++ b/src/pubkey/elgamal/elg_core.h @@ -6,8 +6,7 @@ #ifndef BOTAN_ELGAMAL_CORE_H__ #define BOTAN_ELGAMAL_CORE_H__ -#include <botan/pk_ops.h> -#include <botan/bigint.h> +#include <botan/elg_op.h> #include <botan/blinding.h> #include <botan/dl_group.h> diff --git a/src/pubkey/pubkey/elg_op.cpp b/src/pubkey/elgamal/elg_op.cpp index 0d852d145..3f276de09 100644 --- a/src/pubkey/pubkey/elg_op.cpp +++ b/src/pubkey/elgamal/elg_op.cpp @@ -3,34 +3,11 @@ * (C) 1999-2007 Jack Lloyd * *************************************************/ +#include <botan/elg_op.h> #include <botan/eng_def.h> -#include <botan/pow_mod.h> -#include <botan/numthry.h> -#include <botan/reducer.h> namespace Botan { -namespace { - -/************************************************* -* Default ElGamal Operation * -*************************************************/ -class Default_ELG_Op : public ELG_Operation - { - public: - SecureVector<byte> encrypt(const byte[], u32bit, const BigInt&) const; - BigInt decrypt(const BigInt&, const BigInt&) const; - - ELG_Operation* clone() const { return new Default_ELG_Op(*this); } - - Default_ELG_Op(const DL_Group&, const BigInt&, const BigInt&); - private: - const BigInt p; - Fixed_Base_Power_Mod powermod_g_p, powermod_y_p; - Fixed_Exponent_Power_Mod powermod_x_p; - Modular_Reducer mod_p; - }; - /************************************************* * Default_ELG_Op Constructor * *************************************************/ @@ -75,8 +52,6 @@ BigInt Default_ELG_Op::decrypt(const BigInt& a, const BigInt& b) const return mod_p.multiply(b, inverse_mod(powermod_x_p(a), p)); } -} - /************************************************* * Acquire an ElGamal op * *************************************************/ diff --git a/src/pubkey/elgamal/elg_op.h b/src/pubkey/elgamal/elg_op.h new file mode 100644 index 000000000..c75ff7d45 --- /dev/null +++ b/src/pubkey/elgamal/elg_op.h @@ -0,0 +1,50 @@ +/************************************************* +* ElGamal Operations Header File * +* (C) 1999-2008 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_ELGAMAL_OPS_H__ +#define BOTAN_ELGAMAL_OPS_H__ + +#include <botan/pow_mod.h> +#include <botan/numthry.h> +#include <botan/reducer.h> +#include <botan/dl_group.h> + +namespace Botan { + +/************************************************* +* ElGamal Operation * +*************************************************/ +class BOTAN_DLL ELG_Operation + { + public: + virtual SecureVector<byte> encrypt(const byte[], u32bit, + const BigInt&) const = 0; + virtual BigInt decrypt(const BigInt&, const BigInt&) const = 0; + virtual ELG_Operation* clone() const = 0; + virtual ~ELG_Operation() {} + }; + +/************************************************* +* Botan's Default ElGamal Operation * +*************************************************/ +class BOTAN_DLL Default_ELG_Op : public ELG_Operation + { + public: + SecureVector<byte> encrypt(const byte[], u32bit, const BigInt&) const; + BigInt decrypt(const BigInt&, const BigInt&) const; + + ELG_Operation* clone() const { return new Default_ELG_Op(*this); } + + Default_ELG_Op(const DL_Group&, const BigInt&, const BigInt&); + private: + const BigInt p; + Fixed_Base_Power_Mod powermod_g_p, powermod_y_p; + Fixed_Exponent_Power_Mod powermod_x_p; + Modular_Reducer mod_p; + }; + +} + +#endif diff --git a/src/pubkey/elgamal/info.txt b/src/pubkey/elgamal/info.txt index 96586480b..6359efafa 100644 --- a/src/pubkey/elgamal/info.txt +++ b/src/pubkey/elgamal/info.txt @@ -9,6 +9,8 @@ elgamal.cpp elgamal.h elg_core.cpp elg_core.h +elg_op.cpp +elg_op.h </add> <requires> diff --git a/src/pubkey/if_algo/if_core.h b/src/pubkey/if_algo/if_core.h index b6afad950..ae9fb3d09 100644 --- a/src/pubkey/if_algo/if_core.h +++ b/src/pubkey/if_algo/if_core.h @@ -6,9 +6,8 @@ #ifndef BOTAN_IF_CORE_H__ #define BOTAN_IF_CORE_H__ -#include <botan/bigint.h> +#include <botan/if_op.h> #include <botan/blinding.h> -#include <botan/pk_ops.h> namespace Botan { diff --git a/src/pubkey/pubkey/if_op.cpp b/src/pubkey/if_algo/if_op.cpp index 0b151bf3b..0b151bf3b 100644 --- a/src/pubkey/pubkey/if_op.cpp +++ b/src/pubkey/if_algo/if_op.cpp diff --git a/src/pubkey/if_algo/if_op.h b/src/pubkey/if_algo/if_op.h new file mode 100644 index 000000000..be9a4581c --- /dev/null +++ b/src/pubkey/if_algo/if_op.h @@ -0,0 +1,27 @@ +/************************************************* +* IF Operations Header File * +* (C) 1999-2008 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_IF_OP_H__ +#define BOTAN_IF_OP_H__ + +#include <botan/bigint.h> + +namespace Botan { + +/************************************************* +* IF Operation * +*************************************************/ +class BOTAN_DLL IF_Operation + { + public: + virtual BigInt public_op(const BigInt&) const = 0; + virtual BigInt private_op(const BigInt&) const = 0; + virtual IF_Operation* clone() const = 0; + virtual ~IF_Operation() {} + }; + +} + +#endif diff --git a/src/pubkey/if_algo/info.txt b/src/pubkey/if_algo/info.txt index af1726414..1ee2e3a68 100644 --- a/src/pubkey/if_algo/info.txt +++ b/src/pubkey/if_algo/info.txt @@ -4,15 +4,18 @@ define IF_PUBLIC_KEY_FAMILY load_on required -<add> -if_algo.cpp -if_algo.h -if_core.cpp -if_core.h -</add> <requires> asn1 bigint filters </requires> + +<add> +if_algo.cpp +if_algo.h +if_core.cpp +if_core.h +if_op.cpp +if_op.h +</add> diff --git a/src/pubkey/nr/info.txt b/src/pubkey/nr/info.txt index f7325d984..b574af0e7 100644 --- a/src/pubkey/nr/info.txt +++ b/src/pubkey/nr/info.txt @@ -9,6 +9,8 @@ nr.cpp nr.h nr_core.cpp nr_core.h +nr_op.cpp +nr_op.h </add> <requires> diff --git a/src/pubkey/nr/nr_core.h b/src/pubkey/nr/nr_core.h index 416e31619..69a605c8d 100644 --- a/src/pubkey/nr/nr_core.h +++ b/src/pubkey/nr/nr_core.h @@ -6,8 +6,7 @@ #ifndef BOTAN_NR_CORE_H__ #define BOTAN_NR_CORE_H__ -#include <botan/bigint.h> -#include <botan/pk_ops.h> +#include <botan/nr_op.h> #include <botan/dl_group.h> namespace Botan { diff --git a/src/pubkey/pubkey/nr_op.cpp b/src/pubkey/nr/nr_op.cpp index 01e96a822..dfb44d617 100644 --- a/src/pubkey/pubkey/nr_op.cpp +++ b/src/pubkey/nr/nr_op.cpp @@ -3,34 +3,11 @@ * (C) 1999-2007 Jack Lloyd * *************************************************/ +#include <botan/nr_op.h> #include <botan/eng_def.h> -#include <botan/pow_mod.h> -#include <botan/numthry.h> -#include <botan/reducer.h> namespace Botan { -namespace { - -/************************************************* -* Default NR Operation * -*************************************************/ -class Default_NR_Op : public NR_Operation - { - public: - SecureVector<byte> verify(const byte[], u32bit) const; - SecureVector<byte> sign(const byte[], u32bit, const BigInt&) const; - - NR_Operation* clone() const { return new Default_NR_Op(*this); } - - Default_NR_Op(const DL_Group&, const BigInt&, const BigInt&); - private: - const BigInt x, y; - const DL_Group group; - Fixed_Base_Power_Mod powermod_g_p, powermod_y_p; - Modular_Reducer mod_p, mod_q; - }; - /************************************************* * Default_NR_Op Constructor * *************************************************/ @@ -90,8 +67,6 @@ SecureVector<byte> Default_NR_Op::sign(const byte in[], u32bit length, return output; } -} - /************************************************* * Acquire a NR op * *************************************************/ diff --git a/src/pubkey/nr/nr_op.h b/src/pubkey/nr/nr_op.h new file mode 100644 index 000000000..11c2cd26a --- /dev/null +++ b/src/pubkey/nr/nr_op.h @@ -0,0 +1,51 @@ +/************************************************* +* NR Operations Header File * +* (C) 1999-2008 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_NR_OPS_H__ +#define BOTAN_NR_OPS_H__ + +#include <botan/pow_mod.h> +#include <botan/numthry.h> +#include <botan/reducer.h> +#include <botan/dl_group.h> + +namespace Botan { + +/************************************************* +* NR Operation * +*************************************************/ +class BOTAN_DLL NR_Operation + { + public: + virtual SecureVector<byte> verify(const byte[], u32bit) const = 0; + virtual SecureVector<byte> sign(const byte[], u32bit, + const BigInt&) const = 0; + virtual NR_Operation* clone() const = 0; + virtual ~NR_Operation() {} + }; + +/************************************************* +* Botan's Default NR Operation * +*************************************************/ +class BOTAN_DLL Default_NR_Op : public NR_Operation + { + public: + SecureVector<byte> verify(const byte[], u32bit) const; + SecureVector<byte> sign(const byte[], u32bit, const BigInt&) const; + + NR_Operation* clone() const { return new Default_NR_Op(*this); } + + Default_NR_Op(const DL_Group&, const BigInt&, const BigInt&); + private: + const BigInt x, y; + const DL_Group group; + Fixed_Base_Power_Mod powermod_g_p, powermod_y_p; + Modular_Reducer mod_p, mod_q; + }; + + +} + +#endif diff --git a/src/pubkey/pubkey/info.txt b/src/pubkey/pubkey/info.txt index 421232286..b02f2b5b1 100644 --- a/src/pubkey/pubkey/info.txt +++ b/src/pubkey/pubkey/info.txt @@ -11,15 +11,10 @@ asn1 </requires> <add> -dsa_op.cpp -elg_op.cpp -if_op.cpp -nr_op.cpp pk_algs.cpp pk_algs.h pk_keys.cpp pk_keys.h -pk_ops.h pkcs8.cpp pkcs8.h pubkey.cpp diff --git a/src/pubkey/pubkey/pk_ops.h b/src/pubkey/pubkey/pk_ops.h deleted file mode 100644 index 32be0326f..000000000 --- a/src/pubkey/pubkey/pk_ops.h +++ /dev/null @@ -1,102 +0,0 @@ -/************************************************* -* Public Key Operations Header File * -* (C) 1999-2008 Jack Lloyd * -*************************************************/ - -#ifndef BOTAN_PK_OPS_H__ -#define BOTAN_PK_OPS_H__ - -#include <botan/bigint.h> -#include <botan/dl_group.h> - -#if defined(BOTAN_HAS_ECDSA) - #include <botan/point_gfp.h> -#endif - -namespace Botan { - -/************************************************* -* IF Operation * -*************************************************/ -class BOTAN_DLL IF_Operation - { - public: - virtual BigInt public_op(const BigInt&) const = 0; - virtual BigInt private_op(const BigInt&) const = 0; - virtual IF_Operation* clone() const = 0; - virtual ~IF_Operation() {} - }; - -/************************************************* -* DSA Operation * -*************************************************/ -class BOTAN_DLL DSA_Operation - { - public: - virtual bool verify(const byte[], u32bit, - const byte[], u32bit) const = 0; - virtual SecureVector<byte> sign(const byte[], u32bit, - const BigInt&) const = 0; - virtual DSA_Operation* clone() const = 0; - virtual ~DSA_Operation() {} - }; - -/************************************************* -* NR Operation * -*************************************************/ -class BOTAN_DLL NR_Operation - { - public: - virtual SecureVector<byte> verify(const byte[], u32bit) const = 0; - virtual SecureVector<byte> sign(const byte[], u32bit, - const BigInt&) const = 0; - virtual NR_Operation* clone() const = 0; - virtual ~NR_Operation() {} - }; - -/************************************************* -* ElGamal Operation * -*************************************************/ -class BOTAN_DLL ELG_Operation - { - public: - virtual SecureVector<byte> encrypt(const byte[], u32bit, - const BigInt&) const = 0; - virtual BigInt decrypt(const BigInt&, const BigInt&) const = 0; - virtual ELG_Operation* clone() const = 0; - virtual ~ELG_Operation() {} - }; - -#if defined(BOTAN_HAS_ECDSA) -/************************************************* -* ECDSA Operation * -*************************************************/ -class BOTAN_DLL ECDSA_Operation - { - public: - virtual bool verify(const byte sig[], u32bit sig_len, - const byte msg[], u32bit msg_len) const = 0; - - virtual SecureVector<byte> sign(const byte message[], - u32bit mess_len) const = 0; - - virtual ECDSA_Operation* clone() const = 0; - - virtual ~ECDSA_Operation() {} - }; - -/************************************************* -* ECKAEG Operation * -*************************************************/ -class BOTAN_DLL ECKAEG_Operation - { - public: - virtual SecureVector<byte> agree(const PointGFp&) const = 0; - virtual ECKAEG_Operation* clone() const = 0; - virtual ~ECKAEG_Operation() {} - }; -#endif - -} - -#endif |