3using System.Security.Cryptography;
 
    5using System.Threading.Tasks;
 
   26            this.aes = Aes.Create();
 
   27            this.aes.BlockSize = 128;
 
   28            this.aes.KeySize = 256;
 
   29            this.aes.Mode = CipherMode.CBC;
 
   30            this.aes.Padding = PaddingMode.None;
 
   66        public override byte[] 
GetIV(
string Id, 
string Type, 
string From, 
string To, uint Counter)
 
   69            Array.Resize(ref IV, 16);
 
   71            IV[12] = (byte)Counter;
 
   73            IV[13] = (byte)Counter;
 
   75            IV[14] = (byte)Counter;
 
   77            IV[15] = (byte)Counter;
 
   89            return (ContentLength + 15L) & ~0xfL;
 
  101        public override byte[] 
Encrypt(
byte[] Data, 
byte[] Key, 
byte[] IV, 
byte[] AssociatedData,
 
  104            byte[] Encrypted = base.Encrypt(Data, Key, IV, AssociatedData, FillAlgorithm);
 
  108                using (ICryptoTransform Aes = this.aes.CreateEncryptor(Key, IV))
 
  110                    Encrypted = Aes.TransformFinalBlock(Encrypted, 0, Encrypted.Length);
 
  125        public override byte[] 
Decrypt(
byte[] Data, 
byte[] Key, 
byte[] IV, 
byte[] AssociatedData)
 
  129                using (ICryptoTransform Aes = this.aes.CreateDecryptor(Key, IV))
 
  131                    Data = Aes.TransformFinalBlock(Data, 0, Data.Length);
 
  135            return base.Decrypt(Data, Key, IV, AssociatedData);
 
  146        public override async Task 
Encrypt(Stream Data, Stream Encrypted, 
byte[] Key, 
byte[] IV, 
byte[] AssociatedData)
 
  149            ICryptoTransform Aes = 
null;
 
  153                await base.Encrypt(Data, PreEncrypt, Key, IV, AssociatedData);
 
  154                PreEncrypt.Position = 0;
 
  158                    Aes = this.aes.CreateEncryptor(Key, IV);
 
  178        public override async Task<Stream> 
Decrypt(Stream Data, 
byte[] Key, 
byte[] IV, 
byte[] AssociatedData)
 
  180            ICryptoTransform Aes = 
null;
 
  187                    Aes = this.aes.CreateDecryptor(Key, IV);
 
  192                Decrypted.Position = 0;
 
  193                return await base.Decrypt(Decrypted, Key, IV, AssociatedData);
 
  210                this.aes.GenerateKey();
 
Implements support for the AES-256 cipher in hybrid End-to-End encryption schemes.
 
override void Dispose()
IDisposable.Dispose
 
override byte[] Decrypt(byte[] Data, byte[] Key, byte[] IV, byte[] AssociatedData)
Decrypts binary data
 
override byte[] Encrypt(byte[] Data, byte[] Key, byte[] IV, byte[] AssociatedData, E2eBufferFillAlgorithm FillAlgorithm)
Encrypts binary data
 
override long GetEncryptedLength(long ContentLength)
Calculates the minimum size of encrypted data, given the size of the content.
 
Aes256()
Implements support for the AES-256 cipher in hybrid End-to-End encryption schemes.
 
override byte[] GenerateKey()
Generates a new key. Used when the asymmetric cipher cannot calculate a shared secret.
 
Aes aes
AES encryption object
 
override byte[] GetIV(string Id, string Type, string From, string To, uint Counter)
Gets an Initiation Vector from stanza attributes.
 
override async Task Encrypt(Stream Data, Stream Encrypted, byte[] Key, byte[] IV, byte[] AssociatedData)
Encrypts binary data
 
override async Task< Stream > Decrypt(Stream Data, byte[] Key, byte[] IV, byte[] AssociatedData)
Decrypts binary data
 
override string LocalName
Local name of the E2E symmetric cipher
 
override IE2eSymmetricCipher CreteNew()
Creates a new symmetric cipher object with the same settings as the current object.
 
Abstract base class for symmetric ciphers.
 
Manages a temporary stream. Contents is kept in-memory, if below a memory threshold,...
 
override void Dispose(bool disposing)
Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed res...
 
Helper methods for encrypting and decrypting streams of data.
 
static Task CryptoTransform(ICryptoTransform Transform, Stream Source, Stream Destination)
Transforms a stream of data.
 
Contains methods for simple hash calculations.
 
static byte[] ComputeSHA256Hash(byte[] Data)
Computes the SHA-256 hash of a block of binary data.
 
Interface for symmetric ciphers.
 
E2eBufferFillAlgorithm
How buffers are filler before E2E Encryption is performed.