예제 #1
0
 /// <exception cref="System.IO.IOException"/>
 public CryptoOutputStream(OutputStream @out, CryptoCodec codec, int bufferSize, byte
                           [] key, byte[] iv, long streamOffset)
     : base(@out)
 {
     // Underlying stream offset.
     CryptoStreamUtils.CheckCodec(codec);
     this.bufferSize   = CryptoStreamUtils.CheckBufferSize(codec, bufferSize);
     this.codec        = codec;
     this.key          = key.MemberwiseClone();
     this.initIV       = iv.MemberwiseClone();
     this.iv           = iv.MemberwiseClone();
     inBuffer          = ByteBuffer.AllocateDirect(this.bufferSize);
     outBuffer         = ByteBuffer.AllocateDirect(this.bufferSize);
     this.streamOffset = streamOffset;
     try
     {
         encryptor = codec.CreateEncryptor();
     }
     catch (GeneralSecurityException e)
     {
         throw new IOException(e);
     }
     UpdateEncryptor();
 }