getModulusFromRSACsrPem static method

BigInt getModulusFromRSACsrPem(
  1. String pem
)

Returns the modulus of the given pem that represents an RSA CSR.

This equals the following openssl command:

openssl req -noout -modulus -in FILE.csr

Implementation

static BigInt getModulusFromRSACsrPem(String pem) {
  var data = csrFromPem(pem);
  var bytesString = data.certificationRequestInfo!.publicKeyInfo!.bytes;

  var bytes = _stringAsBytes(bytesString!);
  var rsaPublicKey = CryptoUtils.rsaPublicKeyFromDERBytes(bytes);

  return rsaPublicKey.modulus!;
}