Search in sources :

Example 91 with DERObject

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

the class NetscapeCertRequest method getKeySpec.

private DERObject getKeySpec() throws NoSuchAlgorithmException, InvalidKeySpecException, NoSuchProviderException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    DERObject obj = null;
    try {
        baos.write(pubkey.getEncoded());
        baos.close();
        ASN1InputStream derin = new ASN1InputStream(new ByteArrayInputStream(baos.toByteArray()));
        obj = derin.readObject();
    } catch (IOException ioe) {
        throw new InvalidKeySpecException(ioe.getMessage());
    }
    return obj;
}
Also used : ASN1InputStream(org.bouncycastle.asn1.ASN1InputStream) DERObject(org.bouncycastle.asn1.DERObject) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) InvalidKeySpecException(java.security.spec.InvalidKeySpecException)

Example 92 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 93 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 94 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 95 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)

Aggregations

ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)58 DERSequence (org.bouncycastle.asn1.DERSequence)56 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)42 DERObject (org.bouncycastle.asn1.DERObject)37 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)20 IOException (java.io.IOException)17 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)17 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)17 DERInteger (org.bouncycastle.asn1.DERInteger)16 ASN1Primitive (org.bouncycastle.asn1.ASN1Primitive)13 DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)13 DEROctetString (org.bouncycastle.asn1.DEROctetString)13 PolicyRequiredException (org.nhindirect.policy.PolicyRequiredException)12 BERSequence (org.bouncycastle.asn1.BERSequence)9 DERBitString (org.bouncycastle.asn1.DERBitString)9 DEREncodable (org.bouncycastle.asn1.DEREncodable)9 ByteArrayInputStream (java.io.ByteArrayInputStream)8 ArrayList (java.util.ArrayList)8 BigInteger (java.math.BigInteger)7 Enumeration (java.util.Enumeration)7