Search in sources :

Example 1 with TBSCertList

use of org.bouncycastle.asn1.x509.TBSCertList in project robovm by robovm.

the class CertUtils method generateCRLStructure.

private static CertificateList generateCRLStructure(TBSCertList tbsCertList, AlgorithmIdentifier sigAlgId, byte[] signature) {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(tbsCertList);
    v.add(sigAlgId);
    v.add(new DERBitString(signature));
    return CertificateList.getInstance(new DERSequence(v));
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DERBitString(org.bouncycastle.asn1.DERBitString)

Example 2 with TBSCertList

use of org.bouncycastle.asn1.x509.TBSCertList in project robovm by robovm.

the class CertificateList method toASN1Primitive.

public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(tbsCertList);
    v.add(sigAlgId);
    v.add(sig);
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 3 with TBSCertList

use of org.bouncycastle.asn1.x509.TBSCertList in project XobotOS by xamarin.

the class X509CRLImpl method retrieveEntries.

/*
     * Retrieves the crl entries (TBSCertList.RevokedCertificate objects)
     * from the TBSCertList structure and converts them to the
     * X509CRLEntryImpl objects
     */
private void retrieveEntries() {
    entriesRetrieved = true;
    List rcerts = tbsCertList.getRevokedCertificates();
    if (rcerts == null) {
        return;
    }
    entriesSize = rcerts.size();
    entries = new ArrayList(entriesSize);
    // null means that revoked certificate issuer is the same as CRL issuer
    X500Principal rcertIssuer = null;
    for (int i = 0; i < entriesSize; i++) {
        TBSCertList.RevokedCertificate rcert = (TBSCertList.RevokedCertificate) rcerts.get(i);
        X500Principal iss = rcert.getIssuer();
        if (iss != null) {
            // certificate issuer differs from CRL issuer
            // and CRL is indirect.
            rcertIssuer = iss;
            isIndirectCRL = true;
            // remember how many leading revoked certificates in the
            // list are issued by the same issuer as issuer of CRL
            // (these certificates are first in the list)
            nonIndirectEntriesSize = i;
        }
        entries.add(new X509CRLEntryImpl(rcert, rcertIssuer));
    }
}
Also used : ArrayList(java.util.ArrayList) X500Principal(javax.security.auth.x500.X500Principal) ArrayList(java.util.ArrayList) TBSCertList(org.apache.harmony.security.x509.TBSCertList) CertificateList(org.apache.harmony.security.x509.CertificateList) List(java.util.List) TBSCertList(org.apache.harmony.security.x509.TBSCertList)

Example 4 with TBSCertList

use of org.bouncycastle.asn1.x509.TBSCertList in project XobotOS by xamarin.

the class CertificateList method toASN1Object.

public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(tbsCertList);
    v.add(sigAlgId);
    v.add(sig);
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 5 with TBSCertList

use of org.bouncycastle.asn1.x509.TBSCertList in project candlepin by candlepin.

the class X509CRLStreamWriter method writeNewTime.

/**
 * Write a UTCTime or GeneralizedTime to an output stream.
 *
 * @param out
 * @param newTime
 * @param originalLength
 * @throws IOException
 */
protected void writeNewTime(OutputStream out, ASN1Object newTime, int originalLength) throws IOException {
    byte[] newEncodedTime = newTime.getEncoded();
    InputStream timeIn = null;
    try {
        timeIn = new ByteArrayInputStream(newEncodedTime);
        int newTag = readTag(timeIn, null);
        readTagNumber(timeIn, newTag, null);
        int newLength = readLength(timeIn, null);
        /* If the length changes, it's going to create a discrepancy with the length
             * reported in the TBSCertList sequence.  The length could change with the addition
             * or removal of time zone information for example. */
        if (newLength != originalLength) {
            throw new IllegalStateException("Length of generated time does not match " + "the original length. DER corruption would result.");
        }
    } finally {
        IOUtils.closeQuietly(timeIn);
    }
    writeBytes(out, newEncodedTime);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) ASN1InputStream(org.bouncycastle.asn1.ASN1InputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream)

Aggregations

IOException (java.io.IOException)3 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)3 DERSequence (org.bouncycastle.asn1.DERSequence)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 CRLException (java.security.cert.CRLException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 X500Principal (javax.security.auth.x500.X500Principal)2 CertificateList (org.apache.harmony.security.x509.CertificateList)2 TBSCertList (org.apache.harmony.security.x509.TBSCertList)2 DERBitString (org.bouncycastle.asn1.DERBitString)2 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 BigInteger (java.math.BigInteger)1 Signature (java.security.Signature)1 SignatureException (java.security.SignatureException)1 DSAParams (java.security.interfaces.DSAParams)1