Closed JesusMcCloud closed 2 months ago
This encoding test fails for me:
"fails" {
val it = 2204309167L
val bytes = (it).toTwosComplementByteArray()
val fromBC = ASN1Integer(it).encoded
val long = Long.decodeFromDerValue(bytes)
val encoded = Asn1Primitive(Asn1Element.Tag.INT, bytes).derEncoded
encoded shouldBe fromBC
long shouldBe it
}
with
Expected :[2, 5, 0, -125, 99, 22, -81]
Actual :[2, 6, 0, 0, -125, 99, 22, -81]
This encoding test fails for me:
"fails" { val it = 2204309167L val bytes = (it).toTwosComplementByteArray() val fromBC = ASN1Integer(it).encoded val long = Long.decodeFromDerValue(bytes) val encoded = Asn1Primitive(Asn1Element.Tag.INT, bytes).derEncoded encoded shouldBe fromBC long shouldBe it }
with
Expected :[2, 5, 0, -125, 99, 22, -81] Actual :[2, 6, 0, 0, -125, 99, 22, -81]
@iaik-jheher i thought you fixed it?
decodeTag
is broken!. encoding works perfectly fine though, so debugging should be easy
decodeTag
is broken!. encoding works perfectly fine though, so debugging should be easy
was varint decoding bug. fixed now
decodeTag
is broken!. encoding works perfectly fine though, so debugging should be easywas varint decoding bug. fixed now
did you add a test case that covers this, since it was not caught before?
decodeTag
is broken!. encoding works perfectly fine though, so debugging should be easywas varint decoding bug. fixed now
did you add a test case that covers this, since it was not caught before?
totally forgot do test for trainlign bytes. now there's a testcase for longs and ints and both caught the error
TLV.Tag
with an accompanyingTagClass
enum and aconstructed
flag to accurately represent arbitrary tags up toULong.MAX_VALUE
tag
parametersULong
to reflect support for multi-byte tagsDERTags
Int.Companion.decodeFromDer()
->Int.Companion.decodeFromDerValue()
Long.Companion.decodeFromDer()
->Long.Companion.decodeFromDerValue()
ULong.toAsn1VarInt()
to encode ULongs into ASN.1 unsigned VarInts (not to be confused with multi^2_base'sUVarInt
!)decodeAsn1VarULong()
anddecodeAsn1VarUInt()
which can handle overlong inputs, as long as they start with a valid unsigned number encoding.Iterator<Byte>.decodeAsn1VarULong()
Iterable<Byte>.decodeAsn1VarULong()
ByteArray.decodeAsn1VarULong()
Iterator<Byte>.decodeAsn1VarUInt()
Iterable<Byte>.decodeAsn1VarUInt()
ByteArray.decodeAsn1VarUInt()