ASN1PrivateKeyInfo.fromPkcs8RsaPem constructor

ASN1PrivateKeyInfo.fromPkcs8RsaPem(
  1. String pem
)

Creates an instance of PrivateKeyInfo for the given pem. The pem should represent a RSA private key in PKCS8.

Implementation

ASN1PrivateKeyInfo.fromPkcs8RsaPem(String pem) {
  var bytes = ASN1Utils.getBytesFromPEMString(pem);
  var asn1Parser = ASN1Parser(bytes);
  var privateKeySeq = asn1Parser.nextObject() as ASN1Sequence;
  version = privateKeySeq.elements!.elementAt(0) as ASN1Integer;
  privateKeyAlgorithm = ASN1AlgorithmIdentifier.fromSequence(
      privateKeySeq.elements!.elementAt(1) as ASN1Sequence);
  privateKey = privateKeySeq.elements!.elementAt(2) as ASN1OctetString;
}