--- a/src/ASN1Writer.h Sat Mar 30 01:39:05 2019 +0100
+++ b/src/ASN1Writer.h Sat Mar 30 01:51:54 2019 +0100
@@ -63,6 +63,7 @@
};
enum UniversalType : uint16_t {
+ EndOfContent = 0,
Boolean = 1,
Integer = 2,
OctetString = 4,
@@ -106,6 +107,10 @@
}
}
+ void writeLengthIndefinite() {
+ output.put('\x80');
+ }
+
static bool isLittleEndian() {
int test = 1;
return (*(char *) &test);
@@ -133,20 +138,20 @@
void writeStartSequence() {
sequenceLevel++;
- output.put('\x30');
- output.put('\x80');
+ writeIdentifier(TagClass::Universal, PC::Constructed, UniversalType::Sequence);
+ writeLengthIndefinite();
}
void writeEndSequence() {
if (sequenceLevel == 0) throw cli::RelpipeCLIException(L"Unable to writeEndSequence() if not sequence is currently started.", cli::CLI::EXIT_CODE_UNEXPECTED_ERROR); // should not happen, error in the program
sequenceLevel--;
- output.put('\x00');
- output.put('\x00');
+ writeIdentifier(TagClass::Universal, PC::Primitive, UniversalType::EndOfContent);
+ writeLength(0u);
}
void writeBoolean(const boolean_t& value) {
- output.put('\x01');
- output.put('\x01');
+ writeIdentifier(TagClass::Universal, PC::Primitive, UniversalType::Boolean);
+ writeLength(1u);
output.put(value ? '\xFF' : '\x00');
}