Search in sources :

Example 96 with ASN1Primitive

use of com.github.zhenwei.core.asn1.ASN1Primitive in project LinLong-Java by zhenwei1108.

the class PBES2Parameters method toASN1Primitive.

public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector(2);
    v.add(func);
    v.add(scheme);
    return new DERSequence(v);
}
Also used : DERSequence(com.github.zhenwei.core.asn1.DERSequence) ASN1EncodableVector(com.github.zhenwei.core.asn1.ASN1EncodableVector)

Example 97 with ASN1Primitive

use of com.github.zhenwei.core.asn1.ASN1Primitive in project LinLong-Java by zhenwei1108.

the class PKCS12PBEParams method toASN1Primitive.

public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector(2);
    v.add(iv);
    v.add(iterations);
    return new DERSequence(v);
}
Also used : DERSequence(com.github.zhenwei.core.asn1.DERSequence) ASN1EncodableVector(com.github.zhenwei.core.asn1.ASN1EncodableVector)

Example 98 with ASN1Primitive

use of com.github.zhenwei.core.asn1.ASN1Primitive in project LinLong-Java by zhenwei1108.

the class Pfx method toASN1Primitive.

public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector(3);
    v.add(new ASN1Integer(3));
    v.add(contentInfo);
    if (macData != null) {
        v.add(macData);
    }
    return new BERSequence(v);
}
Also used : BERSequence(com.github.zhenwei.core.asn1.BERSequence) ASN1EncodableVector(com.github.zhenwei.core.asn1.ASN1EncodableVector) ASN1Integer(com.github.zhenwei.core.asn1.ASN1Integer)

Example 99 with ASN1Primitive

use of com.github.zhenwei.core.asn1.ASN1Primitive in project LinLong-Java by zhenwei1108.

the class PrivateKeyInfo method toASN1Primitive.

public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector v = new ASN1EncodableVector(5);
    v.add(version);
    v.add(privateKeyAlgorithm);
    v.add(privateKey);
    if (attributes != null) {
        v.add(new DERTaggedObject(false, 0, attributes));
    }
    if (publicKey != null) {
        v.add(new DERTaggedObject(false, 1, publicKey));
    }
    return new DERSequence(v);
}
Also used : DERSequence(com.github.zhenwei.core.asn1.DERSequence) DERTaggedObject(com.github.zhenwei.core.asn1.DERTaggedObject) ASN1EncodableVector(com.github.zhenwei.core.asn1.ASN1EncodableVector)

Example 100 with ASN1Primitive

use of com.github.zhenwei.core.asn1.ASN1Primitive in project LinLong-Java by zhenwei1108.

the class RSAPrivateKey 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(10);
    // 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(com.github.zhenwei.core.asn1.DERSequence) ASN1EncodableVector(com.github.zhenwei.core.asn1.ASN1EncodableVector) ASN1Integer(com.github.zhenwei.core.asn1.ASN1Integer)

Aggregations

ASN1EncodableVector (com.github.zhenwei.core.asn1.ASN1EncodableVector)253 DERSequence (com.github.zhenwei.core.asn1.DERSequence)231 ASN1Primitive (org.bouncycastle.asn1.ASN1Primitive)177 IOException (java.io.IOException)107 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)62 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)57 DERTaggedObject (com.github.zhenwei.core.asn1.DERTaggedObject)55 ASN1Integer (com.github.zhenwei.core.asn1.ASN1Integer)42 DEROctetString (com.github.zhenwei.core.asn1.DEROctetString)38 ByteArrayInputStream (java.io.ByteArrayInputStream)38 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)32 ASN1Primitive (com.github.zhenwei.core.asn1.ASN1Primitive)31 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)31 ASN1Encodable (org.bouncycastle.asn1.ASN1Encodable)30 DEROctetString (org.bouncycastle.asn1.DEROctetString)28 BigInteger (java.math.BigInteger)24 GeneralSecurityException (java.security.GeneralSecurityException)24 X509Certificate (java.security.cert.X509Certificate)24 ASN1Integer (org.bouncycastle.asn1.ASN1Integer)23 DERIA5String (org.bouncycastle.asn1.DERIA5String)22