| 48 | |
| 49 | |
| 50 | Integer RSA_PrivateKey::CalculateInverse(RandomNumberGenerator& rng, |
| 51 | const Integer& x) const |
| 52 | { |
| 53 | ModularArithmetic modn(n_); |
| 54 | |
| 55 | Integer r(rng, Integer::One(), n_ - Integer::One()); |
| 56 | Integer re = modn.Exponentiate(r, e_); |
| 57 | re = modn.Multiply(re, x); // blind |
| 58 | |
| 59 | // here we follow the notation of PKCS #1 and let u=q inverse mod p |
| 60 | // but in ModRoot, u=p inverse mod q, so we reverse the order of p and q |
| 61 | |
| 62 | Integer y = ModularRoot(re, dq_, dp_, q_, p_, u_); |
| 63 | y = modn.Divide(y, r); // unblind |
| 64 | |
| 65 | return y; |
| 66 | } |
| 67 | |
| 68 | |
| 69 | RSA_PrivateKey::RSA_PrivateKey(Source& source) |
no test coverage detected