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

#ifndef BOTAN_NYBERG_RUEPPEL_H__
#define BOTAN_NYBERG_RUEPPEL_H__

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

namespace Botan {

/*************************************************
* Nyberg-Rueppel Public Key                      *
*************************************************/
class NR_PublicKey : public PK_Verifying_with_MR_Key,
                     public virtual DL_Scheme_PublicKey
   {
   public:
      SecureVector<byte> verify(const byte[], u32bit) const;
      u32bit max_input_bits() const;

      NR_PublicKey(const DL_Group&, const BigInt&);
      NR_PublicKey(DataSource&, X509_Encoding = PEM);
   protected:
      NR_PublicKey() {}
      FixedBase_Exp powermod_g_p, powermod_y_p;
   private:
      friend X509_PublicKey* get_public_key(const std::string&);
      u32bit message_parts() const { return 2; }
      u32bit message_part_size() const;
      SecureVector<byte> DER_encode_params() const;
      void BER_decode_pub(DataSource&);
      void BER_decode_params(DataSource&);
      std::string algo_name() const;
   };

/*************************************************
* Nyberg-Rueppel Private Key                     *
*************************************************/
class NR_PrivateKey : public NR_PublicKey, public PK_Signing_Key,
                      public virtual DL_Scheme_PrivateKey
   {
   public:
      SecureVector<byte> sign(const byte[], u32bit) const;

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

      NR_PrivateKey(const DL_Group&);
      NR_PrivateKey(const DL_Group&, const BigInt&, const BigInt&);
      NR_PrivateKey(DataSource&, X509_Encoding = PEM);
   private:
      friend PKCS8_PrivateKey* get_private_key(const std::string&);
      void BER_decode_priv(DataSource&);
      NR_PrivateKey() {}
   };

}

#endif
