DistributionPoint.fromAsn1 constructor

DistributionPoint.fromAsn1(
  1. ASN1Sequence sequence
)

The ASN.1 definition is:

DistributionPoint ::= SEQUENCE { distributionPoint 0 DistributionPointName OPTIONAL, reasons 1 ReasonFlags OPTIONAL, cRLIssuer 2 GeneralNames OPTIONAL }

Implementation

factory DistributionPoint.fromAsn1(ASN1Sequence sequence) {
  var name = sequence.elements.isEmpty
      ? null
      : DistributionPointName.fromAsn1(
          ASN1Object.fromBytes(sequence.elements[0].valueBytes()));
  var reasons = sequence.elements.length <= 1
      ? null
      : (sequence.elements[1] as ASN1BitString)
          .valueBytes()
          .map((v) => DistributionPointReason.values[v])
          .toList();

  var crlIssuer =
      sequence.elements.length <= 2 ? null : toDart(sequence.elements[2]);
  return DistributionPoint(
      name: name, reasons: reasons, crlIssuer: crlIssuer);
}