use of com.github.zhenwei.core.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);
}
}
use of com.github.zhenwei.core.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);
}
use of com.github.zhenwei.core.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);
}
}
}
}
use of com.github.zhenwei.core.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);
}
use of com.github.zhenwei.core.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);
}
Aggregations