Ejemplo n.º 1
0
 protected override void Dispose(bool disposing)
 {
     if (this.IsDisposed)
     {
         return;
     }
     try
     {
         if (!disposing)
         {
             return;
         }
         if (!this.finalBlockTransformed && this.Transform != null)
         {
             this.FlushFinalBlock();
         }
         (this.baseStream as OperationStream)?.Dispose();
     }
     finally
     {
         try
         {
             this.finalBlockTransformed = true;
             if (this.Transform != null)
             {
                 this.Transform.Dispose();
             }
             if (this.inputBuffer != null)
             {
                 Array.Clear((Array)this.inputBuffer, 0, this.inputBuffer.Length);
             }
             if (this.outputBuffer != null)
             {
                 Array.Clear((Array)this.outputBuffer, 0, this.outputBuffer.Length);
             }
             this.inputBuffer    = (byte[])null;
             this.outputBuffer   = (byte[])null;
             this.blockTransform = (IBlockTransform)null;
             this.baseStream     = (Stream)null;
         }
         finally
         {
             this.IsDisposed = true;
             base.Dispose(disposing);
         }
     }
 }
Ejemplo n.º 2
0
        public CFBMode(byte[] iv, IBlockTransform blockTransform, bool encryption, int paddingSizeInBytes)
            : base(iv, blockTransform.BlockSizeInBytes, paddingSizeInBytes)
        {
            if (iv == null)
            {
                throw new ArgumentNullException(nameof(iv));
            }
            if (iv.Length != blockTransform.BlockSizeInBytes)
            {
                throw new ArgumentOutOfRangeException(nameof(iv));
            }

            this.FR  = CryptoPool.Rent(iv.Length);
            this.FRE = CryptoPool.Rent(iv.Length);
            iv.CopyTo(this.FR, 0);

            this.blockTransform = blockTransform;
            this.encryption     = encryption;
        }
Ejemplo n.º 3
0
 public ECBMode(IBlockTransform blockTransform, int paddingSizeInBytes)
     : base(Array.Empty <byte>(), blockTransform.BlockSizeInBytes, paddingSizeInBytes)
 {
     this.blockTransform = blockTransform;
 }
Ejemplo n.º 4
0
 protected override byte[] Transform(IBlockTransform encryptor, byte[] data)
 {
     return encryptor.DecryptBlock(data);
 }
Ejemplo n.º 5
0
 public Decryptor(IBlockTransform encryptor, int blockSize, int outputSize)
     : base(encryptor, blockSize, outputSize)
 { }
Ejemplo n.º 6
0
 protected virtual byte[] Transform(IBlockTransform encryptor, byte[] data)
 {
     return encryptor.EncryptBlock(data);
 }
Ejemplo n.º 7
0
 public Encryptor(IBlockTransform encryptor, int blockSize, int outputSize)
 {
     _encryptor = encryptor;
     _blockSize = blockSize;
     _outputSize = outputSize;
 }
 protected override byte[] Transform(IBlockTransform encryptor, byte[] data)
 {
     return(encryptor.DecryptBlock(data));
 }
 public Decryptor(IBlockTransform encryptor, int blockSize, int outputSize)
     : base(encryptor, blockSize, outputSize)
 {
 }
 protected virtual byte[] Transform(IBlockTransform encryptor, byte[] data)
 {
     return(encryptor.EncryptBlock(data));
 }
 public Encryptor(IBlockTransform encryptor, int blockSize, int outputSize)
 {
     _encryptor  = encryptor;
     _blockSize  = blockSize;
     _outputSize = outputSize;
 }