コード例 #1
0
  /** @deprecated use open(OutputStream, ASN1ObjectIdentifier, ContentCompressor) */
  public OutputStream open(OutputStream out, String contentOID, String compressionOID)
      throws IOException {
    BERSequenceGenerator sGen = new BERSequenceGenerator(out);

    sGen.addObject(CMSObjectIdentifiers.compressedData);

    //
    // Compressed Data
    //
    BERSequenceGenerator cGen = new BERSequenceGenerator(sGen.getRawOutputStream(), 0, true);

    cGen.addObject(new DERInteger(0));

    //
    // AlgorithmIdentifier
    //
    DERSequenceGenerator algGen = new DERSequenceGenerator(cGen.getRawOutputStream());

    algGen.addObject(new DERObjectIdentifier(ZLIB));

    algGen.close();

    //
    // Encapsulated ContentInfo
    //
    BERSequenceGenerator eiGen = new BERSequenceGenerator(cGen.getRawOutputStream());

    eiGen.addObject(new DERObjectIdentifier(contentOID));

    OutputStream octetStream =
        CMSUtils.createBEROctetOutputStream(eiGen.getRawOutputStream(), 0, true, _bufferSize);

    return new CmsCompressedOutputStream(new DeflaterOutputStream(octetStream), sGen, cGen, eiGen);
  }
コード例 #2
0
ファイル: ECKey.java プロジェクト: nguyenducnhaty/scalechain
 protected ByteArrayOutputStream derByteStream() throws IOException {
   // Usually 70-72 bytes.
   ByteArrayOutputStream bos = new ByteArrayOutputStream(72);
   DERSequenceGenerator seq = new DERSequenceGenerator(bos);
   seq.addObject(new ASN1Integer(r));
   seq.addObject(new ASN1Integer(s));
   seq.close();
   return bos;
 }