diff options
Diffstat (limited to 'src/pubkey/dsa')
-rw-r--r-- | src/pubkey/dsa/dsa.cpp | 13 | ||||
-rw-r--r-- | src/pubkey/dsa/dsa.h | 6 | ||||
-rw-r--r-- | src/pubkey/dsa/dsa_core.cpp | 63 | ||||
-rw-r--r-- | src/pubkey/dsa/dsa_core.h | 37 | ||||
-rw-r--r-- | src/pubkey/dsa/dsa_op.cpp | 73 | ||||
-rw-r--r-- | src/pubkey/dsa/dsa_op.h | 59 | ||||
-rw-r--r-- | src/pubkey/dsa/info.txt | 12 |
7 files changed, 0 insertions, 263 deletions
diff --git a/src/pubkey/dsa/dsa.cpp b/src/pubkey/dsa/dsa.cpp index 52df9827f..60414195d 100644 --- a/src/pubkey/dsa/dsa.cpp +++ b/src/pubkey/dsa/dsa.cpp @@ -19,16 +19,6 @@ DSA_PublicKey::DSA_PublicKey(const DL_Group& grp, const BigInt& y1) { group = grp; y = y1; - core = DSA_Core(group, y); - } - -/* -* DSA Verification Function -*/ -bool DSA_PublicKey::verify(const byte msg[], u32bit msg_len, - const byte sig[], u32bit sig_len) const - { - return core.verify(msg, msg_len, sig, sig_len); } /* @@ -46,8 +36,6 @@ DSA_PrivateKey::DSA_PrivateKey(RandomNumberGenerator& rng, y = power_mod(group_g(), x, group_p()); - core = DSA_Core(group, y, x); - if(x_arg == 0) gen_check(rng); else @@ -60,7 +48,6 @@ DSA_PrivateKey::DSA_PrivateKey(const AlgorithmIdentifier& alg_id, DL_Scheme_PrivateKey(alg_id, key_bits, DL_Group::ANSI_X9_57) { y = power_mod(group_g(), x, group_p()); - core = DSA_Core(group, y, x); load_check(rng); } diff --git a/src/pubkey/dsa/dsa.h b/src/pubkey/dsa/dsa.h index 68ae34235..f8db77a1b 100644 --- a/src/pubkey/dsa/dsa.h +++ b/src/pubkey/dsa/dsa.h @@ -12,7 +12,6 @@ #include <botan/pk_ops.h> #include <botan/reducer.h> #include <botan/pow_mod.h> -#include <botan/dsa_core.h> namespace Botan { @@ -30,20 +29,15 @@ class BOTAN_DLL DSA_PublicKey : public PK_Verifying_wo_MR_Key, u32bit message_part_size() const { return group_q().bytes(); } u32bit max_input_bits() const { return group_q().bits(); } - bool verify(const byte msg[], u32bit msg_len, - const byte sig[], u32bit sig_len) const; - DSA_PublicKey(const AlgorithmIdentifier& alg_id, const MemoryRegion<byte>& key_bits) : DL_Scheme_PublicKey(alg_id, key_bits, DL_Group::ANSI_X9_57) { - core = DSA_Core(group, y); } DSA_PublicKey(const DL_Group& group, const BigInt& y); protected: DSA_PublicKey() {} - DSA_Core core; }; /* diff --git a/src/pubkey/dsa/dsa_core.cpp b/src/pubkey/dsa/dsa_core.cpp deleted file mode 100644 index d952e10eb..000000000 --- a/src/pubkey/dsa/dsa_core.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* -* DSA Core -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/dsa_core.h> -#include <botan/numthry.h> -#include <botan/internal/pk_engine.h> -#include <botan/parsing.h> -#include <algorithm> - -namespace Botan { - -/* -* DSA_Core Constructor -*/ -DSA_Core::DSA_Core(const DL_Group& group, const BigInt& y, const BigInt& x) - { - op = Engine_Core::dsa_op(group, y, x); - } - -/* -* DSA_Core Copy Constructor -*/ -DSA_Core::DSA_Core(const DSA_Core& core) - { - op = 0; - if(core.op) - op = core.op->clone(); - } - -/* -* DSA_Core Assignment Operator -*/ -DSA_Core& DSA_Core::operator=(const DSA_Core& core) - { - delete op; - if(core.op) - op = core.op->clone(); - return (*this); - } - -/* -* DSA Verification Operation -*/ -bool DSA_Core::verify(const byte msg[], u32bit msg_length, - const byte sig[], u32bit sig_length) const - { - return op->verify(msg, msg_length, sig, sig_length); - } - -/* -* DSA Signature Operation -*/ -SecureVector<byte> DSA_Core::sign(const byte in[], u32bit length, - const BigInt& k) const - { - return op->sign(in, length, k); - } - -} diff --git a/src/pubkey/dsa/dsa_core.h b/src/pubkey/dsa/dsa_core.h deleted file mode 100644 index 8bb16211f..000000000 --- a/src/pubkey/dsa/dsa_core.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -* DSA Core -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_DSA_CORE_H__ -#define BOTAN_DSA_CORE_H__ - -#include <botan/dsa_op.h> -#include <botan/dl_group.h> - -namespace Botan { - -/* -* DSA Core -*/ -class BOTAN_DLL DSA_Core - { - public: - SecureVector<byte> sign(const byte[], u32bit, const BigInt&) const; - bool verify(const byte[], u32bit, const byte[], u32bit) const; - - DSA_Core& operator=(const DSA_Core&); - - DSA_Core() { op = 0; } - DSA_Core(const DSA_Core&); - DSA_Core(const DL_Group&, const BigInt&, const BigInt& = 0); - ~DSA_Core() { delete op; } - private: - DSA_Operation* op; - }; - -} - -#endif diff --git a/src/pubkey/dsa/dsa_op.cpp b/src/pubkey/dsa/dsa_op.cpp deleted file mode 100644 index 5b921441d..000000000 --- a/src/pubkey/dsa/dsa_op.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/* -* DSA Operations -* (C) 1999-2007 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#include <botan/dsa_op.h> - -namespace Botan { - -/* -* Default_DSA_Op Constructor -*/ -Default_DSA_Op::Default_DSA_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 DSA Verify Operation -*/ -bool Default_DSA_Op::verify(const byte msg[], u32bit msg_len, - const byte sig[], u32bit sig_len) const - { - const BigInt& q = group.get_q(); - - if(sig_len != 2*q.bytes() || msg_len > q.bytes()) - return false; - - BigInt r(sig, q.bytes()); - BigInt s(sig + q.bytes(), q.bytes()); - BigInt i(msg, msg_len); - - if(r <= 0 || r >= q || s <= 0 || s >= q) - return false; - - s = inverse_mod(s, q); - s = mod_p.multiply(powermod_g_p(mod_q.multiply(s, i)), - powermod_y_p(mod_q.multiply(s, r))); - - return (mod_q.reduce(s) == r); - } - -/* -* Default DSA Sign Operation -*/ -SecureVector<byte> Default_DSA_Op::sign(const byte in[], u32bit length, - const BigInt& k) const - { - if(x == 0) - throw Internal_Error("Default_DSA_Op::sign: No private key"); - - const BigInt& q = group.get_q(); - BigInt i(in, length); - - BigInt r = mod_q.reduce(powermod_g_p(k)); - BigInt s = mod_q.multiply(inverse_mod(k, q), mul_add(x, r, i)); - - if(r.is_zero() || s.is_zero()) - throw Internal_Error("Default_DSA_Op::sign: r or s was zero"); - - SecureVector<byte> output(2*q.bytes()); - r.binary_encode(output + (output.size() / 2 - r.bytes())); - s.binary_encode(output + (output.size() - s.bytes())); - return output; - } - -} diff --git a/src/pubkey/dsa/dsa_op.h b/src/pubkey/dsa/dsa_op.h deleted file mode 100644 index 47a9d09e1..000000000 --- a/src/pubkey/dsa/dsa_op.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -* DSA Operations -* (C) 1999-2008 Jack Lloyd -* -* Distributed under the terms of the Botan license -*/ - -#ifndef BOTAN_DSA_OPS_H__ -#define BOTAN_DSA_OPS_H__ - -#include <botan/numthry.h> -#include <botan/pow_mod.h> -#include <botan/reducer.h> -#include <botan/dl_group.h> - -namespace Botan { - -/* -* DSA Operation -*/ -class BOTAN_DLL DSA_Operation - { - public: - virtual bool verify(const byte msg[], u32bit msg_len, - const byte sig[], u32bit sig_len) const = 0; - - virtual SecureVector<byte> sign(const byte msg[], u32bit msg_len, - const BigInt& k) const = 0; - - virtual DSA_Operation* clone() const = 0; - - virtual ~DSA_Operation() {} - }; - -/* -* Botan's Default DSA Operation -*/ -class BOTAN_DLL Default_DSA_Op : public DSA_Operation - { - public: - bool verify(const byte msg[], u32bit msg_len, - const byte sig[], u32bit sig_len) const; - - SecureVector<byte> sign(const byte msg[], u32bit msg_len, - const BigInt& k) const; - - DSA_Operation* clone() const { return new Default_DSA_Op(*this); } - - Default_DSA_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 diff --git a/src/pubkey/dsa/info.txt b/src/pubkey/dsa/info.txt index 1248cf68d..d59fe7aa7 100644 --- a/src/pubkey/dsa/info.txt +++ b/src/pubkey/dsa/info.txt @@ -1,17 +1,5 @@ define DSA -<header:public> -dsa.h -dsa_core.h -dsa_op.h -</header:public> - -<source> -dsa.cpp -dsa_core.cpp -dsa_op.cpp -</source> - <requires> dl_algo dl_group |