james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [3/4] james-project git commit: JAMES-2201 Add unit test for SHA-1 collision with attachment IDs
Date Wed, 08 Nov 2017 10:42:53 GMT
JAMES-2201 Add unit test for SHA-1 collision with attachment IDs


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/feea7863
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/feea7863
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/feea7863

Branch: refs/heads/master
Commit: feea7863f320d9f36a6706c238a786c03748cca3
Parents: 1795156
Author: Thibaut SAUTEREAU <tsautereau@linagora.com>
Authored: Wed Oct 25 15:53:54 2017 +0700
Committer: Thibaut SAUTEREAU <tsautereau@linagora.com>
Committed: Wed Nov 8 17:26:58 2017 +0700

----------------------------------------------------------------------
 .../james/mailbox/model/AttachmentIdTest.java     |  12 ++++++++++++
 mailbox/api/src/test/resources/shattered-1.pdf    | Bin 0 -> 422435 bytes
 mailbox/api/src/test/resources/shattered-2.pdf    | Bin 0 -> 422435 bytes
 3 files changed, 12 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/feea7863/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentIdTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentIdTest.java
b/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentIdTest.java
index 3e462b6..baf826b 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentIdTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/AttachmentIdTest.java
@@ -22,8 +22,11 @@ package org.apache.james.mailbox.model;
 import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
+import java.io.InputStream;
 import java.util.UUID;
+import java.util.stream.Stream;
 
+import org.apache.commons.io.IOUtils;
 import org.junit.Test;
 
 public class AttachmentIdTest {
@@ -123,4 +126,13 @@ public class AttachmentIdTest {
         
         assertThat(mimeType).isEqualTo("application/octet-stream");
     }
+
+    @Test
+    public void forPayloadAndTypeShouldCalculateDifferentHashesWhenCraftedSha1Collision()
throws Exception {
+        byte[] payload1 = IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("shattered-1.pdf"));
+        byte[] payload2 = IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("shattered-2.pdf"));
+        AttachmentId attachmentId1 = AttachmentId.forPayloadAndType(payload1, "application/pdf");
+        AttachmentId attachmentId2 = AttachmentId.forPayloadAndType(payload2, "application/pdf");
+        assertThat(attachmentId1).isNotEqualTo(attachmentId2);
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/feea7863/mailbox/api/src/test/resources/shattered-1.pdf
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/resources/shattered-1.pdf b/mailbox/api/src/test/resources/shattered-1.pdf
new file mode 100644
index 0000000..ba9aaa1
Binary files /dev/null and b/mailbox/api/src/test/resources/shattered-1.pdf differ

http://git-wip-us.apache.org/repos/asf/james-project/blob/feea7863/mailbox/api/src/test/resources/shattered-2.pdf
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/resources/shattered-2.pdf b/mailbox/api/src/test/resources/shattered-2.pdf
new file mode 100644
index 0000000..b621eec
Binary files /dev/null and b/mailbox/api/src/test/resources/shattered-2.pdf differ


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message