--- a/src/lib/BasicASN1Reader.h Sun Jun 20 21:06:02 2021 +0200
+++ b/src/lib/BasicASN1Reader.h Mon Jun 21 21:36:01 2021 +0200
@@ -72,6 +72,7 @@
if (l.definiteLength && l.length == getBytesRead() - l.start) {
level.pop_back();
handlers.writeCollectionEnd();
+ checkRemainingItems(); // multiple collections may end at the same point
}
}
}
@@ -123,17 +124,21 @@
handlers.writeStreamStart();
started = true;
}
-
+
// TODO: check tagClass and pc
// TODO: constants, more types
- if (typeHeader.tag == 0) handlers.writeCollectionEnd();
- else if (typeHeader.tag == 16) {
+ if (typeHeader.tag == 0 && typeHeader.tagClass == TagClass::Universal && typeHeader.pc == PC::Primitive) {
+ handlers.writeCollectionEnd();
+ } else if (typeHeader.tag == 16) {
level.push_back({typeHeader.definiteLength, typeHeader.length, getBytesRead()}); // TODO: transaction
handlers.writeCollectionStart(ASN1ContentHandler::CollectionType::Sequence);
} else if (typeHeader.tag == 17) {
level.push_back({typeHeader.definiteLength, typeHeader.length, getBytesRead()}); // TODO: transaction
handlers.writeCollectionStart(ASN1ContentHandler::CollectionType::Set);
+ } else if (typeHeader.pc == PC::Constructed) {
+ level.push_back({typeHeader.definiteLength, typeHeader.length, getBytesRead()}); // TODO: transaction
+ handlers.writeCollectionStart(ASN1ContentHandler::CollectionType::Constructed);
} else if (typeHeader.tag == 5 && typeHeader.length == 0) {
handlers.writeNull();
} else if (typeHeader.tag == 1) {
@@ -190,8 +195,9 @@
public:
void close() override {
+ checkRemainingItems();
// TODO: check the bytes remaining in the buffer
- //if (started) handlers.writeStreamEnd();
+ if (started) handlers.writeStreamEnd();
}
};