aboutsummaryrefslogtreecommitdiffstats
path: root/src/pubkey/nr
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-03-05 16:25:43 +0000
committerlloyd <[email protected]>2010-03-05 16:25:43 +0000
commitc52cfb67263a9bb227c4b6fb0a0e37ab388f933a (patch)
treefdd87d05cae6e30e84c60d518ae1f99f80bbabff /src/pubkey/nr
parentdf56028cad58fad04b9866326cb62700af8f2fbe (diff)
Remove NR and DSA specific hooks
Diffstat (limited to 'src/pubkey/nr')
-rw-r--r--src/pubkey/nr/nr.cpp15
-rw-r--r--src/pubkey/nr/nr.h6
-rw-r--r--src/pubkey/nr/nr_core.cpp62
-rw-r--r--src/pubkey/nr/nr_core.h37
-rw-r--r--src/pubkey/nr/nr_op.cpp71
-rw-r--r--src/pubkey/nr/nr_op.h53
6 files changed, 2 insertions, 242 deletions
diff --git a/src/pubkey/nr/nr.cpp b/src/pubkey/nr/nr.cpp
index 700e93092..540cfa281 100644
--- a/src/pubkey/nr/nr.cpp
+++ b/src/pubkey/nr/nr.cpp
@@ -16,7 +16,6 @@ NR_PublicKey::NR_PublicKey(const AlgorithmIdentifier& alg_id,
const MemoryRegion<byte>& key_bits) :
DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_57)
{
- core = NR_Core(group, y);
}
/*
@@ -26,16 +25,6 @@ NR_PublicKey::NR_PublicKey(const DL_Group& grp, const BigInt& y1)
{
group = grp;
y = y1;
-
- core = NR_Core(group, y);
- }
-
-/*
-* Nyberg-Rueppel Verification Function
-*/
-SecureVector<byte> NR_PublicKey::verify(const byte sig[], u32bit sig_len) const
- {
- return core.verify(sig, sig_len);
}
/*
@@ -53,8 +42,6 @@ NR_PrivateKey::NR_PrivateKey(RandomNumberGenerator& rng,
y = power_mod(group_g(), x, group_p());
- core = NR_Core(group, y, x);
-
if(x_arg == 0)
gen_check(rng);
else
@@ -68,8 +55,6 @@ NR_PrivateKey::NR_PrivateKey(const AlgorithmIdentifier& alg_id,
{
y = power_mod(group_g(), x, group_p());
- core = NR_Core(group, y, x);
-
load_check(rng);
}
diff --git a/src/pubkey/nr/nr.h b/src/pubkey/nr/nr.h
index 7a6aaf8fb..c6c7d871c 100644
--- a/src/pubkey/nr/nr.h
+++ b/src/pubkey/nr/nr.h
@@ -10,7 +10,8 @@
#include <botan/dl_algo.h>
#include <botan/pk_ops.h>
-#include <botan/nr_core.h>
+#include <botan/numthry.h>
+#include <botan/reducer.h>
namespace Botan {
@@ -23,8 +24,6 @@ class BOTAN_DLL NR_PublicKey : public PK_Verifying_with_MR_Key,
public:
std::string algo_name() const { return "NR"; }
- SecureVector<byte> verify(const byte sig[], u32bit sig_len) const;
-
DL_Group::Format group_format() const { return DL_Group::ANSI_X9_57; }
u32bit message_parts() const { return 2; }
@@ -37,7 +36,6 @@ class BOTAN_DLL NR_PublicKey : public PK_Verifying_with_MR_Key,
NR_PublicKey(const DL_Group& group, const BigInt& pub_key);
protected:
NR_PublicKey() {}
- NR_Core core;
};
/*
diff --git a/src/pubkey/nr/nr_core.cpp b/src/pubkey/nr/nr_core.cpp
deleted file mode 100644
index a87c32d60..000000000
--- a/src/pubkey/nr/nr_core.cpp
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-* NR Core
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/nr_core.h>
-#include <botan/numthry.h>
-#include <botan/internal/pk_engine.h>
-#include <botan/parsing.h>
-#include <algorithm>
-
-namespace Botan {
-
-/*
-* NR_Core Constructor
-*/
-NR_Core::NR_Core(const DL_Group& group, const BigInt& y, const BigInt& x)
- {
- op = Engine_Core::nr_op(group, y, x);
- }
-
-/*
-* NR_Core Copy Constructor
-*/
-NR_Core::NR_Core(const NR_Core& core)
- {
- op = 0;
- if(core.op)
- op = core.op->clone();
- }
-
-/*
-* NR_Core Assignment Operator
-*/
-NR_Core& NR_Core::operator=(const NR_Core& core)
- {
- delete op;
- if(core.op)
- op = core.op->clone();
- return (*this);
- }
-
-/*
-* NR Verification Operation
-*/
-SecureVector<byte> NR_Core::verify(const byte in[], u32bit length) const
- {
- return op->verify(in, length);
- }
-
-/*
-* NR Signature Operation
-*/
-SecureVector<byte> NR_Core::sign(const byte in[], u32bit length,
- const BigInt& k) const
- {
- return op->sign(in, length, k);
- }
-
-}
diff --git a/src/pubkey/nr/nr_core.h b/src/pubkey/nr/nr_core.h
deleted file mode 100644
index 483773622..000000000
--- a/src/pubkey/nr/nr_core.h
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* NR Core
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_NR_CORE_H__
-#define BOTAN_NR_CORE_H__
-
-#include <botan/nr_op.h>
-#include <botan/dl_group.h>
-
-namespace Botan {
-
-/*
-* NR Core
-*/
-class BOTAN_DLL NR_Core
- {
- public:
- SecureVector<byte> sign(const byte[], u32bit, const BigInt&) const;
- SecureVector<byte> verify(const byte[], u32bit) const;
-
- NR_Core& operator=(const NR_Core&);
-
- NR_Core() { op = 0; }
- NR_Core(const NR_Core&);
- NR_Core(const DL_Group&, const BigInt&, const BigInt& = 0);
- ~NR_Core() { delete op; }
- private:
- NR_Operation* op;
- };
-
-}
-
-#endif
diff --git a/src/pubkey/nr/nr_op.cpp b/src/pubkey/nr/nr_op.cpp
deleted file mode 100644
index b5efa3d37..000000000
--- a/src/pubkey/nr/nr_op.cpp
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-* NR Operations
-* (C) 1999-2007 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#include <botan/nr_op.h>
-
-namespace Botan {
-
-/*
-* Default_NR_Op Constructor
-*/
-Default_NR_Op::Default_NR_Op(const DL_Group& grp, const BigInt& y1,
- const BigInt& x1) : x(x1), y(y1), group(grp)
- {
- powermod_g_p = Fixed_Base_Power_Mod(group.get_g(), group.get_p());
- powermod_y_p = Fixed_Base_Power_Mod(y, group.get_p());
- mod_p = Modular_Reducer(group.get_p());
- mod_q = Modular_Reducer(group.get_q());
- }
-
-/*
-* Default NR Verify Operation
-*/
-SecureVector<byte> Default_NR_Op::verify(const byte in[], u32bit length) const
- {
- const BigInt& q = group.get_q();
-
- if(length != 2*q.bytes())
- return false;
-
- BigInt c(in, q.bytes());
- BigInt d(in + q.bytes(), q.bytes());
-
- if(c.is_zero() || c >= q || d >= q)
- throw Invalid_Argument("Default_NR_Op::verify: Invalid signature");
-
- BigInt i = mod_p.multiply(powermod_g_p(d), powermod_y_p(c));
- return BigInt::encode(mod_q.reduce(c - i));
- }
-
-/*
-* Default NR Sign Operation
-*/
-SecureVector<byte> Default_NR_Op::sign(const byte in[], u32bit length,
- const BigInt& k) const
- {
- if(x == 0)
- throw Internal_Error("Default_NR_Op::sign: No private key");
-
- const BigInt& q = group.get_q();
-
- BigInt f(in, length);
-
- if(f >= q)
- throw Invalid_Argument("Default_NR_Op::sign: Input is out of range");
-
- BigInt c = mod_q.reduce(powermod_g_p(k) + f);
- if(c.is_zero())
- throw Internal_Error("Default_NR_Op::sign: c was zero");
- BigInt d = mod_q.reduce(k - x * c);
-
- SecureVector<byte> output(2*q.bytes());
- c.binary_encode(output + (output.size() / 2 - c.bytes()));
- d.binary_encode(output + (output.size() - d.bytes()));
- return output;
- }
-
-}
diff --git a/src/pubkey/nr/nr_op.h b/src/pubkey/nr/nr_op.h
deleted file mode 100644
index cba1465f2..000000000
--- a/src/pubkey/nr/nr_op.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* NR Operations
-* (C) 1999-2008 Jack Lloyd
-*
-* Distributed under the terms of the Botan license
-*/
-
-#ifndef BOTAN_NR_OPS_H__
-#define BOTAN_NR_OPS_H__
-
-#include <botan/pow_mod.h>
-#include <botan/numthry.h>
-#include <botan/reducer.h>
-#include <botan/dl_group.h>
-
-namespace Botan {
-
-/*
-* NR Operation
-*/
-class BOTAN_DLL NR_Operation
- {
- public:
- virtual SecureVector<byte> verify(const byte[], u32bit) const = 0;
- virtual SecureVector<byte> sign(const byte[], u32bit,
- const BigInt&) const = 0;
- virtual NR_Operation* clone() const = 0;
- virtual ~NR_Operation() {}
- };
-
-/*
-* Botan's Default NR Operation
-*/
-class BOTAN_DLL Default_NR_Op : public NR_Operation
- {
- public:
- SecureVector<byte> verify(const byte[], u32bit) const;
- SecureVector<byte> sign(const byte[], u32bit, const BigInt&) const;
-
- NR_Operation* clone() const { return new Default_NR_Op(*this); }
-
- Default_NR_Op(const DL_Group&, const BigInt&, const BigInt&);
- private:
- const BigInt x, y;
- const DL_Group group;
- Fixed_Base_Power_Mod powermod_g_p, powermod_y_p;
- Modular_Reducer mod_p, mod_q;
- };
-
-
-}
-
-#endif