ASN1Pfx.fromSequence constructor

ASN1Pfx.fromSequence(
  1. ASN1Sequence seq
)

Creates an instance of PFX from the given sequence. The sequence must have at least 2 elements.

Implementation

ASN1Pfx.fromSequence(ASN1Sequence seq) {
  if (seq.elements == null || seq.elements!.isEmpty) {
    throw ArgumentError('Empty sequence');
  }
  if (seq.elements!.length == 1) {
    throw ArgumentError('Sequence has not enough elements');
  }
  version = seq.elements!.elementAt(0) as ASN1Integer;
  if (version.integer!.toInt() != 3) {
    throw ArgumentError('Wrong version for PFX PDU');
  }
  authSafe = ASN1ContentInfo.fromSequence(
      seq.elements!.elementAt(1) as ASN1Sequence);
  if (seq.elements!.length == 3) {
    macData =
        ASN1MacData.fromSequence(seq.elements!.elementAt(2) as ASN1Sequence);
  }
}