// Copyright (C) 2024, The Duplicati Team
// https://duplicati.com, hello@duplicati.com
//
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.IO;
namespace Duplicati.Library.Interface
{
///
/// Public interface for an encryption method.
/// All modules that implements encryption must implement this interface.
/// The classes that implements this interface MUST also
/// implement a default constructor and a constructor that
/// has the signature new(string passphrase, Dictionary<string, string> options).
/// The default constructor is used to construct an instance
/// so the DisplayName and other values can be read.
/// The other constructor is used to do the actual work.
/// An instance can be used to encrypt or decrypt multiple files/streams.
///
public interface IEncryption : IDynamicModule, IDisposable
{
///
/// Encrypts the contents of the inputfile, and saves the result as the outputfile.
///
/// The file to encrypt
/// The encrypted file
void Encrypt(string inputfile, string outputfile);
///
/// Encrypts the contents of the input stream, and writes the result to the output stream.
///
/// The stream to encrypt
/// The encrypted stream
void Encrypt(Stream input, Stream output);
///
/// Decrypts the contents of the input file and saves the result as the outputfile
///
/// The file to decrypt
/// The decrypted output file
void Decrypt(string inputfile, string outputfile);
///
/// Decrypts the contents of the input stream, and writes the result to the output stream.
///
/// The stream to decrypt
/// The decrypted stream
void Decrypt(Stream input, Stream output);
///
/// Decrypts the stream to the output stream
///
/// The encrypted stream
/// The unencrypted stream
Stream Decrypt(Stream input);
///
/// Encrypts the stream
///
/// The target stream
/// An encrypted stream that can be written to
Stream Encrypt(Stream input);
///
/// The extension that the encryption implementation adds to the filename
///
string FilenameExtension { get; }
///
/// A localized string describing the encryption module with a friendly name
///
string DisplayName { get; }
///
/// A localized description of the encryption module
///
string Description { get; }
///
/// Returns the size in bytes of the overhead that will be added to a file of the given size when encrypted
///
/// The size of the file to encrypt
/// The size of the overhead in bytes
long SizeOverhead(long filesize);
}
}