RSAPrivateKey constructor
RSAPrivateKey(])
Create an RSA private key for the given parameters.
The optional public exponent parameter has been deprecated. It does not have to be provided, because it can be calculated from the other values. The optional parameter is retained for backward compatibility, but it does not need to be provided.
Implementation
RSAPrivateKey(BigInt modulus, BigInt privateExponent, this.p, this.q,
[@Deprecated('Public exponent is calculated from the other values')
BigInt? publicExponent])
: super(modulus, privateExponent) {
// Check RSA relationship between p, q and modulus hold true.
if (p! * q! != modulus) {
throw ArgumentError.value('modulus inconsistent with RSA p and q');
}
// Calculate the correct RSA public exponent
_pubExp = privateExponent.modInverse((p! - BigInt.one) * (q! - BigInt.one));
// If explicitly provided, the public exponent value must be correct.
if (publicExponent != null && publicExponent != _pubExp) {
throw ArgumentError(
'public exponent inconsistent with RSA private exponent, p and q');
}
}