Extension.fromAsn1 constructor
Extension.fromAsn1(
- ASN1Sequence sequence
Creates a Extension from an ASN1Sequence
.
The ASN.1 definition is:
Extension ::= SEQUENCE { extnID OBJECT IDENTIFIER, critical BOOLEAN DEFAULT FALSE, extnValue OCTET STRING -- contains the DER encoding of an ASN.1 value -- corresponding to the extension type identified -- by extnID }
Implementation
factory Extension.fromAsn1(ASN1Sequence sequence) {
var id = toDart(sequence.elements[0]);
var critical = false;
var octetIndex = 1;
if (sequence.elements.length > 2) {
critical = toDart(sequence.elements[1]);
octetIndex = 2;
}
return Extension(
extnId: id,
isCritical: critical,
extnValue: ExtensionValue.fromAsn1(
ASN1Parser(sequence.elements[octetIndex].contentBytes()!)
.nextObject(),
id));
}