PrivateKeyUsagePeriod.fromAsn1 constructor

PrivateKeyUsagePeriod.fromAsn1(
  1. ASN1Sequence sequence
)

Creates a basic constraints extension value from an ASN1Sequence.

The ASN.1 definition is:

PrivateKeyUsagePeriod ::= SEQUENCE { notBefore 0 GeneralizedTime OPTIONAL, notAfter 1 GeneralizedTime OPTIONAL }

Implementation

factory PrivateKeyUsagePeriod.fromAsn1(ASN1Sequence sequence) {
  DateTime? notBefore;
  DateTime? notAfter;
  for (ASN1Object o in sequence.elements) {
    var taggedObject = o;
    if (taggedObject.tag == 128) {
      notBefore = ASN1GeneralizedTime.fromBytes(o.encodedBytes).dateTimeValue;
    } else if (taggedObject.tag == 129) {
      notAfter = ASN1GeneralizedTime.fromBytes(o.encodedBytes).dateTimeValue;
    }
  }
  return PrivateKeyUsagePeriod(notBefore: notBefore, notAfter: notAfter);
}