Skip to content

Commit b539522

Browse files
committed
Test to show that Utils.equal(byte[], byte[]) is broken
1 parent 823c069 commit b539522

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

test/net/i2p/crypto/eddsa/UtilsTest.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class UtilsTest {
1616
* Test method for {@link net.i2p.crypto.eddsa.Utils#equal(int, int)}.
1717
*/
1818
@Test
19-
public void testEqual() {
19+
public void testIntEqual() {
2020
assertThat(Utils.equal(0, 0), is(1));
2121
assertThat(Utils.equal(1, 1), is(1));
2222
assertThat(Utils.equal(1, 0), is(0));
@@ -27,6 +27,21 @@ public void testEqual() {
2727
assertThat(Utils.equal(-255, -256), is(0));
2828
}
2929

30+
/**
31+
* Test method for {@link net.i2p.crypto.eddsa.Utils#equal(byte[], byte[])}.
32+
*/
33+
@Test
34+
public void testByteArrayEqual() {
35+
byte[] zero = new byte[32];
36+
byte[] one = new byte[32];
37+
one[0] = 1;
38+
39+
assertThat(Utils.equal(zero, zero), is(1));
40+
assertThat(Utils.equal(one, one), is(1));
41+
assertThat(Utils.equal(one, zero), is(0));
42+
assertThat(Utils.equal(zero, one), is(0));
43+
}
44+
3045
/**
3146
* Test method for {@link net.i2p.crypto.eddsa.Utils#negative(int)}.
3247
*/

0 commit comments

Comments
 (0)