getModulusFromRSAPrivateKeyPem static method
Returns the modulus of the given pem
that represents an RSA private key.
This equals the following openssl command:
openssl rsa -noout -modulus -in FILE.key
Implementation
static BigInt getModulusFromRSAPrivateKeyPem(String pem) {
RSAPrivateKey privateKey;
switch (getPrivateKeyType(pem)) {
case 'RSA':
privateKey = rsaPrivateKeyFromPem(pem);
return privateKey.modulus!;
case 'RSA_PKCS1':
privateKey = rsaPrivateKeyFromPemPkcs1(pem);
return privateKey.modulus!;
case 'ECC':
throw ArgumentError('ECC private key not supported.');
default:
privateKey = rsaPrivateKeyFromPem(pem);
return privateKey.modulus!;
}
}