/// <summary> /// Decrypts the encrypted data to the given stream /// </summary> /// <param name="outputPlaintextStream">The resulting plain text stream.</param> public void DecryptTo(Stream outputPlaintextStream) { if (!PassphraseIsValid) { throw new InternalErrorException("Passphrase is not valid!"); } using (ICryptoTransform decryptor = DataCrypto.DecryptingTransform()) { using (V1AxCryptDataStream encryptedDataStream = CreateEncryptedDataStream(_reader.InputStream, DocumentHeaders.CipherTextLength)) { encryptedDataStream.DecryptTo(outputPlaintextStream, decryptor, DocumentHeaders.IsCompressed); } } if (Hmac != DocumentHeaders.Headers.Hmac) { throw new Axantum.AxCrypt.Core.Runtime.IncorrectDataException("HMAC validation error.", ErrorStatus.HmacValidationError); } }