/// <summary>
        /// Seal encrypts and authenticates the next message in the STREAM,
        /// authenticates the associated data, and returns the result.
        /// </summary>
        /// <param name="plaintext">The plaintext to encrypt.</param>
        /// <param name="data">Associated data items to authenticate.</param>
        /// <param name="last">True if this is the last block in the STREAM.</param>
        /// <returns>Concatenation of the authentication tag and the encrypted data.</returns>
        public byte[] Seal(byte[] plaintext, byte[] data = null, bool last = false)
        {
            if (disposed)
            {
                throw new ObjectDisposedException(nameof(StreamEncryptor));
            }

            if (finished)
            {
                throw new CryptographicException("STREAM is already finished.");
            }

            finished = last;

            return(siv.Seal(plaintext, data, nonce.Next(last)));
        }
Example #2
0
 /// <summary>
 /// Seal encrypts and authenticates plaintext, authenticates
 /// the associated data, and returns the result.
 /// </summary>
 /// <param name="plaintext">The plaintext to encrypt.</param>
 /// <param name="nonce">The nonce for encryption.</param>
 /// <param name="data">Associated data to authenticate.</param>
 /// <returns>Concatenation of the authentication tag and the encrypted data.</returns>
 public byte[] Seal(byte[] plaintext, byte[] nonce = null, byte[] data = null)
 {
     return(siv.Seal(plaintext, data, nonce));
 }