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

#ifndef BOTAN_DIFFIE_HELLMAN_H__
#define BOTAN_DIFFIE_HELLMAN_H__

#include <botan/dl_algo.h>
#include <botan/mod_exp.h>
#include <botan/blinding.h>

namespace Botan {

/*************************************************
* Diffie-Hellman Public Key                      *
*************************************************/
class DH_PublicKey : public virtual DL_Scheme_PublicKey
   {
   public:
      SecureVector<byte> public_value() const;
      DH_PublicKey(const DL_Group&, const BigInt&);
   protected:
      std::string algo_name() const;
      DH_PublicKey() {}
   private:
      friend X509_PublicKey* get_public_key(const std::string&);
      SecureVector<byte> DER_encode_params() const;
      void BER_decode_params(DataSource&);
   };

/*************************************************
* Diffie-Hellman Private Key                     *
*************************************************/
class DH_PrivateKey : public DH_PublicKey,
                      public PK_Key_Agreement_Key,
                      public virtual DL_Scheme_PrivateKey
   {
   public:
      SecureVector<byte> derive_key(const byte[], u32bit) const;
      SecureVector<byte> derive_key(const DH_PublicKey&) const;
      SecureVector<byte> derive_key(const BigInt&) const;

      SecureVector<byte> public_value() const;
      bool check_params() const;

      DH_PrivateKey(const DL_Group&);
      DH_PrivateKey(const DL_Group&, const BigInt&, const BigInt&);
   private:
      friend PKCS8_PrivateKey* get_private_key(const std::string&);
      void BER_decode_priv(DataSource&);
      DH_PrivateKey() {}
      FixedExponent_Exp powermod_x_p;
      Blinder blinder;
   };

}

#endif
