Botan  1.11.15
src/lib/pubkey/elgamal/elgamal.h
Go to the documentation of this file.
00001 /*
00002 * ElGamal
00003 * (C) 1999-2007 Jack Lloyd
00004 *
00005 * Botan is released under the Simplified BSD License (see license.txt)
00006 */
00007 
00008 #ifndef BOTAN_ELGAMAL_H__
00009 #define BOTAN_ELGAMAL_H__
00010 
00011 #include <botan/dl_algo.h>
00012 
00013 namespace Botan {
00014 
00015 /**
00016 * ElGamal Public Key
00017 */
00018 class BOTAN_DLL ElGamal_PublicKey : public virtual DL_Scheme_PublicKey
00019    {
00020    public:
00021       std::string algo_name() const { return "ElGamal"; }
00022       DL_Group::Format group_format() const { return DL_Group::ANSI_X9_42; }
00023 
00024       size_t max_input_bits() const { return (group_p().bits() - 1); }
00025 
00026       ElGamal_PublicKey(const AlgorithmIdentifier& alg_id,
00027                         const secure_vector<byte>& key_bits) :
00028          DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
00029          {}
00030 
00031       ElGamal_PublicKey(const DL_Group& group, const BigInt& y);
00032    protected:
00033       ElGamal_PublicKey() {}
00034    };
00035 
00036 /**
00037 * ElGamal Private Key
00038 */
00039 class BOTAN_DLL ElGamal_PrivateKey : public ElGamal_PublicKey,
00040                                      public virtual DL_Scheme_PrivateKey
00041    {
00042    public:
00043       bool check_key(RandomNumberGenerator& rng, bool) const;
00044 
00045       ElGamal_PrivateKey(const AlgorithmIdentifier& alg_id,
00046                          const secure_vector<byte>& key_bits,
00047                          RandomNumberGenerator& rng);
00048 
00049       ElGamal_PrivateKey(RandomNumberGenerator& rng,
00050                          const DL_Group& group,
00051                          const BigInt& priv_key = 0);
00052    };
00053 
00054 }
00055 
00056 #endif