diff options
author | lloyd <[email protected]> | 2008-10-01 15:01:06 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-10-01 15:01:06 +0000 |
commit | 1034cf44b4ee0948312c11a1b079b8b04c5828e2 (patch) | |
tree | 17bd5ec37cea079132d0774435b81f8c18fc01f4 /src/pubkey/dh | |
parent | 9da5c08de6bb6a6972a48ee5bb11ab7654c37f63 (diff) |
Split Diffie-Hellman off almost completely, such that nearly none of
it builds if it is disabled.
Current deficiency: due to #if defined(BLAH) in the engine code,
Botan will not be binary compat across different configurations b/c
the vtable will change size.
Move some source from core/ to core/libstate where it belonged (engine stuff)
Diffstat (limited to 'src/pubkey/dh')
-rw-r--r-- | src/pubkey/dh/dh_core.h | 4 | ||||
-rw-r--r-- | src/pubkey/dh/dh_op.cpp | 20 | ||||
-rw-r--r-- | src/pubkey/dh/dh_op.h | 43 | ||||
-rw-r--r-- | src/pubkey/dh/info.txt | 2 |
4 files changed, 66 insertions, 3 deletions
diff --git a/src/pubkey/dh/dh_core.h b/src/pubkey/dh/dh_core.h index 3735f31e1..666e615fc 100644 --- a/src/pubkey/dh/dh_core.h +++ b/src/pubkey/dh/dh_core.h @@ -6,10 +6,8 @@ #ifndef BOTAN_DH_CORE_H__ #define BOTAN_DH_CORE_H__ -#include <botan/bigint.h> +#include <botan/dh_op.h> #include <botan/blinding.h> -#include <botan/pk_ops.h> -#include <botan/dl_group.h> namespace Botan { diff --git a/src/pubkey/dh/dh_op.cpp b/src/pubkey/dh/dh_op.cpp new file mode 100644 index 000000000..3b87c6467 --- /dev/null +++ b/src/pubkey/dh/dh_op.cpp @@ -0,0 +1,20 @@ +/************************************************* +* DH Operations Source File * +* (C) 1999-2007 Jack Lloyd * +*************************************************/ + +#include <botan/dh_op.h> +#include <botan/eng_def.h> + +namespace Botan { + +/************************************************* +* Acquire a DH op * +*************************************************/ +DH_Operation* Default_Engine::dh_op(const DL_Group& group, + const BigInt& x) const + { + return new Default_DH_Op(group, x); + } + +} diff --git a/src/pubkey/dh/dh_op.h b/src/pubkey/dh/dh_op.h new file mode 100644 index 000000000..4fbd3f5dc --- /dev/null +++ b/src/pubkey/dh/dh_op.h @@ -0,0 +1,43 @@ +/************************************************* +* DH Operations Header File * +* (C) 1999-2008 Jack Lloyd * +*************************************************/ + +#ifndef BOTAN_DH_OPS_H__ +#define BOTAN_DH_OPS_H__ + +#include <botan/dl_group.h> +#include <botan/reducer.h> +#include <botan/pow_mod.h> + +namespace Botan { + +/************************************************* +* DH Operation Interface * +*************************************************/ +class BOTAN_DLL DH_Operation + { + public: + virtual BigInt agree(const BigInt&) const = 0; + virtual DH_Operation* clone() const = 0; + virtual ~DH_Operation() {} + }; + +/************************************************* +* Botan's Default DH Operation * +*************************************************/ +class Default_DH_Op : public DH_Operation + { + public: + BigInt agree(const BigInt& i) const { return powermod_x_p(i); } + DH_Operation* clone() const { return new Default_DH_Op(*this); } + + Default_DH_Op(const DL_Group& group, const BigInt& x) : + powermod_x_p(x, group.get_p()) {} + private: + Fixed_Exponent_Power_Mod powermod_x_p; + }; + +} + +#endif diff --git a/src/pubkey/dh/info.txt b/src/pubkey/dh/info.txt index 3765644c8..a54188c57 100644 --- a/src/pubkey/dh/info.txt +++ b/src/pubkey/dh/info.txt @@ -9,6 +9,8 @@ dh.cpp dh.h dh_core.cpp dh_core.h +dh_op.h +dh_op.cpp </add> <requires> |