james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From adup...@apache.org
Subject [1/4] james-project git commit: JAMES-2201 Add unit test for SHA-1 collision with Cassandra blob IDs
Date Wed, 08 Nov 2017 10:42:51 GMT
Repository: james-project
Updated Branches:
  refs/heads/master 0e99fb117 -> 5afa61ba0


JAMES-2201 Add unit test for SHA-1 collision with Cassandra blob 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/5afa61ba
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5afa61ba
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5afa61ba

Branch: refs/heads/master
Commit: 5afa61ba07d2ef4c27674220e8c06f357f457a9c
Parents: feea786
Author: Thibaut SAUTEREAU <tsautereau@linagora.com>
Authored: Wed Oct 25 17:29:39 2017 +0700
Committer: Thibaut SAUTEREAU <tsautereau@linagora.com>
Committed: Wed Nov 8 17:26:58 2017 +0700

----------------------------------------------------------------------
 .../james/mailbox/cassandra/ids/BlobIdTest.java   |  10 ++++++++++
 .../cassandra/src/test/resources/shattered-1.pdf  | Bin 0 -> 422435 bytes
 .../cassandra/src/test/resources/shattered-2.pdf  | Bin 0 -> 422435 bytes
 3 files changed, 10 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5afa61ba/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/ids/BlobIdTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/ids/BlobIdTest.java
b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/ids/BlobIdTest.java
index 3e17004..0261274 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/ids/BlobIdTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/ids/BlobIdTest.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.cassandra.ids;
 
 import static org.assertj.core.api.Assertions.assertThat;
 
+import org.apache.commons.io.IOUtils;
 import org.junit.Rule;
 import org.junit.Test;
 import org.junit.rules.ExpectedException;
@@ -80,4 +81,13 @@ public class BlobIdTest {
 
         assertThat(blobId.getId()).isEqualTo("ed7002b439e9ac845f22357d822bac1444730fbdb6016d3ec9432297b9ec9f73");
     }
+
+    @Test
+    public void forPayloadShouldCalculateDifferentHashesWhenCraftedSha1Collision() throws
Exception {
+        byte[] payload1 = IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("shattered-1.pdf"));
+        byte[] payload2 = IOUtils.toByteArray(ClassLoader.getSystemResourceAsStream("shattered-2.pdf"));
+        BlobId blobId1 = BlobId.forPayload(payload1);
+        BlobId blobId2 = BlobId.forPayload(payload2);
+        assertThat(blobId1).isNotEqualTo(blobId2);
+    }
 }

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

http://git-wip-us.apache.org/repos/asf/james-project/blob/5afa61ba/mailbox/cassandra/src/test/resources/shattered-2.pdf
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/resources/shattered-2.pdf b/mailbox/cassandra/src/test/resources/shattered-2.pdf
new file mode 100644
index 0000000..b621eec
Binary files /dev/null and b/mailbox/cassandra/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