aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-05 17:40:45 +0000
committerlloyd <[email protected]>2010-03-05 17:40:45 +0000
commitbe9d7d1031bba2cd4f415d114389a1f50c61d44b (patch)
treec6714d8c40ac685c98e4b8bfbacdd14d99d64a63
parentcdd1a1509ffc74c74bd902d55a7a85ab9e2afe78 (diff)
Remove IF_Core
-rw-r--r--src/engine/def_engine/def_pk_ops.cpp14
-rw-r--r--src/engine/def_engine/default_engine.h6
-rw-r--r--src/engine/engine.h11
-rw-r--r--src/libstate/pk_engine.cpp21
-rw-r--r--src/libstate/pk_engine.h10
-rw-r--r--src/pubkey/if_algo/if_algo.cpp4
-rw-r--r--src/pubkey/if_algo/if_algo.h3
-rw-r--r--src/pubkey/if_algo/if_core.cpp83
-rw-r--r--src/pubkey/if_algo/if_core.h45
-rw-r--r--src/pubkey/if_algo/if_op.cpp47
-rw-r--r--src/pubkey/if_algo/if_op.h52
-rw-r--r--src/pubkey/if_algo/info.txt12
-rw-r--r--src/pubkey/rsa/rsa.cpp45
-rw-r--r--src/pubkey/rsa/rsa.h9
-rw-r--r--src/pubkey/rw/rw.cpp2
-rw-r--r--src/pubkey/rw/rw.h9
16 files changed, 7 insertions, 366 deletions
diff --git a/src/engine/def_engine/def_pk_ops.cpp b/src/engine/def_engine/def_pk_ops.cpp
index 88880eea6..d3264e67e 100644
--- a/src/engine/def_engine/def_pk_ops.cpp
+++ b/src/engine/def_engine/def_pk_ops.cpp
@@ -8,7 +8,6 @@
#include <botan/internal/default_engine.h>
#if defined(BOTAN_HAS_RSA)
- #include <botan/if_op.h>
#include <botan/rsa.h>
#endif
@@ -168,17 +167,4 @@ Default_Engine::get_verify_op(const Public_Key& key) const
return 0;
}
-#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
-/*
-* Acquire an IF op
-*/
-IF_Operation* Default_Engine::if_op(const BigInt& e, const BigInt& n,
- const BigInt& d, const BigInt& p,
- const BigInt& q, const BigInt& d1,
- const BigInt& d2, const BigInt& c) const
- {
- return new Default_IF_Op(e, n, d, p, q, d1, d2, c);
- }
-#endif
-
}
diff --git a/src/engine/def_engine/default_engine.h b/src/engine/def_engine/default_engine.h
index 9edd25d2b..1e40cfe46 100644
--- a/src/engine/def_engine/default_engine.h
+++ b/src/engine/def_engine/default_engine.h
@@ -32,12 +32,6 @@ class Default_Engine : public Engine
PK_Ops::Decryption* get_decryption_op(const Private_Key& key) const;
-#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
- IF_Operation* if_op(const BigInt&, const BigInt&, const BigInt&,
- const BigInt&, const BigInt&, const BigInt&,
- const BigInt&, const BigInt&) const;
-#endif
-
Modular_Exponentiator* mod_exp(const BigInt& n,
Power_Mod::Usage_Hints) const;
diff --git a/src/engine/engine.h b/src/engine/engine.h
index a3f227412..69592886c 100644
--- a/src/engine/engine.h
+++ b/src/engine/engine.h
@@ -21,10 +21,6 @@
#include <utility>
#include <map>
-#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
- #include <botan/if_op.h>
-#endif
-
namespace Botan {
class Algorithm_Factory;
@@ -91,13 +87,6 @@ class BOTAN_DLL Engine
{
return 0;
}
-
-#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
- virtual IF_Operation* if_op(const BigInt&, const BigInt&, const BigInt&,
- const BigInt&, const BigInt&, const BigInt&,
- const BigInt&, const BigInt&) const
- { return 0; }
-#endif
};
}
diff --git a/src/libstate/pk_engine.cpp b/src/libstate/pk_engine.cpp
index 5b7c3b4e1..2c9ee4bfd 100644
--- a/src/libstate/pk_engine.cpp
+++ b/src/libstate/pk_engine.cpp
@@ -13,27 +13,6 @@ namespace Botan {
namespace Engine_Core {
-#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
-/*
-* Acquire an IF op
-*/
-IF_Operation* if_op(const BigInt& e, const BigInt& n, const BigInt& d,
- const BigInt& p, const BigInt& q, const BigInt& d1,
- const BigInt& d2, const BigInt& c)
- {
- Algorithm_Factory::Engine_Iterator i(global_state().algorithm_factory());
-
- while(const Engine* engine = i.next())
- {
- IF_Operation* op = engine->if_op(e, n, d, p, q, d1, d2, c);
- if(op)
- return op;
- }
-
- throw Lookup_Error("Engine_Core::if_op: Unable to find a working engine");
- }
-#endif
-
/*
* Acquire a modular exponentiator
*/
diff --git a/src/libstate/pk_engine.h b/src/libstate/pk_engine.h
index 8f38b2928..0e6b8dc41 100644
--- a/src/libstate/pk_engine.h
+++ b/src/libstate/pk_engine.h
@@ -11,10 +11,6 @@
#include <botan/bigint.h>
#include <botan/pow_mod.h>
-#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
- #include <botan/if_op.h>
-#endif
-
namespace Botan {
class Algorithm_Factory;
@@ -28,12 +24,6 @@ namespace Engine_Core {
*/
Modular_Exponentiator* mod_exp(const BigInt&, Power_Mod::Usage_Hints);
-#if defined(BOTAN_HAS_IF_PUBLIC_KEY_FAMILY)
-IF_Operation* if_op(const BigInt&, const BigInt&, const BigInt&,
- const BigInt&, const BigInt&, const BigInt&,
- const BigInt&, const BigInt&);
-#endif
-
}
}
diff --git a/src/pubkey/if_algo/if_algo.cpp b/src/pubkey/if_algo/if_algo.cpp
index 1acbad02c..759c30c61 100644
--- a/src/pubkey/if_algo/if_algo.cpp
+++ b/src/pubkey/if_algo/if_algo.cpp
@@ -78,8 +78,6 @@ IF_Scheme_PrivateKey::IF_Scheme_PrivateKey(RandomNumberGenerator& rng,
if(version != 0)
throw Decoding_Error("Unknown PKCS #1 key format version");
- core = IF_Core(rng, e, n, d, p, q, d1, d2, c);
-
load_check(rng);
}
@@ -109,8 +107,6 @@ IF_Scheme_PrivateKey::IF_Scheme_PrivateKey(RandomNumberGenerator& rng,
d2 = d % (q - 1);
c = inverse_mod(q, p);
- core = IF_Core(rng, e, n, d, p, q, d1, d2, c);
-
load_check(rng);
}
diff --git a/src/pubkey/if_algo/if_algo.h b/src/pubkey/if_algo/if_algo.h
index d35c8245f..65bb8aed4 100644
--- a/src/pubkey/if_algo/if_algo.h
+++ b/src/pubkey/if_algo/if_algo.h
@@ -8,7 +8,7 @@
#ifndef BOTAN_IF_ALGO_H__
#define BOTAN_IF_ALGO_H__
-#include <botan/if_core.h>
+#include <botan/bigint.h>
#include <botan/x509_key.h>
#include <botan/pkcs8.h>
#include <botan/pk_ops.h>
@@ -52,7 +52,6 @@ class BOTAN_DLL IF_Scheme_PublicKey : public virtual Public_Key
IF_Scheme_PublicKey() {}
BigInt n, e;
- IF_Core core;
};
/**
diff --git a/src/pubkey/if_algo/if_core.cpp b/src/pubkey/if_algo/if_core.cpp
deleted file mode 100644
index 41ebfe8dd..000000000
--- a/src/pubkey/if_algo/if_core.cpp
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-* IF Algorithm Core
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/if_core.h>
-#include <botan/numthry.h>
-#include <botan/internal/pk_engine.h>
-#include <botan/parsing.h>
-#include <algorithm>
-
-namespace Botan {
-
-/*
-* IF_Core Constructor
-*/
-IF_Core::IF_Core(const BigInt& e, const BigInt& n)
- {
- op = Engine_Core::if_op(e, n, 0, 0, 0, 0, 0, 0);
- }
-
-
-/*
-* IF_Core Constructor
-*/
-IF_Core::IF_Core(RandomNumberGenerator& rng,
- const BigInt& e, const BigInt& n, const BigInt& d,
- const BigInt& p, const BigInt& q,
- const BigInt& d1, const BigInt& d2, const BigInt& c)
- {
- const u32bit BLINDING_BITS = BOTAN_PRIVATE_KEY_OP_BLINDING_BITS;
-
- op = Engine_Core::if_op(e, n, d, p, q, d1, d2, c);
-
- if(BLINDING_BITS)
- {
- BigInt k(rng, std::min(n.bits()-1, BLINDING_BITS));
- blinder = Blinder(power_mod(k, e, n), inverse_mod(k, n), n);
- }
- }
-
-/*
-* IF_Core Copy Constructor
-*/
-IF_Core::IF_Core(const IF_Core& core)
- {
- op = 0;
- if(core.op)
- op = core.op->clone();
- blinder = core.blinder;
- }
-
-/*
-* IF_Core Assignment Operator
-*/
-IF_Core& IF_Core::operator=(const IF_Core& core)
- {
- delete op;
- if(core.op)
- op = core.op->clone();
- blinder = core.blinder;
- return (*this);
- }
-
-/*
-* IF Public Operation
-*/
-BigInt IF_Core::public_op(const BigInt& i) const
- {
- return op->public_op(i);
- }
-
-/*
-* IF Private Operation
-*/
-BigInt IF_Core::private_op(const BigInt& i) const
- {
- return blinder.unblind(op->private_op(blinder.blind(i)));
- }
-
-}
diff --git a/src/pubkey/if_algo/if_core.h b/src/pubkey/if_algo/if_core.h
deleted file mode 100644
index b7f487706..000000000
--- a/src/pubkey/if_algo/if_core.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-* IF Algorithm Core
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_IF_CORE_H__
-#define BOTAN_IF_CORE_H__
-
-#include <botan/if_op.h>
-#include <botan/blinding.h>
-
-namespace Botan {
-
-/*
-* IF Core
-*/
-class BOTAN_DLL IF_Core
- {
- public:
- BigInt public_op(const BigInt&) const;
- BigInt private_op(const BigInt&) const;
-
- IF_Core& operator=(const IF_Core&);
-
- IF_Core() { op = 0; }
- IF_Core(const IF_Core&);
-
- IF_Core(const BigInt&, const BigInt&);
-
- IF_Core(RandomNumberGenerator& rng,
- const BigInt&, const BigInt&,
- const BigInt&, const BigInt&, const BigInt&,
- const BigInt&, const BigInt&, const BigInt&);
-
- ~IF_Core() { delete op; }
- private:
- IF_Operation* op;
- Blinder blinder;
- };
-
-}
-
-#endif
diff --git a/src/pubkey/if_algo/if_op.cpp b/src/pubkey/if_algo/if_op.cpp
deleted file mode 100644
index 27aef453e..000000000
--- a/src/pubkey/if_algo/if_op.cpp
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-* IF (RSA/RW) Operation
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/if_op.h>
-#include <botan/numthry.h>
-
-namespace Botan {
-
-/*
-* Default_IF_Op Constructor
-*/
-Default_IF_Op::Default_IF_Op(const BigInt& e, const BigInt& n, const BigInt&,
- const BigInt& p, const BigInt& q,
- const BigInt& d1, const BigInt& d2,
- const BigInt& c)
- {
- powermod_e_n = Fixed_Exponent_Power_Mod(e, n);
-
- if(d1 != 0 && d2 != 0 && p != 0 && q != 0)
- {
- powermod_d1_p = Fixed_Exponent_Power_Mod(d1, p);
- powermod_d2_q = Fixed_Exponent_Power_Mod(d2, q);
- reducer = Modular_Reducer(p);
- this->c = c;
- this->q = q;
- }
- }
-
-/*
-* Default IF Private Operation
-*/
-BigInt Default_IF_Op::private_op(const BigInt& i) const
- {
- if(q == 0)
- throw Internal_Error("Default_IF_Op::private_op: No private key");
-
- BigInt j1 = powermod_d1_p(i);
- BigInt j2 = powermod_d2_q(i);
- j1 = reducer.reduce(sub_mul(j1, j2, c));
- return mul_add(j1, q, j2);
- }
-
-}
diff --git a/src/pubkey/if_algo/if_op.h b/src/pubkey/if_algo/if_op.h
deleted file mode 100644
index 516902fd9..000000000
--- a/src/pubkey/if_algo/if_op.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-* IF Operations
-* (C) 1999-2008 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_IF_OP_H__
-#define BOTAN_IF_OP_H__
-
-#include <botan/bigint.h>
-#include <botan/pow_mod.h>
-#include <botan/reducer.h>
-
-namespace Botan {
-
-/*
-* IF Operation
-*/
-class BOTAN_DLL IF_Operation
- {
- public:
- virtual BigInt public_op(const BigInt&) const = 0;
- virtual BigInt private_op(const BigInt&) const = 0;
- virtual IF_Operation* clone() const = 0;
- virtual ~IF_Operation() {}
- };
-
-/*
-* Default IF Operation
-*/
-class BOTAN_DLL Default_IF_Op : public IF_Operation
- {
- public:
- BigInt public_op(const BigInt& i) const
- { return powermod_e_n(i); }
- BigInt private_op(const BigInt&) const;
-
- IF_Operation* clone() const { return new Default_IF_Op(*this); }
-
- Default_IF_Op(const BigInt&, const BigInt&, const BigInt&,
- const BigInt&, const BigInt&, const BigInt&,
- const BigInt&, const BigInt&);
- private:
- Fixed_Exponent_Power_Mod powermod_e_n, powermod_d1_p, powermod_d2_q;
- Modular_Reducer reducer;
- BigInt c, q;
- };
-
-}
-
-#endif
diff --git a/src/pubkey/if_algo/info.txt b/src/pubkey/if_algo/info.txt
index c0914cd15..32e50e684 100644
--- a/src/pubkey/if_algo/info.txt
+++ b/src/pubkey/if_algo/info.txt
@@ -2,18 +2,6 @@ define IF_PUBLIC_KEY_FAMILY
load_on dep
-<header:public>
-if_algo.h
-if_core.h
-if_op.h
-</header:public>
-
-<source>
-if_algo.cpp
-if_core.cpp
-if_op.cpp
-</source>
-
<requires>
asn1
bigint
diff --git a/src/pubkey/rsa/rsa.cpp b/src/pubkey/rsa/rsa.cpp
index 13ac1c318..dc182f36a 100644
--- a/src/pubkey/rsa/rsa.cpp
+++ b/src/pubkey/rsa/rsa.cpp
@@ -14,26 +14,6 @@
namespace Botan {
/*
-* RSA Public Operation
-*/
-BigInt RSA_PublicKey::public_op(const BigInt& i) const
- {
- if(i >= n)
- throw Invalid_Argument(algo_name() + "::public_op: input is too large");
- return core.public_op(i);
- }
-
-/*
-* RSA Encryption Function
-*/
-SecureVector<byte> RSA_PublicKey::encrypt(const byte in[], u32bit len,
- RandomNumberGenerator&) const
- {
- BigInt i(in, len);
- return BigInt::encode_1363(public_op(i), n.bytes());
- }
-
-/*
* Create a RSA private key
*/
RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng,
@@ -58,35 +38,10 @@ RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng,
d2 = d % (q - 1);
c = inverse_mod(q, p);
- core = IF_Core(rng, e, n, d, p, q, d1, d2, c);
-
gen_check(rng);
}
/*
-* RSA Private Operation
-*/
-BigInt RSA_PrivateKey::private_op(const byte in[], u32bit length) const
- {
- BigInt i(in, length);
- if(i >= n)
- throw Invalid_Argument(algo_name() + "::private_op: input is too large");
-
- BigInt r = core.private_op(i);
- if(i != public_op(r))
- throw Self_Test_Failure(algo_name() + " private operation check failed");
- return r;
- }
-
-/*
-* RSA Decryption Operation
-*/
-SecureVector<byte> RSA_PrivateKey::decrypt(const byte in[], u32bit len) const
- {
- return BigInt::encode(private_op(in, len));
- }
-
-/*
* Check Private RSA Parameters
*/
bool RSA_PrivateKey::check_key(RandomNumberGenerator& rng, bool strong) const
diff --git a/src/pubkey/rsa/rsa.h b/src/pubkey/rsa/rsa.h
index 794352dce..73c3c347d 100644
--- a/src/pubkey/rsa/rsa.h
+++ b/src/pubkey/rsa/rsa.h
@@ -9,6 +9,7 @@
#define BOTAN_RSA_H__
#include <botan/if_algo.h>
+#include <botan/reducer.h>
namespace Botan {
@@ -28,9 +29,7 @@ class BOTAN_DLL RSA_PublicKey : public PK_Encrypting_Key,
RSA_PublicKey(const AlgorithmIdentifier& alg_id,
const MemoryRegion<byte>& key_bits) :
IF_Scheme_PublicKey(alg_id, key_bits)
- {
- core = IF_Core(e, n);
- }
+ {}
/**
* Create a RSA_PublicKey
@@ -39,9 +38,7 @@ class BOTAN_DLL RSA_PublicKey : public PK_Encrypting_Key,
*/
RSA_PublicKey(const BigInt& n, const BigInt& e) :
IF_Scheme_PublicKey(n, e)
- {
- core = IF_Core(e, n);
- }
+ {}
protected:
RSA_PublicKey() {}
diff --git a/src/pubkey/rw/rw.cpp b/src/pubkey/rw/rw.cpp
index bf66898b2..7b87ce7df 100644
--- a/src/pubkey/rw/rw.cpp
+++ b/src/pubkey/rw/rw.cpp
@@ -40,8 +40,6 @@ RW_PrivateKey::RW_PrivateKey(RandomNumberGenerator& rng,
d2 = d % (q - 1);
c = inverse_mod(q, p);
- core = IF_Core(rng, e, n, d, p, q, d1, d2, c);
-
gen_check(rng);
}
diff --git a/src/pubkey/rw/rw.h b/src/pubkey/rw/rw.h
index 059ba7d48..7d614cf5a 100644
--- a/src/pubkey/rw/rw.h
+++ b/src/pubkey/rw/rw.h
@@ -9,6 +9,7 @@
#define BOTAN_RW_H__
#include <botan/if_algo.h>
+#include <botan/reducer.h>
namespace Botan {
@@ -24,15 +25,11 @@ class BOTAN_DLL RW_PublicKey : public PK_Verifying_with_MR_Key,
RW_PublicKey(const AlgorithmIdentifier& alg_id,
const MemoryRegion<byte>& key_bits) :
IF_Scheme_PublicKey(alg_id, key_bits)
- {
- core = IF_Core(e, n);
- }
+ {}
RW_PublicKey(const BigInt& mod, const BigInt& exponent) :
IF_Scheme_PublicKey(mod, exponent)
- {
- core = IF_Core(e, n);
- }
+ {}
protected:
RW_PublicKey() {}