int tag = _in.read();
if (tag == -1)
{
if (_eofFound)
{
throw new EOFException("attempt to read past end of file.");
}
_eofFound = true;
return null;
}
//
// turn of looking for "00" while we resolve the tag
//
set00Check(false);
//
// calculate tag number
//
int baseTagNo = tag & ~DERTags.CONSTRUCTED;
int tagNo = baseTagNo;
if ((tag & DERTags.TAGGED) != 0)
{
tagNo = tag & 0x1f;
//
// with tagged object tag number is bottom 5 bits, or stored at the start of the content
//
if (tagNo == 0x1f)
{
tagNo = 0;
int b = _in.read();
while ((b >= 0) && ((b & 0x80) != 0))
{
tagNo |= (b & 0x7f);
tagNo <<= 7;
b = _in.read();
}
if (b < 0)
{
_eofFound = true;
throw new EOFException("EOF encountered inside tag value.");
}
tagNo |= (b & 0x7f);
}
}