share a common function for reading asn1 integer