/*************************************************
* 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&);
      DH_PublicKey(DataSource&, X509_Encoding = PEM);
   protected:
      DH_PublicKey() {}
   private:
      friend X509_PublicKey* get_public_key(const std::string&);
      SecureVector<byte> DER_encode_params() const;
      void BER_decode_params(DataSource&);
      std::string algo_name() const;
   };

/*************************************************
* 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&);
      DH_PrivateKey(DataSource&, const std::string& = "", X509_Encoding = PEM);
   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
