Search in sources :

Example 21 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project robovm by robovm.

the class AttributeCertificate method toASN1Primitive.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *  AttributeCertificate ::= SEQUENCE {
     *       acinfo               AttributeCertificateInfo,
     *       signatureAlgorithm   AlgorithmIdentifier,
     *       signatureValue       BIT STRING
     *  }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(acinfo);
    v.add(signatureAlgorithm);
    v.add(signatureValue);
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 22 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project robovm by robovm.

the class X9Curve method toASN1Primitive.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *  Curve ::= SEQUENCE {
     *      a               FieldElement,
     *      b               FieldElement,
     *      seed            BIT STRING      OPTIONAL
     *  }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    if (fieldIdentifier.equals(prime_field)) {
        v.add(new X9FieldElement(curve.getA()).toASN1Primitive());
        v.add(new X9FieldElement(curve.getB()).toASN1Primitive());
    } else if (fieldIdentifier.equals(characteristic_two_field)) {
        v.add(new X9FieldElement(curve.getA()).toASN1Primitive());
        v.add(new X9FieldElement(curve.getB()).toASN1Primitive());
    }
    if (seed != null) {
        v.add(new DERBitString(seed));
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DERBitString(org.bouncycastle.asn1.DERBitString)

Example 23 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project robovm by robovm.

the class EncryptedPrivateKeyInfo method toASN1Primitive.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     * EncryptedPrivateKeyInfo ::= SEQUENCE {
     *      encryptionAlgorithm AlgorithmIdentifier {{KeyEncryptionAlgorithms}},
     *      encryptedData EncryptedData
     * }
     *
     * EncryptedData ::= OCTET STRING
     *
     * KeyEncryptionAlgorithms ALGORITHM-IDENTIFIER ::= {
     *          ... -- For local profiles
     * }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(algId);
    v.add(data);
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 24 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project robovm by robovm.

the class X9ECParameters method toASN1Primitive.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *  ECParameters ::= SEQUENCE {
     *      version         INTEGER { ecpVer1(1) } (ecpVer1),
     *      fieldID         FieldID {{FieldTypes}},
     *      curve           X9Curve,
     *      base            X9ECPoint,
     *      order           INTEGER,
     *      cofactor        INTEGER OPTIONAL
     *  }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(new ASN1Integer(1));
    v.add(fieldID);
    v.add(new X9Curve(curve, seed));
    v.add(new X9ECPoint(g));
    v.add(new ASN1Integer(n));
    if (h != null) {
        v.add(new ASN1Integer(h));
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) ASN1Integer(org.bouncycastle.asn1.ASN1Integer)

Example 25 with ASN1OutputStream

use of org.bouncycastle.asn1.ASN1OutputStream in project robovm by robovm.

the class GeneralSubtree method toASN1Primitive.

/**
     * 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 ASN1Primitive
     */
public ASN1Primitive toASN1Primitive() {
    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)33 DERSequence (org.bouncycastle.asn1.DERSequence)26 ByteArrayOutputStream (java.io.ByteArrayOutputStream)11 ASN1OutputStream (org.bouncycastle.asn1.ASN1OutputStream)11 IOException (java.io.IOException)9 X500Principal (javax.security.auth.x500.X500Principal)7 BERSequence (org.bouncycastle.asn1.BERSequence)7 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)6 BERTaggedObject (org.bouncycastle.asn1.BERTaggedObject)5 Enumeration (java.util.Enumeration)4 PolicyQualifierInfo (java.security.cert.PolicyQualifierInfo)2 HashSet (java.util.HashSet)2 Hashtable (java.util.Hashtable)2 Set (java.util.Set)2 Vector (java.util.Vector)2 DERBitString (org.bouncycastle.asn1.DERBitString)2 DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)2 ExtCertPathValidatorException (org.bouncycastle.jce.exception.ExtCertPathValidatorException)2 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)1 DERInteger (org.bouncycastle.asn1.DERInteger)1