Esempio n. 1
0
        /// <inheritsdoc />
        public override void Encrypt(ReadOnlySpan <byte> key, ReadOnlySpan <byte> plaintext, ReadOnlySpan <byte> nonce, Span <byte> ciphertext)
        {
            if (nonce.Length != 16)
            {
                ThrowHelper.ThrowArgumentOutOfRangeException_MustBeAtLeast(ExceptionArgument.nonce, 16);
            }

            if (ciphertext.Length < GetCiphertextLength(plaintext.Length))
            {
                ThrowHelper.ThrowArgumentOutOfRangeException_MustBeAtLeast(ExceptionArgument.ciphertext, GetCiphertextLength(plaintext.Length));
            }

            var      keys   = new Aes256EncryptionKeys(key);
            var      state  = nonce.AsVector128 <byte>();
            int      left   = plaintext.Length & BlockSize - 1;
            ref byte output = ref MemoryMarshal.GetReference(ciphertext);
Esempio n. 2
0
 public Aes256BlockEncryptor(ReadOnlySpan <byte> key)
 {
     _keys = new Aes256EncryptionKeys(key);
 }