Added SecretChats.DownloadFile and media.MimeType to simplify download & decryption

This commit is contained in:
Wizou 2022-10-20 23:12:43 +02:00
parent 82d852e071
commit b9587e3997
8 changed files with 74 additions and 30 deletions

View file

@ -526,16 +526,13 @@ j4WcDuXc2CTHgH8gFTNhp/Y8/SpDOhvn9QIDAQAB
#endif
}
/// <summary>Stream for encryption/decryption of AES-256 with infinite garble extension (IGE) </summary>
public class AES_IGE_Stream : Helpers.IndirectStream
internal class AES_IGE_Stream : Helpers.IndirectStream
{
private readonly ICryptoTransform aesCrypto;
private readonly byte[] prevBytes;
/// <summary>Decryption of AES-256 IGE file with key/iv obtained from media structure</summary>
public AES_IGE_Stream(Stream stream, DecryptedMessageMedia media) : this(stream, media.SizeKeyIV) { }
public AES_IGE_Stream(Stream stream, (int size, byte[] key, byte[] iv) t) : this(stream, t.key, t.iv) { ContentLength = t.size; }
public AES_IGE_Stream(Stream stream, byte[] key, byte[] iv, bool encrypt = false) : base(stream)
public AES_IGE_Stream(Stream stream, int size, byte[] key, byte[] iv) : this(stream, key, iv, false) { ContentLength = size; }
public AES_IGE_Stream(Stream stream, byte[] key, byte[] iv, bool encrypt) : base(stream)
{
aesCrypto = encrypt ? Encryption.AesECB.CreateEncryptor(key, null) : Encryption.AesECB.CreateDecryptor(key, null);
if (encrypt) prevBytes = (byte[])iv.Clone();