aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-04 18:45:24 +0000
committerlloyd <[email protected]>2010-03-04 18:45:24 +0000
commitc17ef3dd93bddc7afe3cee1cc4a413f21e93793c (patch)
tree4c288fe990cd858255a56aa9aef9987f39270301 /src
parent12eea3fc8bbe46ec2d0db20262b21df3e4b7c160 (diff)
Remove ElGamal load hook functions
Diffstat (limited to 'src')
-rw-r--r--src/pubkey/elgamal/elgamal.cpp44
-rw-r--r--src/pubkey/elgamal/elgamal.h26
2 files changed, 23 insertions, 47 deletions
diff --git a/src/pubkey/elgamal/elgamal.cpp b/src/pubkey/elgamal/elgamal.cpp
index e3215f757..6fe28a177 100644
--- a/src/pubkey/elgamal/elgamal.cpp
+++ b/src/pubkey/elgamal/elgamal.cpp
@@ -20,14 +20,6 @@ ElGamal_PublicKey::ElGamal_PublicKey(const DL_Group& grp, const BigInt& y1)
{
group = grp;
y = y1;
- X509_load_hook();
- }
-
-/*
-* Algorithm Specific X.509 Initialization Code
-*/
-void ElGamal_PublicKey::X509_load_hook()
- {
core = ELG_Core(group, y);
}
@@ -43,14 +35,6 @@ ElGamal_PublicKey::encrypt(const byte in[], u32bit length,
}
/*
-* Return the maximum input size in bits
-*/
-u32bit ElGamal_PublicKey::max_input_bits() const
- {
- return (group_p().bits() - 1);
- }
-
-/*
* ElGamal_PrivateKey Constructor
*/
ElGamal_PrivateKey::ElGamal_PrivateKey(RandomNumberGenerator& rng,
@@ -61,30 +45,28 @@ ElGamal_PrivateKey::ElGamal_PrivateKey(RandomNumberGenerator& rng,
x = x_arg;
if(x == 0)
- {
x.randomize(rng, 2 * dl_work_factor(group_p().bits()));
- PKCS8_load_hook(rng, true);
- }
- else
- PKCS8_load_hook(rng, false);
- }
-/*
-* Algorithm Specific PKCS #8 Initialization Code
-*/
-void ElGamal_PrivateKey::PKCS8_load_hook(RandomNumberGenerator& rng,
- bool generated)
- {
- if(y == 0)
- y = power_mod(group_g(), x, group_p());
+ y = power_mod(group_g(), x, group_p());
+
core = ELG_Core(rng, group, y, x);
- if(generated)
+ if(x_arg == 0)
gen_check(rng);
else
load_check(rng);
}
+ElGamal_PrivateKey::ElGamal_PrivateKey(const AlgorithmIdentifier& alg_id,
+ const MemoryRegion<byte>& key_bits,
+ RandomNumberGenerator& rng) :
+ DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
+ {
+ y = power_mod(group_g(), x, group_p());
+ core = ELG_Core(rng, group, y, x);
+ load_check(rng);
+ }
+
/*
* ElGamal Decryption Function
*/
diff --git a/src/pubkey/elgamal/elgamal.h b/src/pubkey/elgamal/elgamal.h
index 92adf108d..3ae8f3a6b 100644
--- a/src/pubkey/elgamal/elgamal.h
+++ b/src/pubkey/elgamal/elgamal.h
@@ -23,21 +23,20 @@ class BOTAN_DLL ElGamal_PublicKey : public PK_Encrypting_Key,
std::string algo_name() const { return "ElGamal"; }
DL_Group::Format group_format() const { return DL_Group::ANSI_X9_42; }
- SecureVector<byte> encrypt(const byte[], u32bit,
+ u32bit max_input_bits() const { return (group_p().bits() - 1); }
+
+ SecureVector<byte> encrypt(const byte msg[], u32bit msg_len,
RandomNumberGenerator& rng) const;
- u32bit max_input_bits() const;
ElGamal_PublicKey(const AlgorithmIdentifier& alg_id,
const MemoryRegion<byte>& key_bits) :
DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
- { X509_load_hook(); }
+ { core = ELG_Core(group, y); }
- ElGamal_PublicKey(const DL_Group&, const BigInt&);
+ ElGamal_PublicKey(const DL_Group& group, const BigInt& y);
protected:
ElGamal_PublicKey() {}
ELG_Core core;
- private:
- void X509_load_hook();
};
/*
@@ -48,22 +47,17 @@ class BOTAN_DLL ElGamal_PrivateKey : public ElGamal_PublicKey,
public virtual DL_Scheme_PrivateKey
{
public:
- SecureVector<byte> decrypt(const byte[], u32bit) const;
+ SecureVector<byte> decrypt(const byte msg[], u32bit msg_len) const;
bool check_key(RandomNumberGenerator& rng, bool) const;
ElGamal_PrivateKey(const AlgorithmIdentifier& alg_id,
const MemoryRegion<byte>& key_bits,
- RandomNumberGenerator& rng) :
- DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_42)
- {
- PKCS8_load_hook(rng);
- }
+ RandomNumberGenerator& rng);
- ElGamal_PrivateKey(RandomNumberGenerator&, const DL_Group&,
- const BigInt& = 0);
- private:
- void PKCS8_load_hook(RandomNumberGenerator&, bool = false);
+ ElGamal_PrivateKey(RandomNumberGenerator& rng,
+ const DL_Group& group,
+ const BigInt& priv_key = 0);
};
}