ASN1OctetString.fromBytes constructor

ASN1OctetString.fromBytes(
  1. Uint8List encodedBytes
)

Creates an ASN1OctetString entity from the given encodedBytes.

Implementation

ASN1OctetString.fromBytes(Uint8List encodedBytes)
    : super.fromBytes(encodedBytes) {
  if (ASN1Utils.isConstructed(encodedBytes.elementAt(0))) {
    elements = [];
    var parser = ASN1Parser(valueBytes);
    var bytes = <int>[];
    while (parser.hasNext()) {
      var octetString = parser.nextObject() as ASN1OctetString;
      bytes.addAll(octetString.octets!);
      elements!.add(octetString);
    }
    octets = Uint8List.fromList(bytes);
  } else {
    octets = valueBytes;
  }
}