/*************************************************
* ElGamal Header File                            *
* (C) 1999-2003 The Botan Project                *
*************************************************/

#ifndef BOTAN_ELGAMAL_H__
#define BOTAN_ELGAMAL_H__

#include <botan/dl_param.h>
#include <botan/mod_exp.h>
#include <botan/pk_keys.h>
#include <botan/blinding.h>

namespace Botan {

/*************************************************
* ElGamal Public Key                             *
*************************************************/
class ElGamal_PublicKey : public PK_Encrypting_Key
   {
   public:
      SecureVector<byte> encrypt(const byte[], u32bit) const;

      u32bit max_input_bits() const;
      bool check_params() const;

      const DL_Group& get_domain() const { return group; }
      BigInt get_y() const { return y; }

      ElGamal_PublicKey(const DL_Group&, const BigInt&);
   protected:
      DL_Group group;
      BigInt y;
      FixedBase_Exp powermod_g_p, powermod_y_p;
   private:
      std::string algo_name() const { return "ElGamal"; }
   };

/*************************************************
* ElGamal Private Key                            *
*************************************************/
class ElGamal_PrivateKey : public ElGamal_PublicKey, public PK_Decrypting_Key
   {
   public:
      SecureVector<byte> decrypt(const byte[], u32bit) const;

      bool check_params() const;
      BigInt get_x() const { return x; }

      ElGamal_PrivateKey(const DL_Group&);
      ElGamal_PrivateKey(const DL_Group&, const BigInt&, const BigInt&);
   private:
      BigInt x;
      FixedExponent_Exp powermod_x_p;
      Blinder blinder;
   };

}

#endif
