func decodeInteger(bytes []byte) (int64, bool) {
	if len(bytes) == 0 {
		return 0, false
	}
	if len(bytes) > 1 && (bytes[0] == 0 || bytes[0] == 0xff) && bytes[0]&0x80 == bytes[1]&0x80 {
		return 0, false
	}
	val := int64(bytes[0])
	if val&0x80 != 0 {
		val -= 256
	}
	for _, v := range bytes[1:] {
		if (val<<8)>>8 != val {
			return 0, false
		}
		val <<= 8
		val |= int64(v)
	}
	return val, true
}
decodeInteger decodes bytes as the contents of a DER INTEGER. It returns the
value on success and false otherwise.
package main
import "github.com/google/der-ascii/internal"
func parseBase128(bytes []byte) (ret uint32, lengthOverride int, rest []byte, ok bool) {
	rest = bytes
	if len(rest) == 0 {
		return
	}
	isMinimal := rest[0] != 0x80
	for {
		if len(rest) == 0 || (ret<<7)>>7 != ret {
			return
		}
		b := rest[0]
		ret <<= 7
		ret |= uint32(b & 0x7f)
		rest = rest[1:]
		if b&0x80 == 0 {
			ok = true
			if !isMinimal {
				lengthOverride = len(bytes) - len(rest)
			}
			return
		}
	}
}
func parseTag(bytes []byte) (tag internal.Tag, rest []byte, ok bool) {
	rest = bytes
	if len(rest) == 0 {
		return
	}
	b := rest[0]
	rest = rest[1:]
	class := internal.Class(b & 0xc0)
	number := uint32(b & 0x1f)
	constructed := b&0x20 != 0
	if number < 0x1f {
		tag = internal.Tag{class, number, constructed, 0}
		ok = true
		return
	}
	n, lengthOverride, rest, base128Ok := parseBase128(rest)
	if !base128Ok {
		rest = bytes
		return
	}
	if n < 0x1f {
		lengthOverride = len(bytes) - len(rest) - 1
	}
	number = n
	tag = internal.Tag{class, number, constructed, lengthOverride}
	ok = true
	return
}
type element struct {
	tag              internal.Tag
	body             []byte
	indefinite       bool
	longFormOverride int
}
func parseTagAndLength(bytes []byte) (elem element, length int, rest []byte, ok bool) {
	rest = bytes
	var tagOk bool
	elem.tag, bytes, tagOk = parseTag(bytes)
	if !tagOk {
		return
	}
	if len(bytes) == 0 {
		return
	}
	b := bytes[0]
	bytes = bytes[1:]
	if b < 0x80 {
		length = int(b)
	} else if b == 0x80 {
		if !elem.tag.Constructed {
			return  
		}
		elem.indefinite = true
	} else {
		b &= 0x7f
		if int(b) > len(bytes) {
			return  
		}
		for i := 0; i < int(b); i++ {
			if length >= 1<<23 {
				return  
			}
			length <<= 8
			length |= int(bytes[i])
		}
		if bytes[0] == 0 || length < 0x80 {
			elem.longFormOverride = int(b)  
		}
		bytes = bytes[b:]
	}
	ok = true
	rest = bytes
	return
}
func parseElement(bytes []byte) (elem element, rest []byte, ok bool) {
	rest = bytes
	var length int
	elem, length, bytes, ok = parseTagAndLength(bytes)
	if !ok {
		return
	}
	if !elem.indefinite {
		if length > len(bytes) {
			ok = false
			return
		}
		elem.body = bytes[:length]
		bytes = bytes[length:]
	}
	rest = bytes
	return
}