diff options
author | lloyd <[email protected]> | 2010-03-04 17:38:59 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2010-03-04 17:38:59 +0000 |
commit | 788e524d35d01d90c56c825dbf63a96c3c42a32c (patch) | |
tree | 0147300f6b0f6dd2fd1f16e4e8b5b4e55c35c473 /src/pubkey/rw | |
parent | e63bcc23c6121245c143b7b026127ebf0be55c22 (diff) |
New IF constructors, simplifies RSA/RW
Diffstat (limited to 'src/pubkey/rw')
-rw-r--r-- | src/pubkey/rw/rw.cpp | 30 | ||||
-rw-r--r-- | src/pubkey/rw/rw.h | 13 |
2 files changed, 10 insertions, 33 deletions
diff --git a/src/pubkey/rw/rw.cpp b/src/pubkey/rw/rw.cpp index f6d67bbde..259e53a26 100644 --- a/src/pubkey/rw/rw.cpp +++ b/src/pubkey/rw/rw.cpp @@ -15,16 +15,6 @@ namespace Botan { /* -* RW_PublicKey Constructor -*/ -RW_PublicKey::RW_PublicKey(const BigInt& mod, const BigInt& exp) - { - n = mod; - e = exp; - core = IF_Core(e, n); - } - -/* * Rabin-Williams Public Operation */ BigInt RW_PublicKey::public_op(const BigInt& i) const @@ -76,26 +66,6 @@ RW_PrivateKey::RW_PrivateKey(RandomNumberGenerator& rng, } /* -* RW_PrivateKey Constructor -*/ -RW_PrivateKey::RW_PrivateKey(RandomNumberGenerator& rng, - const BigInt& prime1, const BigInt& prime2, - const BigInt& exp, const BigInt& d_exp, - const BigInt& mod) - { - p = prime1; - q = prime2; - e = exp; - d = d_exp; - n = mod; - - if(d == 0) - d = inverse_mod(e, lcm(p - 1, q - 1) >> 1); - - PKCS8_load_hook(rng); - } - -/* * Rabin-Williams Signature Operation */ SecureVector<byte> RW_PrivateKey::sign(const byte in[], u32bit len, diff --git a/src/pubkey/rw/rw.h b/src/pubkey/rw/rw.h index bc8f053b6..d2411d630 100644 --- a/src/pubkey/rw/rw.h +++ b/src/pubkey/rw/rw.h @@ -30,7 +30,12 @@ class BOTAN_DLL RW_PublicKey : public PK_Verifying_with_MR_Key, core = IF_Core(e, n); } - RW_PublicKey(const BigInt& mod, const BigInt& exponent); + RW_PublicKey(const BigInt& mod, const BigInt& exponent) : + IF_Scheme_PublicKey(mod, exponent) + { + core = IF_Core(e, n); + } + protected: RW_PublicKey() {} BigInt public_op(const BigInt&) const; @@ -58,8 +63,10 @@ class BOTAN_DLL RW_PrivateKey : public RW_PublicKey, } RW_PrivateKey(RandomNumberGenerator& rng, - const BigInt&, const BigInt&, const BigInt&, - const BigInt& = 0, const BigInt& = 0); + const BigInt& p, const BigInt& q, + const BigInt& e, const BigInt& d = 0, + const BigInt& n = 0) : + IF_Scheme_PrivateKey(rng, p, q, e, d, n) {} RW_PrivateKey(RandomNumberGenerator& rng, u32bit bits, u32bit = 2); }; |