From 1c7dbb21d19702872379421e6ae44a15caf67da2 Mon Sep 17 00:00:00 2001 From: lloyd Date: Fri, 5 Mar 2010 01:09:28 +0000 Subject: Add signature generation operation classes. Remove sign() from PK_Signing_Key, though for the moment the class remains because there are a few pieces of code that use it to detect if signatures are supported, or for passing to functions in look_pk --- src/pubkey/rw/rw.h | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'src/pubkey/rw/rw.h') diff --git a/src/pubkey/rw/rw.h b/src/pubkey/rw/rw.h index efdca04e7..a46cb5bb3 100644 --- a/src/pubkey/rw/rw.h +++ b/src/pubkey/rw/rw.h @@ -49,11 +49,6 @@ class BOTAN_DLL RW_PrivateKey : public RW_PublicKey, public IF_Scheme_PrivateKey { public: - SecureVector sign(const byte[], u32bit, - RandomNumberGenerator& rng) const; - - bool check_key(RandomNumberGenerator& rng, bool) const; - RW_PrivateKey(const AlgorithmIdentifier& alg_id, const MemoryRegion& key_bits, RandomNumberGenerator& rng) : @@ -66,6 +61,30 @@ class BOTAN_DLL RW_PrivateKey : public RW_PublicKey, IF_Scheme_PrivateKey(rng, p, q, e, d, n) {} RW_PrivateKey(RandomNumberGenerator& rng, u32bit bits, u32bit = 2); + + bool check_key(RandomNumberGenerator& rng, bool) const; + + SecureVector sign(const byte[], u32bit, + RandomNumberGenerator& rng) const; + }; + +class BOTAN_DLL RW_Signature_Operation : public PK_Ops::Signature_Operation + { + public: + RW_Signature_Operation(const RW_PrivateKey& rw); + + u32bit max_input_bits() const { return (n.bits() - 1); } + + SecureVector sign(const byte msg[], u32bit msg_len, + RandomNumberGenerator& rng); + private: + const BigInt& q; + const BigInt& c; + const BigInt& n; + + Fixed_Exponent_Power_Mod powermod_d1_p, powermod_d2_q; + Modular_Reducer mod_p; + u32bit n_bits; }; } -- cgit v1.2.3