RsaPrivateKey.decode constructor

RsaPrivateKey.decode(
  1. Uint8List keyBlob
)

Implementation

factory RsaPrivateKey.decode(Uint8List keyBlob) {
  final parser = ASN1Parser(keyBlob);

  final sequence = parser.nextObject() as ASN1Sequence;
  final version = (sequence.elements[0] as ASN1Integer).valueAsBigInteger;
  final n = (sequence.elements[1] as ASN1Integer).valueAsBigInteger;
  final e = (sequence.elements[2] as ASN1Integer).valueAsBigInteger;
  final d = (sequence.elements[3] as ASN1Integer).valueAsBigInteger;
  final p = (sequence.elements[4] as ASN1Integer).valueAsBigInteger;
  final q = (sequence.elements[5] as ASN1Integer).valueAsBigInteger;
  final exponent1 = (sequence.elements[6] as ASN1Integer).valueAsBigInteger;
  final exponent2 = (sequence.elements[7] as ASN1Integer).valueAsBigInteger;
  final coefficient = (sequence.elements[8] as ASN1Integer).valueAsBigInteger;

  return RsaPrivateKey(
    version!,
    n!,
    e!,
    d!,
    p!,
    q!,
    exponent1!,
    exponent2!,
    coefficient!,
  );
}