Java Code Examples for org.bouncycastle.asn1.BERTags#SEQUENCE

The following examples show how to use org.bouncycastle.asn1.BERTags#SEQUENCE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XAdESWithPemEncodedCrlTest.java    From dss with GNU Lesser General Public License v2.1 4 votes vote down vote up
private boolean isDerEncoded(byte[] binaries) {
	return binaries != null && binaries.length > 0 && (BERTags.SEQUENCE | BERTags.CONSTRUCTED) == binaries[0];
}
 
Example 2
Source File: CAdESWithPemEncodedCrlTest.java    From dss with GNU Lesser General Public License v2.1 4 votes vote down vote up
private boolean isDerEncoded(byte[] binaries) {
	return binaries != null && binaries.length > 0 && (BERTags.SEQUENCE | BERTags.CONSTRUCTED) == binaries[0];
}
 
Example 3
Source File: AbstractCRLUtils.java    From dss with GNU Lesser General Public License v2.1 4 votes vote down vote up
private boolean isDerEncoded(byte first) {
	return (BERTags.SEQUENCE | BERTags.CONSTRUCTED) == first;
}
 
Example 4
Source File: PAdESWithPemEncodedCrlTest.java    From dss with GNU Lesser General Public License v2.1 4 votes vote down vote up
private boolean isDerEncoded(byte[] binaries) {
	return binaries != null && binaries.length > 0 && (BERTags.SEQUENCE | BERTags.CONSTRUCTED) == binaries[0];
}
 
Example 5
Source File: DSSASN1Utils.java    From dss with GNU Lesser General Public License v2.1 4 votes vote down vote up
public static boolean isASN1SequenceTag(byte tagByte) {
	// BERTags.SEQUENCE | BERTags.CONSTRUCTED = 0x30
	return (BERTags.SEQUENCE | BERTags.CONSTRUCTED) == tagByte;
}
 
Example 6
Source File: CRLParser.java    From dss with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * This method allows to parse the CRL and return the revocation data for a given serial number
 * 
 * @param s
 *            an InputStream with the CRL
 * @param serialNumber
 *            the certificate's serial number
 * @return the X509CRLEntry with the revocation date, the reason,... or null if the serial number is not present in
 *         the CRL
 * @throws IOException
 */
public X509CRLEntry retrieveRevocationInfo(InputStream s, BigInteger serialNumber) throws IOException {
	// Skip CertificateList Sequence info
	consumeTagIntro(s);

	// Read TBSCertList Sequence
	consumeTagIntro(s);

	// Skip all before mandatory thisUpdate
	int tag = -1;
	int tagNo = BERTags.NULL;
	int length = -1;
	do {
		tag = DERUtil.readTag(s);
		tagNo = DERUtil.readTagNumber(s, tag);
		length = DERUtil.readLength(s);
		skip(s, length);
	} while (!isDate(tagNo));

	tag = DERUtil.readTag(s);
	tagNo = DERUtil.readTagNumber(s, tag);
	length = DERUtil.readLength(s);

	// TBSCertList -> nextUpdate (optional)
	if (isDate(tagNo)) {
		skip(s, length);

		tag = DERUtil.readTag(s);
		tagNo = DERUtil.readTagNumber(s, tag);
		length = DERUtil.readLength(s);
	}

	while (tagNo == BERTags.SEQUENCE) {
		tag = DERUtil.readTag(s);

		if (tag < 0) {
			// EOF
			return null;
		}

		tagNo = DERUtil.readTagNumber(s, tag);
		length = DERUtil.readLength(s);

		if (tagNo == BERTags.SEQUENCE) {

			byte[] entryArray = readNbBytes(s, length);

			try (InputStream is = new ByteArrayInputStream(entryArray)) {
				int entryTag = DERUtil.readTag(is);
				int entryTagNo = DERUtil.readTagNumber(is, entryTag);
				int entryLength = DERUtil.readLength(is);

				// SerialNumber
				if (BERTags.INTEGER == entryTagNo) {
					ASN1Integer asn1SerialNumber = rebuildASN1Integer(readNbBytes(is, entryLength));
					if (serialNumber.equals(asn1SerialNumber.getValue())) {
						ASN1Sequence asn1Sequence = rebuildASN1Sequence(entryArray);
						CRLEntry crlEntry = CRLEntry.getInstance(asn1Sequence);
						return new X509CRLEntryObject(crlEntry);
					}
				}
			}
		} else {
			LOG.debug("Should only contain SEQUENCEs : tagNo = {} (ignored)", tagNo);
			skip(s, length);
		}
	}

	return null;
}