diff options
-rw-r--r-- | ber/bits.go | 18 | ||||
-rw-r--r-- | parse/parse.go | 2 |
2 files changed, 20 insertions, 0 deletions
diff --git a/ber/bits.go b/ber/bits.go new file mode 100644 index 0000000..42474e5 --- /dev/null +++ b/ber/bits.go @@ -0,0 +1,18 @@ +package ber + +// BitString +type Bits struct { + Bytes []byte + Length int +} + +func parseBitString(b []byte) (bs Bits) { + padding := int(b[0]) + bs.Length = (len(b)-1)*8 - padding + bs.Bytes = b[1:] + return +} + +func UnmarshalBitString(b []byte) Bits { + return parseBitString(b) +} diff --git a/parse/parse.go b/parse/parse.go index eb67e8a..1a6a77f 100644 --- a/parse/parse.go +++ b/parse/parse.go @@ -19,6 +19,8 @@ func dump(b []byte, indent int) { fmt.Println(tag, ber.UnmarshalInt(value)) case ber.ObjectIdentifier: fmt.Println(tag, ber.UnmarshalOID(value)) + case ber.BitString: + fmt.Println(tag, ber.UnmarshalBitString(value)) default: if len(value) > 5 { fmt.Println(tag, kind, value[:5], "...") |