/// <summary> /// Retrieves a SignalServiceAttachment /// </summary> /// <param name="token"></param> /// <param name="pointer">The <see cref="SignalServiceAttachmentPointer"/> /// received in a <see cref="SignalServiceDataMessage"/></param> /// <param name="tmpCipherDestination">The temporary destination for this attachment before decryption</param> /// <param name="maxSizeBytes">The maximum size for this attachment (not yet implemented)</param> /// <param name="listener">An optional listener (may be null) to receive callbacks on download progress.</param> public async Task <Stream> RetrieveAttachment(CancellationToken token, SignalServiceAttachmentPointer pointer, Stream tmpCipherDestination, int maxSizeBytes, IProgressListener listener) { await Socket.RetrieveAttachment(token, pointer.Id, tmpCipherDestination, maxSizeBytes); tmpCipherDestination.Position = 0; return(AttachmentCipherInputStream.CreateFor(tmpCipherDestination, pointer.Size != null ? pointer.Size.Value : 0, pointer.Key, pointer.Digest)); }
private void DecryptAttachment(SignalServiceAttachmentPointer pointer, Stream ciphertextFileStream, Stream plaintextFileStream) { byte[] buf = new byte[32]; Stream s = AttachmentCipherInputStream.CreateFor(ciphertextFileStream, pointer.Size != null ? pointer.Size.Value : 0, pointer.Key, pointer.Digest); s.CopyTo(plaintextFileStream); }