/// <summary> /// Open decrypts the next ciphertext in the STREAM, authenticates the /// decrypted plaintext and the associated data and, if successful, returns /// the result. In case of failed decryption, this method throws /// <see cref="CryptographicException">. /// </summary> /// <param name="ciphertext">The ciphertext to decrypt.</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>The decrypted plaintext.</returns> /// <exception cref="CryptographicException">Thrown when the ciphertext is invalid.</exception> public byte[] Open(byte[] ciphertext, 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.Open(ciphertext, data, nonce.Next(last))); }
/// <summary> /// Open decrypts ciphertext, authenticates the decrypted plaintext /// and the associated data and, if successful, returns the result. /// In case of failed decryption, this method throws /// <see cref="CryptographicException">. /// </summary> /// <param name="ciphertext">The ciphertext to decrypt.</param> /// <param name="nonce">The nonce for encryption.</param> /// <param name="data">Associated data to authenticate.</param> /// <returns>The decrypted plaintext.</returns> /// <exception cref="CryptographicException">Thrown when the ciphertext is invalid.</exception> public byte[] Open(byte[] ciphertext, byte[] nonce = null, byte[] data = null) { return(siv.Open(ciphertext, data, nonce)); }