encode method
Encodes this ASN1Object depending on the given encodingRule
If no ASN1EncodingRule is given, ENCODING_DER will be used.
Supported encoding rules are :
Throws an UnsupportedAsn1EncodingRuleException if the given encodingRule
is not supported.
Implementation
@override
Uint8List encode(
{ASN1EncodingRule encodingRule = ASN1EncodingRule.ENCODING_DER}) {
if (encodingRule != ASN1EncodingRule.ENCODING_DER) {
throw UnsupportedAsn1EncodingRuleException(encodingRule);
}
var oi = <int>[];
oi.add(objectIdentifier![0] * 40 + objectIdentifier![1]);
for (var ci = 2; ci < objectIdentifier!.length; ci++) {
var position = oi.length;
var v = objectIdentifier![ci];
assert(v >= 0);
var first = true;
do {
var remainder = v & 127;
v = v >> 7;
if (first) {
first = false;
} else {
remainder |= 0x80;
}
oi.insert(position, remainder);
} while (v > 0);
}
valueBytes = Uint8List.fromList(oi);
valueByteLength = oi.length;
return super.encode();
}