Search in sources :

Example 71 with DERObject

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

the class X509NameEntryConverter method convertHexEncoded.

/**
     * Convert an inline encoded hex string rendition of an ASN.1
     * object back into its corresponding ASN.1 object.
     * 
     * @param str the hex encoded object
     * @param off the index at which the encoding starts
     * @return the decoded object
     */
protected DERObject convertHexEncoded(String str, int off) throws IOException {
    str = Strings.toLowerCase(str);
    byte[] data = new byte[(str.length() - off) / 2];
    for (int index = 0; index != data.length; index++) {
        char left = str.charAt((index * 2) + off);
        char right = str.charAt((index * 2) + off + 1);
        if (left < 'a') {
            data[index] = (byte) ((left - '0') << 4);
        } else {
            data[index] = (byte) ((left - 'a' + 10) << 4);
        }
        if (right < 'a') {
            data[index] |= (byte) (right - '0');
        } else {
            data[index] |= (byte) (right - 'a' + 10);
        }
    }
    ASN1InputStream aIn = new ASN1InputStream(data);
    return aIn.readObject();
}
Also used : ASN1InputStream(org.bouncycastle.asn1.ASN1InputStream)

Example 72 with DERObject

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

the class DHValidationParms method toASN1Object.

public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(this.seed);
    v.add(this.pgenCounter);
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector)

Example 73 with DERObject

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

the class X9ECParameters method toASN1Object.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *  ECParameters ::= SEQUENCE {
     *      version         INTEGER { ecpVer1(1) } (ecpVer1),
     *      fieldID         FieldID {{FieldTypes}},
     *      curve           X9Curve,
     *      base            X9ECPoint,
     *      order           INTEGER,
     *      cofactor        INTEGER OPTIONAL
     *  }
     * </pre>
     */
public DERObject toASN1Object() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(new DERInteger(1));
    v.add(fieldID);
    v.add(new X9Curve(curve, seed));
    v.add(new X9ECPoint(g));
    v.add(new DERInteger(n));
    if (h != null) {
        v.add(new DERInteger(h));
    }
    return new DERSequence(v);
}
Also used : DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) DERInteger(org.bouncycastle.asn1.DERInteger)

Example 74 with DERObject

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

the class IssuerSerial method toASN1Object.

/**
     * Produce an object suitable for an ASN1OutputStream.
     * <pre>
     *  IssuerSerial  ::=  SEQUENCE {
     *       issuer         GeneralNames,
     *       serial         CertificateSerialNumber,
     *       issuerUID      UniqueIdentifier OPTIONAL
     *  }
     * </pre>
     */
public DERObject toASN1Object() {
    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 75 with DERObject

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

the class X509Extensions method toASN1Object.

/**
     * <pre>
     *     Extensions        ::=   SEQUENCE SIZE (1..MAX) OF Extension
     *
     *     Extension         ::=   SEQUENCE {
     *        extnId            EXTENSION.&amp;id ({ExtensionSet}),
     *        critical          BOOLEAN DEFAULT FALSE,
     *        extnValue         OCTET STRING }
     * </pre>
     */
public DERObject toASN1Object() {
    ASN1EncodableVector vec = new ASN1EncodableVector();
    Enumeration e = ordering.elements();
    while (e.hasMoreElements()) {
        ASN1ObjectIdentifier oid = (ASN1ObjectIdentifier) e.nextElement();
        X509Extension ext = (X509Extension) extensions.get(oid);
        ASN1EncodableVector v = new ASN1EncodableVector();
        v.add(oid);
        if (ext.isCritical()) {
            // BEGIN android-changed
            v.add(DERBoolean.TRUE);
        // END android-changed
        }
        v.add(ext.getValue());
        vec.add(new DERSequence(v));
    }
    return new DERSequence(vec);
}
Also used : Enumeration(java.util.Enumeration) DERSequence(org.bouncycastle.asn1.DERSequence) ASN1EncodableVector(org.bouncycastle.asn1.ASN1EncodableVector) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Aggregations

ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)47 DERSequence (org.bouncycastle.asn1.DERSequence)42 DERObject (org.bouncycastle.asn1.DERObject)31 IOException (java.io.IOException)15 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)15 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)13 DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)12 PolicyRequiredException (org.nhindirect.policy.PolicyRequiredException)12 DERInteger (org.bouncycastle.asn1.DERInteger)11 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)10 ArrayList (java.util.ArrayList)8 DEREncodable (org.bouncycastle.asn1.DEREncodable)8 DEROctetString (org.bouncycastle.asn1.DEROctetString)8 DERBitString (org.bouncycastle.asn1.DERBitString)7 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)7 GeneralSecurityException (java.security.GeneralSecurityException)5 CertPathValidatorException (java.security.cert.CertPathValidatorException)5 Enumeration (java.util.Enumeration)5 BERSequence (org.bouncycastle.asn1.BERSequence)5 PolicyProcessException (org.nhindirect.policy.PolicyProcessException)5