예제 #1
0
 /// <exception cref="System.IO.IOException"/>
 private void Process(ByteBuffer inBuffer, ByteBuffer outBuffer)
 {
     try
     {
         int inputSize = inBuffer.Remaining();
         // OpensslCipher#update will maintain crypto context.
         int n = cipher.Update(inBuffer, outBuffer);
         if (n < inputSize)
         {
             contextReset = true;
             cipher.DoFinal(outBuffer);
         }
     }
     catch (Exception e)
     {
         throw new IOException(e);
     }
 }
예제 #2
0
        /// <exception cref="System.Exception"/>
        public virtual void TestDoFinalArguments()
        {
            Assume.AssumeTrue(OpensslCipher.GetLoadingFailureReason() == null);
            OpensslCipher cipher = OpensslCipher.GetInstance("AES/CTR/NoPadding");

            Assert.True(cipher != null);
            cipher.Init(OpensslCipher.EncryptMode, key, iv);
            // Require direct buffer
            ByteBuffer output = ByteBuffer.Allocate(1024);

            try
            {
                cipher.DoFinal(output);
                NUnit.Framework.Assert.Fail("Output buffer should be direct buffer.");
            }
            catch (ArgumentException e)
            {
                GenericTestUtils.AssertExceptionContains("Direct buffer is required", e);
            }
        }