Search in sources :

Example 51 with ASN1EncodableVector

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

the class RSAPrivateKeyStructure method toASN1Primitive.

/**
     * 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 ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    // version
    v.add(new ASN1Integer(version));
    v.add(new ASN1Integer(getModulus()));
    v.add(new ASN1Integer(getPublicExponent()));
    v.add(new ASN1Integer(getPrivateExponent()));
    v.add(new ASN1Integer(getPrime1()));
    v.add(new ASN1Integer(getPrime2()));
    v.add(new ASN1Integer(getExponent1()));
    v.add(new ASN1Integer(getExponent2()));
    v.add(new ASN1Integer(getCoefficient()));
    if (otherPrimeInfos != null) {
        v.add(otherPrimeInfos);
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) ASN1Integer(org.bouncycastle.asn1.ASN1Integer)

Example 52 with ASN1EncodableVector

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

the class SafeBag method toASN1Primitive.

public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(bagId);
    v.add(new DLTaggedObject(true, 0, bagValue));
    if (bagAttributes != null) {
        v.add(bagAttributes);
    }
    return new DLSequence(v);
}
Also used : DLTaggedObject(org.bouncycastle.asn1.DLTaggedObject) DLSequence(org.bouncycastle.asn1.DLSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 53 with ASN1EncodableVector

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

the class SignedData method toASN1Primitive.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *  SignedData ::= SEQUENCE {
     *      version Version,
     *      digestAlgorithms DigestAlgorithmIdentifiers,
     *      contentInfo ContentInfo,
     *      certificates
     *          [0] IMPLICIT ExtendedCertificatesAndCertificates
     *                   OPTIONAL,
     *      crls
     *          [1] IMPLICIT CertificateRevocationLists OPTIONAL,
     *      signerInfos SignerInfos }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(version);
    v.add(digestAlgorithms);
    v.add(contentInfo);
    if (certificates != null) {
        v.add(new DERTaggedObject(false, 0, certificates));
    }
    if (crls != null) {
        v.add(new DERTaggedObject(false, 1, crls));
    }
    v.add(signerInfos);
    return new BERSequence(v);
}
Also used : DERTaggedObject(org.bouncycastle.asn1.DERTaggedObject) BERSequence(org.bouncycastle.asn1.BERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 54 with ASN1EncodableVector

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

the class IssuerSerial method toASN1Primitive.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *  IssuerSerial  ::=  SEQUENCE {
     *       issuer         GeneralNames,
     *       serial         CertificateSerialNumber,
     *       issuerUID      UniqueIdentifier OPTIONAL
     *  }
     * </pre>
     */
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(issuer);
    v.add(serial);
    if (issuerUID != null) {
        v.add(issuerUID);
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 55 with ASN1EncodableVector

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

the class PolicyInformation method toASN1Primitive.

/* 
     * PolicyInformation ::= SEQUENCE {
     *      policyIdentifier   CertPolicyId,
     *      policyQualifiers   SEQUENCE SIZE (1..MAX) OF
     *              PolicyQualifierInfo OPTIONAL }
     */
public ASN1Primitive toASN1Primitive() {
    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)

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