ASN1Object.preEncoded is broken
Closed this issue · 0 comments
ThomasKliszowski commented
I tried to implement OPTIONAL tagging on a sequence by doing something like that:
ASN1Sequence()
..add(ASN1Integer.fromInt(1))
..add(ASN1Integer(privateKey.d, tag: OCTET_STRING_TYPE))
..add(ASN1Object.preEncoded(
160,
ASN1ObjectIdentifier.fromComponentString("1.2.840.10045.3.1.7")
.encodedBytes))
..add(ASN1Object.preEncoded(
161, ASN1BitString(publicKey.Q.getEncoded(false)).encodedBytes));
This code gives me a wrong object identifier 1.2.840.10045.3.0.0
.
After investigate a bit, I could find that ASN1Object.preEncoded()
is broken, the range is going from start
to length
, when it should go from start
to start + length
.