ASN1Object.fromBytes constructor

ASN1Object.fromBytes(
  1. Uint8List bytes
)

Create an ASN1Object from the given bytes.

This will typically happen when bytes are read from a socket

Note that is it possible that the supplied encoded bytes could be longer than the actual object (i.e. in a byte stream we dont always know how long an object is until we complete parsing it).

Implementation

ASN1Object.fromBytes(Uint8List bytes) : tag = bytes[0] {
  _encodedBytes = bytes;
  // _initFromBytes();

  var offset = 1; // offset where the length bytes start
  // This is an extended tag if all the lower 5 bits are 1s
  if ((tag & 0x1f) == 0x1f) {
    var (tag, o) = _calculateExtendedTag(bytes);
    _extendedTag = tag;
    offset = o;
  }

  var (l, v) = ASN1Object.decodeLength(_encodedBytes!, offset: offset);
  _valueByteLength = l;
  _valueStartPosition = v;
}