aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/dh/dh_op.h
blob: b19961452afeacb4abf876d337b71c9713edcd50 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
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 BOTAN_DLL 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