Search in sources :

Example 86 with ASN1EncodableVector

use of com.github.zhenwei.core.asn1.ASN1EncodableVector in project XobotOS by xamarin.

the class X509V1CertificateGenerator method generateJcaObject.

private X509Certificate generateJcaObject(TBSCertificateStructure tbsCert, byte[] signature) throws CertificateEncodingException {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(tbsCert);
    v.add(sigAlgId);
    v.add(new DERBitString(signature));
    try {
        return new X509CertificateObject(new X509CertificateStructure(new DERSequence(v)));
    } catch (CertificateParsingException e) {
        throw new ExtCertificateEncodingException("exception producing certificate object", e);
    }
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) CertificateParsingException(java.security.cert.CertificateParsingException) X509CertificateObject(org.bouncycastle.jce.provider.X509CertificateObject) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DERBitString(org.bouncycastle.asn1.DERBitString) X509CertificateStructure(org.bouncycastle.asn1.x509.X509CertificateStructure)

Example 87 with ASN1EncodableVector

use of com.github.zhenwei.core.asn1.ASN1EncodableVector in project XobotOS by xamarin.

the class SubjectPublicKeyInfo method toASN1Object.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     * SubjectPublicKeyInfo ::= SEQUENCE {
     *                          algorithm AlgorithmIdentifier,
     *                          publicKey BIT STRING }
     * </pre>
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(algId);
    v.add(keyData);
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 88 with ASN1EncodableVector

use of com.github.zhenwei.core.asn1.ASN1EncodableVector in project XobotOS by xamarin.

the class AttributeTypeAndValue method toASN1Object.

/**
     * <pre>
     * AttributeTypeAndValue ::= SEQUENCE {
     *           type         OBJECT IDENTIFIER,
     *           value        ANY DEFINED BY type }
     * </pre>
     * @return a basic ASN.1 object representation.
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(type);
    v.add(value);
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 89 with ASN1EncodableVector

use of com.github.zhenwei.core.asn1.ASN1EncodableVector in project XobotOS by xamarin.

the class AlgorithmIdentifier method toASN1Object.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *      AlgorithmIdentifier ::= SEQUENCE {
     *                            algorithm OBJECT IDENTIFIER,
     *                            parameters ANY DEFINED BY algorithm OPTIONAL }
     * </pre>
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(objectId);
    if (parametersDefined) {
        if (parameters != null) {
            v.add(parameters);
        } else {
            v.add(DERNull.INSTANCE);
        }
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 90 with ASN1EncodableVector

use of com.github.zhenwei.core.asn1.ASN1EncodableVector in project XobotOS by xamarin.

the class GeneralSubtree method toASN1Object.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * 
     * Returns:
     * 
     * <pre>
     *       GeneralSubtree ::= SEQUENCE 
     *       {
     *         base                    GeneralName,
     *         minimum         [0]     BaseDistance DEFAULT 0,
     *         maximum         [1]     BaseDistance OPTIONAL 
     *       }
     * </pre>
     * 
     * @return a DERObject
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(base);
    if (minimum != null && !minimum.getValue().equals(ZERO)) {
        v.add(new DERTaggedObject(false, 0, minimum));
    }
    if (maximum != null) {
        v.add(new DERTaggedObject(false, 1, maximum));
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Aggregations

ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)391 ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)330 DERSequence (org.bouncycastle.asn1.DERSequence)318 DERSequence (com.github.zhenwei.core.asn1.DERSequence)286 IOException (java.io.IOException)104 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)91 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)70 DEROctetString (org.bouncycastle.asn1.DEROctetString)70 DERTaggedObject (com.github.zhenwei.core.asn1.DERTaggedObject)68 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)57 ASN1Integer (com.github.zhenwei.core.asn1.ASN1Integer)49 DEROctetString (com.github.zhenwei.core.asn1.DEROctetString)49 X509Certificate (java.security.cert.X509Certificate)40 BigInteger (java.math.BigInteger)38 DERBitString (org.bouncycastle.asn1.DERBitString)35 DERSet (org.bouncycastle.asn1.DERSet)34 Enumeration (java.util.Enumeration)31 ArrayList (java.util.ArrayList)30 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)28 Iterator (java.util.Iterator)26