parse static method
Implementation
static ASN1ObjectIdentifier parse(final MutableIterable bytes) {
if (bytes.length < 2) {
throw Exception('Invalid data!');
}
int tag = bytes.first;
if (tag != ASN1Type.objectIdentifierTag) {
throw Exception('Invalid tag!');
}
bytes.mutate = bytes.skip(1);
final lengthBigInt = ASN1Object.decodeLength(bytes);
int length = lengthBigInt.toInt();
if (length == 0) {
throw Exception('Invalid data');
}
if (bytes.length < length) {
throw Exception('Invalid data');
}
final contentBytes = MutableIterable(bytes.take(length));
bytes.mutate = bytes.skip(length);
final subIdentifiers = <int>[0];
while (contentBytes.isNotEmpty) {
final decoded = _decodedSubIdentifier(contentBytes);
subIdentifiers.add(decoded);
}
subIdentifiers[0] = subIdentifiers[1] ~/ 40;
subIdentifiers[1] = subIdentifiers[1] % 40;
return ASN1ObjectIdentifier(Uint32List.fromList(subIdentifiers));
}