mirror of
https://github.com/signalapp/Signal-Android.git
synced 2025-12-22 03:58:48 +00:00
Do not check incremental MAC in Glide.
This commit is contained in:
committed by
Alex Hart
parent
81e928f94e
commit
5ed4c51582
@@ -22,18 +22,14 @@ class AttachmentStreamLocalUriFetcher implements DataFetcher<InputStream> {
|
|||||||
private final File attachment;
|
private final File attachment;
|
||||||
private final byte[] key;
|
private final byte[] key;
|
||||||
private final Optional<byte[]> digest;
|
private final Optional<byte[]> digest;
|
||||||
private final Optional<byte[]> incrementalDigest;
|
|
||||||
private final int incrementalMacChunkSize;
|
|
||||||
private final long plaintextLength;
|
private final long plaintextLength;
|
||||||
|
|
||||||
private InputStream is;
|
private InputStream is;
|
||||||
|
|
||||||
AttachmentStreamLocalUriFetcher(File attachment, long plaintextLength, byte[] key, Optional<byte[]> digest, Optional<byte[]> incrementalDigest, int incrementalMacChunkSize) {
|
AttachmentStreamLocalUriFetcher(File attachment, long plaintextLength, byte[] key, Optional<byte[]> digest) {
|
||||||
this.attachment = attachment;
|
this.attachment = attachment;
|
||||||
this.plaintextLength = plaintextLength;
|
this.plaintextLength = plaintextLength;
|
||||||
this.digest = digest;
|
this.digest = digest;
|
||||||
this.incrementalDigest = incrementalDigest;
|
|
||||||
this.incrementalMacChunkSize = incrementalMacChunkSize;
|
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,7 +37,7 @@ class AttachmentStreamLocalUriFetcher implements DataFetcher<InputStream> {
|
|||||||
public void loadData(@NonNull Priority priority, @NonNull DataCallback<? super InputStream> callback) {
|
public void loadData(@NonNull Priority priority, @NonNull DataCallback<? super InputStream> callback) {
|
||||||
try {
|
try {
|
||||||
if (!digest.isPresent()) throw new InvalidMessageException("No attachment digest!");
|
if (!digest.isPresent()) throw new InvalidMessageException("No attachment digest!");
|
||||||
is = AttachmentCipherInputStream.createForAttachment(attachment, plaintextLength, key, digest.get(), incrementalDigest.orElse(null), incrementalMacChunkSize);
|
is = AttachmentCipherInputStream.createForAttachment(attachment, plaintextLength, key, digest.get(), null, 0);
|
||||||
callback.onDataReady(is);
|
callback.onDataReady(is);
|
||||||
} catch (IOException | InvalidMessageException e) {
|
} catch (IOException | InvalidMessageException e) {
|
||||||
callback.onLoadFailed(e);
|
callback.onLoadFailed(e);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class AttachmentStreamUriLoader implements ModelLoader<AttachmentModel, I
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable LoadData<InputStream> buildLoadData(@NonNull AttachmentModel attachmentModel, int width, int height, @NonNull Options options) {
|
public @Nullable LoadData<InputStream> buildLoadData(@NonNull AttachmentModel attachmentModel, int width, int height, @NonNull Options options) {
|
||||||
return new LoadData<>(attachmentModel, new AttachmentStreamLocalUriFetcher(attachmentModel.attachment, attachmentModel.plaintextLength, attachmentModel.key, attachmentModel.digest, attachmentModel.incrementalDigest, attachmentModel.incrementalMacChunkSize));
|
return new LoadData<>(attachmentModel, new AttachmentStreamLocalUriFetcher(attachmentModel.attachment, attachmentModel.plaintextLength, attachmentModel.key, attachmentModel.digest));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -53,6 +53,9 @@ public class AttachmentCipherInputStream extends FilterInputStream {
|
|||||||
private long totalRead;
|
private long totalRead;
|
||||||
private byte[] overflowBuffer;
|
private byte[] overflowBuffer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Passing in a null incrementalDigest and/or 0 for the chunk size at the call site disables incremental mac validation.
|
||||||
|
*/
|
||||||
public static InputStream createForAttachment(File file, long plaintextLength, byte[] combinedKeyMaterial, byte[] digest, byte[] incrementalDigest, int incrementalMacChunkSize)
|
public static InputStream createForAttachment(File file, long plaintextLength, byte[] combinedKeyMaterial, byte[] digest, byte[] incrementalDigest, int incrementalMacChunkSize)
|
||||||
throws InvalidMessageException, IOException
|
throws InvalidMessageException, IOException
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user