/** * Encodes the signature as a DER sequence (ASN.1 format). */ private byte[] asnEncode(byte[] sigBlob) throws IOException { byte[] r = new BigInteger(1, Arrays.copyOfRange(sigBlob, 0, 20)).toByteArray(); byte[] s = new BigInteger(1, Arrays.copyOfRange(sigBlob, 20, 40)).toByteArray(); ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(r)); vector.add(new ASN1Integer(s)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ASN1OutputStream asnOS = new ASN1OutputStream(baos); asnOS.writeObject(new DERSequence(vector)); asnOS.flush(); return baos.toByteArray(); } }
/** * Encodes the signature as a DER sequence (ASN.1 format). */ private byte[] asnEncode(byte[] sigBlob) throws IOException { Buffer.PlainBuffer sigbuf = new Buffer.PlainBuffer(sigBlob); byte[] r = sigbuf.readBytes(); byte[] s = sigbuf.readBytes(); ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(r)); vector.add(new ASN1Integer(s)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ASN1OutputStream asnOS = new ASN1OutputStream(baos); asnOS.writeObject(new DERSequence(vector)); asnOS.flush(); return baos.toByteArray(); } }
/** * Return the default BER or DER encoding for this object. * * @return BER/DER byte encoded object. * @throws java.io.IOException on encoding error. */ public byte[] getEncoded() throws IOException { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ASN1OutputStream aOut = new ASN1OutputStream(bOut); aOut.writeObject(this); return bOut.toByteArray(); }
/** * Return the default BER or DER encoding for this object. * * @return BER/DER byte encoded object. * @throws java.io.IOException on encoding error. */ public byte[] getEncoded() throws IOException { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ASN1OutputStream aOut = new ASN1OutputStream(bOut); aOut.writeObject(this); return bOut.toByteArray(); }
public X500Principal getIssuerX500Principal() { try { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ASN1OutputStream aOut = new ASN1OutputStream(bOut); aOut.writeObject(c.getIssuer()); return new X500Principal(bOut.toByteArray()); } catch (IOException e) { throw new IllegalStateException("can't encode issuer DN"); } }
public X500Principal getIssuerX500Principal() { try { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ASN1OutputStream aOut = new ASN1OutputStream(bOut); aOut.writeObject(c.getIssuer()); return new X500Principal(bOut.toByteArray()); } catch (IOException e) { throw new IllegalStateException("can't encode issuer DN"); } }
public X500Principal getSubjectX500Principal() { try { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ASN1OutputStream aOut = new ASN1OutputStream(bOut); aOut.writeObject(c.getSubject()); return new X500Principal(bOut.toByteArray()); } catch (IOException e) { throw new IllegalStateException("can't encode issuer DN"); } }
public X500Principal getSubjectX500Principal() { try { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ASN1OutputStream aOut = new ASN1OutputStream(bOut); aOut.writeObject(c.getSubject()); return new X500Principal(bOut.toByteArray()); } catch (IOException e) { throw new IllegalStateException("can't encode issuer DN"); } }
private static byte[] encodeWithoutSeqHeader(RDN[] rdns) throws IOException { ByteArrayOutputStream bOut = new ByteArrayOutputStream(); ASN1OutputStream aOut = new ASN1OutputStream(bOut); for (RDN rdn: rdns) { aOut.writeObject(rdn); } aOut.close(); return bOut.toByteArray(); } }
/** * Encodes the signature as a DER sequence (ASN.1 format). */ private byte[] asnEncode(byte[] sigBlob) throws IOException { byte[] r = new BigInteger(1, Arrays.copyOfRange(sigBlob, 0, 20)).toByteArray(); byte[] s = new BigInteger(1, Arrays.copyOfRange(sigBlob, 20, 40)).toByteArray(); ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new ASN1Integer(r)); vector.add(new ASN1Integer(s)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ASN1OutputStream asnOS = new ASN1OutputStream(baos); asnOS.writeObject(new DERSequence(vector)); asnOS.flush(); return baos.toByteArray(); } }
void encode( ASN1OutputStream out) throws IOException { out.write(BERTags.SEQUENCE | BERTags.CONSTRUCTED); out.write(0x80); Enumeration e = getObjects(); while (e.hasMoreElements()) { out.writeObject((ASN1Encodable)e.nextElement()); } out.write(0x00); out.write(0x00); } }
void encode( ASN1OutputStream out) throws IOException { out.write(BERTags.SET | BERTags.CONSTRUCTED); out.write(0x80); Enumeration e = getObjects(); while (e.hasMoreElements()) { out.writeObject((ASN1Encodable)e.nextElement()); } out.write(0x00); out.write(0x00); } }
void encode( ASN1OutputStream out) throws IOException { ASN1OutputStream dOut = out.getDERSubStream(); int length = getBodyLength(); out.write(BERTags.SET | BERTags.CONSTRUCTED); out.writeLength(length); for (Enumeration e = this.getObjects(); e.hasMoreElements();) { Object obj = e.nextElement(); dOut.writeObject((ASN1Encodable)obj); } } }
void encode( ASN1OutputStream out) throws IOException { out.write(BERTags.SET | BERTags.CONSTRUCTED); out.write(0x80); Enumeration e = getObjects(); while (e.hasMoreElements()) { out.writeObject((ASN1Encodable)e.nextElement()); } out.write(0x00); out.write(0x00); } }
void encode( ASN1OutputStream out) throws IOException { ASN1OutputStream dOut = out.getDERSubStream(); int length = getBodyLength(); out.write(BERTags.SEQUENCE | BERTags.CONSTRUCTED); out.writeLength(length); for (Enumeration e = this.getObjects(); e.hasMoreElements();) { Object obj = e.nextElement(); dOut.writeObject((ASN1Encodable)obj); } } }
void encode( ASN1OutputStream out) throws IOException { ASN1OutputStream dOut = out.getDERSubStream(); int length = getBodyLength(); out.write(BERTags.SEQUENCE | BERTags.CONSTRUCTED); out.writeLength(length); for (Enumeration e = this.getObjects(); e.hasMoreElements();) { Object obj = e.nextElement(); dOut.writeObject((ASN1Encodable)obj); } } }
void encode( ASN1OutputStream out) throws IOException { out.write(BERTags.SEQUENCE | BERTags.CONSTRUCTED); out.write(0x80); Enumeration e = getObjects(); while (e.hasMoreElements()) { out.writeObject((ASN1Encodable)e.nextElement()); } out.write(0x00); out.write(0x00); } }
void encode( ASN1OutputStream out) throws IOException { ASN1OutputStream dOut = out.getDERSubStream(); int length = getBodyLength(); out.write(BERTags.SET | BERTags.CONSTRUCTED); out.writeLength(length); for (Enumeration e = this.getObjects(); e.hasMoreElements();) { Object obj = e.nextElement(); dOut.writeObject((ASN1Encodable)obj); } } }
public void encode( ASN1OutputStream out) throws IOException { out.write(BERTags.CONSTRUCTED | BERTags.OCTET_STRING); out.write(0x80); // // write out the octet array // for (Enumeration e = getObjects(); e.hasMoreElements();) { out.writeObject((ASN1Encodable)e.nextElement()); } out.write(0x00); out.write(0x00); }
public void encode( ASN1OutputStream out) throws IOException { out.write(BERTags.CONSTRUCTED | BERTags.OCTET_STRING); out.write(0x80); // // write out the octet array // for (Enumeration e = getObjects(); e.hasMoreElements();) { out.writeObject((ASN1Encodable)e.nextElement()); } out.write(0x00); out.write(0x00); }