some support for UTF8String and PrintableString v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue, 22 Jun 2021 21:41:59 +0200
branchv_0
changeset 16 bb457bb5b515
parent 15 95ca127ba816
child 17 f5281ab3e68f
some support for UTF8String and PrintableString
src/lib/ASN1ContentHandler.h
src/lib/BasicASN1Reader.h
--- a/src/lib/ASN1ContentHandler.h	Mon Jun 21 21:36:01 2021 +0200
+++ b/src/lib/ASN1ContentHandler.h	Tue Jun 22 21:41:59 2021 +0200
@@ -113,7 +113,7 @@
 		handler->writeNull();
 	}
 
-	void writeInteger(int64_t value) override {
+	void writeInteger(int64_t value) override { // TODO: Integer class containing raw data + methods for converting them to particular numeric data types
 		handler->writeInteger(value);
 	}
 
--- a/src/lib/BasicASN1Reader.h	Mon Jun 21 21:36:01 2021 +0200
+++ b/src/lib/BasicASN1Reader.h	Tue Jun 22 21:41:59 2021 +0200
@@ -145,6 +145,17 @@
 			bool value;
 			read((uint8_t*) & value, 1);
 			handlers.writeBoolean(value);
+		} else if (typeHeader.tag == 12 && typeHeader.tagClass == TagClass::Universal) {
+			std::string s;
+			s.resize(typeHeader.length);
+			read((uint8_t*) s.data(), typeHeader.length);
+			handlers.writeString(ASN1ContentHandler::StringType::UTF8String, s);
+		} else if (typeHeader.tag == 19 && typeHeader.tagClass == TagClass::Universal) {
+			// TODO: check encoding
+			std::string s;
+			s.resize(typeHeader.length);
+			read((uint8_t*) s.data(), typeHeader.length);
+			handlers.writeString(ASN1ContentHandler::StringType::PrintableString, s);
 		} else {
 			// TODO: do not skip, parse
 			std::vector<uint8_t> temp(typeHeader.length, 0);