DKIM.OpenSslKey.GetIntegerSize C# (CSharp) Method

GetIntegerSize() private static method

private static GetIntegerSize ( [ binr ) : int
binr [
return int
        private static int GetIntegerSize([NotNull]BinaryReader binr)
        {
            if (binr == null)
            {
                throw new ArgumentNullException("binr");
            }

            int count;
            byte bt = binr.ReadByte();
            if (bt != 0x02)		//expect integer
                return 0;
            bt = binr.ReadByte();

            if (bt == 0x81)
                count = binr.ReadByte();	// data size in next byte
            else
                if (bt == 0x82)
                {
                    byte highbyte = binr.ReadByte();
                    byte lowbyte = binr.ReadByte();
                    byte[] modint = { lowbyte, highbyte, 0x00, 0x00 };
                    count = BitConverter.ToInt32(modint, 0);
                }
                else
                {
                    count = bt;		// we already have the data size
                }



            while (binr.ReadByte() == 0x00)
            {	//remove high order zeros in data
                count -= 1;
            }
            binr.BaseStream.Seek(-1, SeekOrigin.Current);		//last ReadByte wasn't a removed zero, so back up a byte
            return count;
        }