Пример #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 Aes128EncryptionKeys(key);

            var      state  = nonce.AsVector128 <byte>();
            int      left   = plaintext.Length & BlockSize - 1;
            ref byte output = ref MemoryMarshal.GetReference(ciphertext);
Пример #2
0
 public Aes128BlockEncryptor(ReadOnlySpan <byte> key)
 {
     _keys = new Aes128EncryptionKeys(key);
 }