Search in sources :

Example 61 with ASN1EncodableVector

use of org.openecard.bouncycastle.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 62 with ASN1EncodableVector

use of org.openecard.bouncycastle.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)

Example 63 with ASN1EncodableVector

use of org.openecard.bouncycastle.asn1.ASN1EncodableVector in project XobotOS by xamarin.

the class ObjectDigestInfo method toASN1Object.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * 
     * <pre>
     *  
     *    ObjectDigestInfo ::= SEQUENCE {
     *         digestedObjectType  ENUMERATED {
     *                 publicKey            (0),
     *                 publicKeyCert        (1),
     *                 otherObjectTypes     (2) },
     *                         -- otherObjectTypes MUST NOT
     *                         -- be used in this profile
     *         otherObjectTypeID   OBJECT IDENTIFIER OPTIONAL,
     *         digestAlgorithm     AlgorithmIdentifier,
     *         objectDigest        BIT STRING
     *    }
     *   
     * </pre>
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(digestedObjectType);
    if (otherObjectTypeID != null) {
        v.add(otherObjectTypeID);
    }
    v.add(digestAlgorithm);
    v.add(objectDigest);
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 64 with ASN1EncodableVector

use of org.openecard.bouncycastle.asn1.ASN1EncodableVector in project XobotOS by xamarin.

the class PolicyInformation method toASN1Object.

/* 
     * PolicyInformation ::= SEQUENCE {
     *      policyIdentifier   CertPolicyId,
     *      policyQualifiers   SEQUENCE SIZE (1..MAX) OF
     *              PolicyQualifierInfo OPTIONAL }
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(policyIdentifier);
    if (policyQualifiers != null) {
        v.add(policyQualifiers);
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 65 with ASN1EncodableVector

use of org.openecard.bouncycastle.asn1.ASN1EncodableVector in project XobotOS by xamarin.

the class RSAPublicKeyStructure method toASN1Object.

/**
     * This outputs the key in PKCS1v2 format.
     * <pre>
     *      RSAPublicKey ::= SEQUENCE {
     *                          modulus INTEGER, -- n
     *                          publicExponent INTEGER, -- e
     *                      }
     * </pre>
     * <p>
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(new DERInteger(getModulus()));
    v.add(new DERInteger(getPublicExponent()));
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DERInteger(org.bouncycastle.asn1.DERInteger)

Aggregations

ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)246 DERSequence (org.bouncycastle.asn1.DERSequence)196 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)54 IOException (java.io.IOException)45 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)43 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)42 DEROctetString (org.bouncycastle.asn1.DEROctetString)32 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)24 DERUTF8String (org.bouncycastle.asn1.DERUTF8String)21 DLSequence (org.bouncycastle.asn1.DLSequence)21 BigInteger (java.math.BigInteger)20 X509Certificate (java.security.cert.X509Certificate)20 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)18 DERSet (org.bouncycastle.asn1.DERSet)18 ArrayList (java.util.ArrayList)17 DERBitString (org.bouncycastle.asn1.DERBitString)17 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)16 BERSequence (org.bouncycastle.asn1.BERSequence)14 DERIA5String (org.bouncycastle.asn1.DERIA5String)14 DERInteger (org.bouncycastle.asn1.DERInteger)14