From 6c8904606f6455b82e5ec9fad5f18f1cd587d5ef Mon Sep 17 00:00:00 2001 From: Dimitri Sokolyuk Date: Tue, 30 Jun 2015 19:47:04 +0200 Subject: Add uint --- ber/class.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'ber/class.go') diff --git a/ber/class.go b/ber/class.go index f2915fe..0839c05 100644 --- a/ber/class.go +++ b/ber/class.go @@ -116,3 +116,13 @@ func Ident(b []byte) (Class, Kind, Tag, int) { } return c, k, t, n + 1 } + +func Length(b []byte) (int, int) { + if b[0] & 0x80 != 0 { + l := b[0] & 0x7f + i := unmarshalUint(b[1:l+1]) + return int(i), int(l+1) + } else { + return int(b[0]), 1 + } +} -- cgit v1.2.3