diff options
author | Michael Grosshans <michael.grosshans@freiheit.com> | 2017-01-04 15:23:38 +0100 |
---|---|---|
committer | Michael Grosshans <michael.grosshans@freiheit.com> | 2017-01-04 15:23:38 +0100 |
commit | e8fcb80412352832e63f8a5859687729d358461b (patch) | |
tree | e70a4cc58e8a27a93b4303d9d0a8b2fe5309fcb4 | |
parent | Fixed String Decoding (diff) | |
download | asn1-ber-e8fcb80412352832e63f8a5859687729d358461b.tar asn1-ber-e8fcb80412352832e63f8a5859687729d358461b.tar.gz asn1-ber-e8fcb80412352832e63f8a5859687729d358461b.tar.bz2 asn1-ber-e8fcb80412352832e63f8a5859687729d358461b.tar.lz asn1-ber-e8fcb80412352832e63f8a5859687729d358461b.tar.xz asn1-ber-e8fcb80412352832e63f8a5859687729d358461b.tar.zst asn1-ber-e8fcb80412352832e63f8a5859687729d358461b.zip |
-rw-r--r-- | ber.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -290,7 +290,14 @@ func EncodeInteger(val uint64) []byte { mask = mask >> 8 } - return out.Bytes() + byteSlice := out.Bytes() + + // if first bit in first byte is 1 it is necessary to append a leading 00 byte to make signum clear + // otherwise it happens that a request with messageId => 02 01 80 get response with messageId => 02 04 FF FF FF 80 + if len(byteSlice) > 0 && byteSlice[0]&byte(128) != 0 { + return append([]byte{0x00}, byteSlice...) + } + return byteSlice } func DecodePacket(data []byte) *Packet { |