6 #ifndef CRYPTOPP_ELGAMAL_H 7 #define CRYPTOPP_ELGAMAL_H 32 agreedElement.
Encode(derivedKey, derivedLength);
38 return GetGroupParameters().GetModulus().ByteCount();
43 unsigned int len = GetGroupParameters().GetModulus().ByteCount();
44 if (plainTextLength <= GetMaxSymmetricPlaintextLength(len))
52 unsigned int len = GetGroupParameters().GetModulus().ByteCount();
53 if (cipherTextLength == len)
54 return STDMIN(255U, len-3);
62 const Integer &p = GetGroupParameters().GetModulus();
67 memcpy(block+modulusLen-2-plainTextLength, plainText, plainTextLength);
68 block[modulusLen-2] = (
byte)plainTextLength;
70 a_times_b_mod_c(Integer(key, modulusLen), Integer(block, modulusLen-1), p).
Encode(cipherText, modulusLen);
76 const Integer &p = GetGroupParameters().GetModulus();
79 if (cipherTextLength != modulusLen)
82 Integer m =
a_times_b_mod_c(Integer(cipherText, modulusLen), Integer(key, modulusLen).InverseMod(p), p);
85 unsigned int plainTextLength = plainText[0];
86 if (plainTextLength > GetMaxSymmetricPlaintextLength(modulusLen))
89 m.
Encode(plainText, plainTextLength);
99 template <
class BASE,
class SCHEME_OPTIONS,
class KEY>
PK_FinalTemplate< ElGamalObjectImpl< DL_EncryptorBase< Integer >, SchemeOptions, SchemeOptions::PublicKey > > Encryptor
implements PK_Encryptor interface
Keys::PrivateKey PrivateKey
const KEY & GetKey() const
Diffie-Hellman key agreement algorithm.
size_t GetSymmetricKeyLength(size_t plainTextLength) const
Utility functions for the Crypto++ library.
#define CRYPTOPP_STATIC_CONSTEXPR
void Encode(byte *output, size_t outputLen, Signedness sign=UNSIGNED) const
Encode in big-endian format.
ElGamal key agreement and encryption schemes default implementation.
Integer a_times_b_mod_c(const Integer &x, const Integer &y, const Integer &m)
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
DL_CryptoKeys_GFP::GroupParameters GroupParameters
ElGamal::Encryptor ElGamalEncryptor
DecodingResult SymmetricDecrypt(const byte *key, const byte *cipherText, size_t cipherTextLength, byte *plainText, const NameValuePairs ¶meters) const
#define NAMESPACE_BEGIN(x)
SchemeOptions::GroupParameters GroupParameters
Converts an enumeration to a type suitable for use as a template parameter.
Abstract base classes that provide a uniform interface to this library.
ElGamal::Decryptor ElGamalDecryptor
Interface for key derivation algorithms used in DL cryptosystems.
Interface for random number generators.
void Derive(const DL_GroupParameters< Integer > &groupParams, byte *derivedKey, size_t derivedLength, const Integer &agreedElement, const Integer &ephemeralPublicKey, const NameValuePairs &derivationParams) const
ElGamal key agreement and encryption schemes keys.
Discrete Log (DL) crypto scheme options.
const DL_SymmetricEncryptionAlgorithm & GetSymmetricEncryptionAlgorithm() const
ElGamal encryption scheme with non-standard padding.
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
size_t GetMaxSymmetricPlaintextLength(size_t cipherTextLength) const
Returns a decoding results.
const DL_KeyAgreementAlgorithm< Integer > & GetKeyAgreementAlgorithm() const
size_t FixedCiphertextLength() const
const DL_KeyDerivationAlgorithm< Integer > & GetKeyDerivationAlgorithm() const
SCHEME_OPTIONS SchemeOptions
Multiple precision integer with arithmetic operations.
Keys::PublicKey PublicKey
Discrete Log (DL) base object implementation.
Classes and functions for schemes based on Discrete Logs (DL) over GF(p)
Classes for the DSA signature algorithm.
const T & STDMIN(const T &a, const T &b)
Replacement function for std::min.
size_t GetSymmetricCiphertextLength(size_t plainTextLength) const
#define CRYPTOPP_NO_VTABLE
size_t FixedMaxPlaintextLength() const
DL_PrivateKey_GFP_OldFormat< DL_CryptoKeys_GFP::PrivateKey > PrivateKey
DL_PublicKey_GFP_OldFormat< DL_CryptoKeys_GFP::PublicKey > PublicKey
void * memcpy(void *a, const void *b, size_t c)
#define CRYPTOPP_UNUSED(x)
Multiple precision integer with arithmetic operations.
virtual ~ElGamalObjectImpl()
ElGamal key agreement and encryption schemes base class.
DecodingResult FixedLengthDecrypt(RandomNumberGenerator &rng, const byte *cipherText, byte *plainText) const
std::vector< char * > parameters
void SymmetricEncrypt(RandomNumberGenerator &rng, const byte *key, const byte *plainText, size_t plainTextLength, byte *cipherText, const NameValuePairs ¶meters) const
Interface for symmetric encryption algorithms used in DL cryptosystems.
DL_CryptoSchemeOptions< ElGamal, ElGamalKeys, int, int, int > SchemeOptions
PK_FinalTemplate< ElGamalObjectImpl< DL_DecryptorBase< Integer >, SchemeOptions, SchemeOptions::PrivateKey > > Decryptor
implements PK_Decryptor interface
unsigned int ByteCount() const
Determines the number of bytes required to represent the Integer.
Interface for retrieving values given their names.
Template implementing constructors for public key algorithm classes.
const DL_GroupParameters_GFP & GetGroupParameters() const