Search in sources :

Example 86 with DERSequence

use of com.android.org.bouncycastle.asn1.DERSequence in project XobotOS by xamarin.

the class RSAPrivateKeyStructure method toASN1Object.

/**
     * This outputs the key in PKCS1v2 format.
     * <pre>
     *      RSAPrivateKey ::= SEQUENCE {
     *                          version Version,
     *                          modulus INTEGER, -- n
     *                          publicExponent INTEGER, -- e
     *                          privateExponent INTEGER, -- d
     *                          prime1 INTEGER, -- p
     *                          prime2 INTEGER, -- q
     *                          exponent1 INTEGER, -- d mod (p-1)
     *                          exponent2 INTEGER, -- d mod (q-1)
     *                          coefficient INTEGER, -- (inverse of q) mod p
     *                          otherPrimeInfos OtherPrimeInfos OPTIONAL
     *                      }
     *
     *      Version ::= INTEGER { two-prime(0), multi(1) }
     *        (CONSTRAINED BY {-- version must be multi if otherPrimeInfos present --})
     * </pre>
     * <p>
     * This routine is written to output PKCS1 version 2.1, private keys.
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    // version
    v.add(new DERInteger(version));
    v.add(new DERInteger(getModulus()));
    v.add(new DERInteger(getPublicExponent()));
    v.add(new DERInteger(getPrivateExponent()));
    v.add(new DERInteger(getPrime1()));
    v.add(new DERInteger(getPrime2()));
    v.add(new DERInteger(getExponent1()));
    v.add(new DERInteger(getExponent2()));
    v.add(new DERInteger(getCoefficient()));
    if (otherPrimeInfos != null) {
        v.add(otherPrimeInfos);
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DERInteger(org.bouncycastle.asn1.DERInteger)

Example 87 with DERSequence

use of com.android.org.bouncycastle.asn1.DERSequence in project XobotOS by xamarin.

the class SafeBag method toASN1Object.

public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(bagId);
    v.add(new DERTaggedObject(0, bagValue));
    if (bagAttributes != null) {
        v.add(bagAttributes);
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 88 with DERSequence

use of com.android.org.bouncycastle.asn1.DERSequence in project XobotOS by xamarin.

the class CertificationRequestInfo method toASN1Object.

public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(version);
    v.add(subject);
    v.add(subjectPKInfo);
    if (attributes != null) {
        v.add(new DERTaggedObject(false, 0, attributes));
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 89 with DERSequence

use of com.android.org.bouncycastle.asn1.DERSequence in project XobotOS by xamarin.

the class DHParameter method toASN1Object.

public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(p);
    v.add(g);
    if (this.getL() != null) {
        v.add(l);
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 90 with DERSequence

use of com.android.org.bouncycastle.asn1.DERSequence in project XobotOS by xamarin.

the class EncryptedPrivateKeyInfo method toASN1Object.

/**
     * 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 DERObject toASN1Object() {
    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)

Aggregations

DERSequence (org.bouncycastle.asn1.DERSequence)119 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)111 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)17 DERBitString (org.bouncycastle.asn1.DERBitString)13 DEROctetString (org.bouncycastle.asn1.DEROctetString)13 IOException (java.io.IOException)10 Enumeration (java.util.Enumeration)10 X509Certificate (java.security.cert.X509Certificate)9 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)9 DERInteger (org.bouncycastle.asn1.DERInteger)9 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)8 BigInteger (java.math.BigInteger)7 DERIA5String (org.bouncycastle.asn1.DERIA5String)7 DERSet (org.bouncycastle.asn1.DERSet)7 DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)6 ASN1EncodableVector (com.android.org.bouncycastle.asn1.ASN1EncodableVector)5 ASN1InputStream (com.android.org.bouncycastle.asn1.ASN1InputStream)5 ASN1Integer (com.android.org.bouncycastle.asn1.ASN1Integer)5 ASN1ObjectIdentifier (com.android.org.bouncycastle.asn1.ASN1ObjectIdentifier)5 DERBitString (com.android.org.bouncycastle.asn1.DERBitString)5