diff --git a/libsignal/service/src/main/java/org/whispersystems/signalservice/internal/push/http/AttachmentCipherOutputStreamFactory.kt b/libsignal/service/src/main/java/org/whispersystems/signalservice/internal/push/http/AttachmentCipherOutputStreamFactory.kt index 25623ad241..1fb68054e0 100644 --- a/libsignal/service/src/main/java/org/whispersystems/signalservice/internal/push/http/AttachmentCipherOutputStreamFactory.kt +++ b/libsignal/service/src/main/java/org/whispersystems/signalservice/internal/push/http/AttachmentCipherOutputStreamFactory.kt @@ -33,7 +33,7 @@ class AttachmentCipherOutputStreamFactory(private val key: ByteArray, private va } val privateKey = key.sliceArray(AES_KEY_LENGTH until key.size) - val chunkSizeChoice = ChunkSizeChoice.inferChunkSize(length.toInt().coerceAtLeast(1)) + val chunkSizeChoice = ChunkSizeChoice.inferChunkSize(length.toInt()) val incrementalStream = IncrementalMacOutputStream(wrap, privateKey, chunkSizeChoice, incrementalDigestOut) return createFor(incrementalStream) } diff --git a/libsignal/service/src/test/java/org/whispersystems/signalservice/api/crypto/AttachmentCipherTest.java b/libsignal/service/src/test/java/org/whispersystems/signalservice/api/crypto/AttachmentCipherTest.java index 1ce1a999e6..7460ceca54 100644 --- a/libsignal/service/src/test/java/org/whispersystems/signalservice/api/crypto/AttachmentCipherTest.java +++ b/libsignal/service/src/test/java/org/whispersystems/signalservice/api/crypto/AttachmentCipherTest.java @@ -67,12 +67,12 @@ public final class AttachmentCipherTest { try { byte[] key = Util.getSecretBytes(64); byte[] plaintextInput = "Gwen Stacy".getBytes(); - EncryptResult encryptResult = encryptData(plaintextInput, key, false); + EncryptResult encryptResult = encryptData(plaintextInput, key, true); byte[] badKey = new byte[64]; cipherFile = writeToFile(encryptResult.ciphertext); - AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, badKey, encryptResult.digest, encryptResult.incrementalDigest); + AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, badKey, encryptResult.digest, null); } catch (InvalidMessageException e) { hitCorrectException = true; } finally { @@ -92,12 +92,12 @@ public final class AttachmentCipherTest { try { byte[] key = Util.getSecretBytes(64); byte[] plaintextInput = "Mary Jane Watson".getBytes(); - EncryptResult encryptResult = encryptData(plaintextInput, key, false); + EncryptResult encryptResult = encryptData(plaintextInput, key, true); byte[] badDigest = new byte[32]; cipherFile = writeToFile(encryptResult.ciphertext); - AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, key, badDigest, encryptResult.incrementalDigest); + AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, key, badDigest, null); } catch (InvalidMessageException e) { hitCorrectException = true; } finally { @@ -213,14 +213,14 @@ public final class AttachmentCipherTest { try { byte[] key = Util.getSecretBytes(64); byte[] plaintextInput = "Uncle Ben".getBytes(); - EncryptResult encryptResult = encryptData(plaintextInput, key, false); + EncryptResult encryptResult = encryptData(plaintextInput, key, true); byte[] badMacCiphertext = Arrays.copyOf(encryptResult.ciphertext, encryptResult.ciphertext.length); badMacCiphertext[badMacCiphertext.length - 1] += 1; cipherFile = writeToFile(badMacCiphertext); - AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, key, encryptResult.digest, encryptResult.incrementalDigest); + AttachmentCipherInputStream.createForAttachment(cipherFile, plaintextInput.length, key, encryptResult.digest, null); fail(); } catch (InvalidMessageException e) { hitCorrectException = true;