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/rsa | |
parent | e63bcc23c6121245c143b7b026127ebf0be55c22 (diff) |
New IF constructors, simplifies RSA/RW
Diffstat (limited to 'src/pubkey/rsa')
-rw-r--r-- | src/pubkey/rsa/rsa.cpp | 30 | ||||
-rw-r--r-- | src/pubkey/rsa/rsa.h | 23 |
2 files changed, 15 insertions, 38 deletions
diff --git a/src/pubkey/rsa/rsa.cpp b/src/pubkey/rsa/rsa.cpp index 33999f1cd..c606e5c53 100644 --- a/src/pubkey/rsa/rsa.cpp +++ b/src/pubkey/rsa/rsa.cpp @@ -14,16 +14,6 @@ namespace Botan { /* -* RSA_PublicKey Constructor -*/ -RSA_PublicKey::RSA_PublicKey(const BigInt& mod, const BigInt& exp) - { - n = mod; - e = exp; - core = IF_Core(e, n); - } - -/* * RSA Public Operation */ BigInt RSA_PublicKey::public_op(const BigInt& i) const @@ -76,26 +66,6 @@ RSA_PrivateKey::RSA_PrivateKey(RandomNumberGenerator& rng, } /* -* RSA_PrivateKey Constructor -*/ -RSA_PrivateKey::RSA_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)); - - PKCS8_load_hook(rng); - } - -/* * RSA Private Operation */ BigInt RSA_PrivateKey::private_op(const byte in[], u32bit length) const diff --git a/src/pubkey/rsa/rsa.h b/src/pubkey/rsa/rsa.h index c1210d22a..ce79e2440 100644 --- a/src/pubkey/rsa/rsa.h +++ b/src/pubkey/rsa/rsa.h @@ -39,7 +39,12 @@ class BOTAN_DLL RSA_PublicKey : public PK_Encrypting_Key, * @arg n the modulus * @arg e the exponent */ - RSA_PublicKey(const BigInt& n, const BigInt& e); + RSA_PublicKey(const BigInt& n, const BigInt& e) : + IF_Scheme_PublicKey(n, e) + { + core = IF_Core(e, n); + } + protected: RSA_PublicKey() {} BigInt public_op(const BigInt&) const; @@ -71,19 +76,21 @@ class BOTAN_DLL RSA_PrivateKey : public RSA_PublicKey, /** * Construct a private key from the specified parameters. - * @param rng the random number generator to use - * @param prime1 the first prime - * @param prime2 the second prime - * @param exp the exponent - * @param d_exp if specified, this has to be d with + * @param rng a random number generator + * @param p the first prime + * @param q the second prime + * @param e the exponent + * @param d if specified, this has to be d with * exp * d = 1 mod (p - 1, q - 1). Leave it as 0 if you wish to * the constructor to calculate it. * @param n if specified, this must be n = p * q. Leave it as 0 * if you wish to the constructor to calculate it. */ RSA_PrivateKey(RandomNumberGenerator& rng, - const BigInt& p, const BigInt& q, const BigInt& e, - const BigInt& d = 0, const BigInt& n = 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) {} /** * Create a new private key with the specified bit length |