public void write(OutputStream cOut) throws IOException, CMSException { if (structure instanceof ASN1Sequence) { ASN1Sequence s = ASN1Sequence.getInstance(structure); for (Iterator it = s.iterator(); it.hasNext();) { ASN1Encodable enc = (ASN1Encodable)it.next(); cOut.write(enc.toASN1Primitive().getEncoded(ASN1Encoding.DER)); } } else { byte[] encoded = structure.toASN1Primitive().getEncoded(ASN1Encoding.DER); int index = 1; while ((encoded[index] & 0xff) > 127) { index++; } index++; cOut.write(encoded, index, encoded.length - index); } }
public void write(OutputStream cOut) throws IOException, CMSException { if (structure instanceof ASN1Sequence) { ASN1Sequence s = ASN1Sequence.getInstance(structure); for (Iterator it = s.iterator(); it.hasNext();) { ASN1Encodable enc = (ASN1Encodable)it.next(); cOut.write(enc.toASN1Primitive().getEncoded(ASN1Encoding.DER)); } } else { byte[] encoded = structure.toASN1Primitive().getEncoded(ASN1Encoding.DER); int index = 1; while ((encoded[index] & 0xff) > 127) { index++; } index++; cOut.write(encoded, index, encoded.length - index); } }