byte tagNumber = (byte) (buffer[offset] & 0x1f);
if (tagNumber < 32) {
tag = tagNumber;
endOffset = offset + 1;
} else {
throw new SignatureException("Can't handle tags > 32"); //$NON-NLS-1$
}
if ((buffer[endOffset] & 0x80) == 0) {
// section 8.1.3.4 (doing the short form of the length)
contentLength = buffer[endOffset];
endOffset++;
} else {
// section 8.1.3.5 (doing the long form of the length)
int octetCount = buffer[endOffset] & 0x7f;
if (octetCount > 3)
throw new SignatureException("ContentLength octet count too large: " + octetCount); //$NON-NLS-1$
contentLength = 0;
endOffset++;
for (int i = 0; i < octetCount; i++) {
contentLength <<= 8;
contentLength |= buffer[endOffset] & 0xff;
endOffset++;
}
// section 8.1.3.6 (doing the indefinite form
if (octetCount == 0)
contentLength = -1;
}
contentOffset = endOffset;
if (contentLength != -1)
endOffset += contentLength;
if (endOffset > lastOffset)
throw new SignatureException("Content length too large: " + endOffset + " > " + lastOffset); //$NON-NLS-1$ //$NON-NLS-2$
}