use of org.bouncycastle.asn1.DERBitString in project jruby-openssl by jruby.
the class NetscapeSPKI method toDER.
private byte[] toDER() throws IOException {
ASN1Sequence b = (ASN1Sequence) ((NetscapeCertRequest) cert).toASN1Primitive();
ASN1ObjectIdentifier encType = (ASN1ObjectIdentifier) ((ASN1Sequence) ((ASN1Sequence) ((ASN1Sequence) b.getObjectAt(0)).getObjectAt(0)).getObjectAt(0)).getObjectAt(0);
ASN1ObjectIdentifier sigAlg = ((AlgorithmIdentifier) b.getObjectAt(1)).getAlgorithm();
DERBitString sig = (DERBitString) b.getObjectAt(2);
DERBitString publicKey = new DERBitString(((PKey) public_key).to_der().convertToString().getBytes());
DERIA5String encodedChallenge = new DERIA5String(this.challenge.toString());
ASN1EncodableVector v1 = new ASN1EncodableVector();
ASN1EncodableVector v1_2 = new ASN1EncodableVector();
ASN1EncodableVector v2 = new ASN1EncodableVector();
ASN1EncodableVector v3 = new ASN1EncodableVector();
ASN1EncodableVector v4 = new ASN1EncodableVector();
v4.add(encType);
v4.add(DERNull.INSTANCE);
v3.add(new DLSequence(v4));
v3.add(publicKey);
v2.add(new DLSequence(v3));
v2.add(encodedChallenge);
v1.add(new DLSequence(v2));
v1_2.add(sigAlg);
v1_2.add(DERNull.INSTANCE);
v1.add(new DLSequence(v1_2));
v1.add(sig);
return new DLSequence(v1).getEncoded();
}
Aggregations