ASN1Object.fromBytes constructor

ASN1Object.fromBytes(
  1. Uint8List? encodedBytes
)

Creates a new ASN1Object from the given encodedBytes.

The first byte will be used as the tag.The field valueStartPosition and valueByteLength will be calculated on the given encodedBytes.

Implementation

ASN1Object.fromBytes(this.encodedBytes) {
  tag = encodedBytes![0];
  isConstructed = ASN1Utils.isConstructed(tag!);
  valueByteLength = ASN1Utils.decodeLength(encodedBytes!);
  valueStartPosition = ASN1Utils.calculateValueStartPosition(encodedBytes!);
  if (valueByteLength == -1) {
    // Indefinite length, check the last to bytes
    if (ASN1Utils.hasIndefiniteLengthEnding(encodedBytes!)) {
      valueByteLength = encodedBytes!.length - 4;
    }
  }
  valueBytes = Uint8List.view(encodedBytes!.buffer,
      valueStartPosition + encodedBytes!.offsetInBytes, valueByteLength);
}