Search in sources :

Example 21 with DEROctetString

use of org.bouncycastle.asn1.DEROctetString in project XobotOS by xamarin.

the class MacData method toASN1Object.

/**
     * <pre>
     * MacData ::= SEQUENCE {
     *     mac      DigestInfo,
     *     macSalt  OCTET STRING,
     *     iterations INTEGER DEFAULT 1
     *     -- Note: The default is for historic reasons and its use is deprecated. A
     *     -- higher value, like 1024 is recommended.
     * </pre>
     * @return the basic DERObject construction.
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(digInfo);
    v.add(new DEROctetString(salt));
    if (!iterationCount.equals(ONE)) {
        v.add(new DERInteger(iterationCount));
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DEROctetString(org.bouncycastle.asn1.DEROctetString) DERInteger(org.bouncycastle.asn1.DERInteger)

Example 22 with DEROctetString

use of org.bouncycastle.asn1.DEROctetString in project XobotOS by xamarin.

the class PrivateKeyInfo method toASN1Object.

/**
     * write out an RSA private key with its associated information
     * as described in PKCS8.
     * <pre>
     *      PrivateKeyInfo ::= SEQUENCE {
     *                              version Version,
     *                              privateKeyAlgorithm AlgorithmIdentifier {{PrivateKeyAlgorithms}},
     *                              privateKey PrivateKey,
     *                              attributes [0] IMPLICIT Attributes OPTIONAL 
     *                          }
     *      Version ::= INTEGER {v1(0)} (v1,...)
     *
     *      PrivateKey ::= OCTET STRING
     *
     *      Attributes ::= SET OF Attribute
     * </pre>
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(new DERInteger(0));
    v.add(algId);
    v.add(new DEROctetString(privKey));
    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) DEROctetString(org.bouncycastle.asn1.DEROctetString) DERInteger(org.bouncycastle.asn1.DERInteger)

Example 23 with DEROctetString

use of org.bouncycastle.asn1.DEROctetString in project XobotOS by xamarin.

the class DigestInfo method toASN1Object.

public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(algId);
    v.add(new DEROctetString(digest));
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DEROctetString(org.bouncycastle.asn1.DEROctetString)

Aggregations

DEROctetString (org.bouncycastle.asn1.DEROctetString)20 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)10 DERSequence (org.bouncycastle.asn1.DERSequence)10 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)9 ASN1ObjectIdentifier (org.bouncycastle.asn1.ASN1ObjectIdentifier)8 IOException (java.io.IOException)7 AlgorithmIdentifier (org.bouncycastle.asn1.x509.AlgorithmIdentifier)7 X962Parameters (org.bouncycastle.asn1.x9.X962Parameters)7 X9ECParameters (org.bouncycastle.asn1.x9.X9ECParameters)7 X9ECPoint (org.bouncycastle.asn1.x9.X9ECPoint)7 DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)5 ECNamedCurveSpec (org.bouncycastle.jce.spec.ECNamedCurveSpec)5 BigInteger (java.math.BigInteger)4 DERBitString (org.bouncycastle.asn1.DERBitString)4 DERInteger (org.bouncycastle.asn1.DERInteger)4 Hashtable (java.util.Hashtable)3 DERSet (org.bouncycastle.asn1.DERSet)3 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)3 ECCurve (org.bouncycastle.math.ec.ECCurve)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2