Search in sources :

Example 26 with ASN1Object

use of com.mindbright.asn1.ASN1Object in project churchkey by tomitribe.

the class BeginRsaPublicKey method decode.

public static Key decode(final byte[] bytes) {
    try {
        final DerParser parser = new DerParser(bytes);
        final Asn1Object sequence = parser.readObject();
        if (sequence.getType() != Asn1Type.SEQUENCE) {
            throw new IllegalArgumentException("Invalid DER: not a sequence");
        }
        // Parse inside the sequence
        final DerParser p = sequence.createParser();
        final RSAPublicKey publicKey = Rsa.Public.builder().modulus(p.readObject().asInteger()).publicExponent(p.readObject().asInteger()).build().toKey();
        return new Key(publicKey, Key.Type.PUBLIC, Key.Algorithm.RSA, Key.Format.PEM);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
}
Also used : RSAPublicKey(java.security.interfaces.RSAPublicKey) DerParser(io.churchkey.asn1.DerParser) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) RSAPublicKey(java.security.interfaces.RSAPublicKey) Key(io.churchkey.Key) Asn1Object(io.churchkey.asn1.Asn1Object)

Example 27 with ASN1Object

use of com.mindbright.asn1.ASN1Object in project churchkey by tomitribe.

the class EcCurveParams method parse.

public static ECParameterSpec parse(final byte[] data) throws IOException {
    final DerParser d1 = new DerParser(data);
    final Asn1Object d1o1 = d1.readObject().assertType(Asn1Type.SEQUENCE);
    return parseSequence(d1o1);
}
Also used : DerParser(io.churchkey.asn1.DerParser) Asn1Object(io.churchkey.asn1.Asn1Object)

Example 28 with ASN1Object

use of com.mindbright.asn1.ASN1Object in project jruby-openssl by jruby.

the class X509Name method fromASN1Sequence.

void fromASN1Sequence(final ASN1Sequence seq) {
    oids.clear();
    values.clear();
    types.clear();
    if (seq != null) {
        for (Enumeration e = seq.getObjects(); e.hasMoreElements(); ) {
            ASN1Object element = (ASN1Object) e.nextElement();
            if (element instanceof RDN) {
                fromRDNElement((RDN) element);
            } else if (element instanceof ASN1Sequence) {
                fromASN1Sequence(element);
            } else {
                fromASN1Set(element);
            }
        }
    }
}
Also used : Enumeration(java.util.Enumeration) ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) ASN1Object(org.bouncycastle.asn1.ASN1Object) RDN(org.bouncycastle.asn1.x500.RDN)

Example 29 with ASN1Object

use of com.mindbright.asn1.ASN1Object in project xipki by xipki.

the class ProxyP11Slot method removeCerts0.

@Override
protected void removeCerts0(P11ObjectIdentifier objectId) throws P11TokenException {
    ASN1Object req = new SlotIdAndObjectId(asn1SlotId, new ObjectIdentifier(objectId));
    module.send(P11ProxyConstants.ACTION_REMOVE_CERTS, req);
}
Also used : ASN1Object(org.bouncycastle.asn1.ASN1Object) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Example 30 with ASN1Object

use of com.mindbright.asn1.ASN1Object in project xipki by xipki.

the class ProxyP11Slot method removeIdentity0.

@Override
protected void removeIdentity0(P11IdentityId identityId) throws P11TokenException {
    ASN1Object req = new SlotIdAndObjectId(asn1SlotId, new ObjectIdentifier(identityId.getKeyId()));
    module.send(P11ProxyConstants.ACTION_REMOVE_IDENTITY, req);
}
Also used : ASN1Object(org.bouncycastle.asn1.ASN1Object) ASN1ObjectIdentifier(org.bouncycastle.asn1.ASN1ObjectIdentifier)

Aggregations

IOException (java.io.IOException)35 Asn1Object (com.android.hotspot2.asn1.Asn1Object)25 ASN1Object (org.bouncycastle.asn1.ASN1Object)20 ArrayList (java.util.ArrayList)16 Asn1Constructed (com.android.hotspot2.asn1.Asn1Constructed)15 HashMap (java.util.HashMap)15 Asn1Object (io.churchkey.asn1.Asn1Object)13 DerParser (io.churchkey.asn1.DerParser)12 X509Certificate (java.security.cert.X509Certificate)12 Asn1Integer (com.android.hotspot2.asn1.Asn1Integer)10 DERBitString (com.android.org.bouncycastle.asn1.DERBitString)10 DERIA5String (com.android.org.bouncycastle.asn1.DERIA5String)10 DERPrintableString (com.android.org.bouncycastle.asn1.DERPrintableString)10 ByteBuffer (java.nio.ByteBuffer)10 Key (io.churchkey.Key)8 ByteArrayInputStream (java.io.ByteArrayInputStream)7 I18Name (com.android.anqp.I18Name)5 Asn1Oid (com.android.hotspot2.asn1.Asn1Oid)5 Asn1String (com.android.hotspot2.asn1.Asn1String)5 OidMappings (com.android.hotspot2.asn1.OidMappings)5