| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public static int | Returns: 0 if not equal. 1 if equal.the first value. x, int the second value. y)Compare two |
| public static int | Returns: 0 if not equal. 1 if equal.the first value. x, long the second value. y)Compare two |
| public static int | Returns: 0 if not equal. 1 if equal.the first byte array. bytes1, int the position (inclusive) to start comparing in startPos1, byte[] bytes1.the second byte array. bytes2, int the position (inclusive) to start comparing in startPos2, int bytes2.the amount of bytes to compare. This is assumed to be validated as not going out of bounds
by the caller. length)Compare two |
| public static int | Returns: 0 if not equal. 1 if equal.the first value. s1, CharSequence the second value. s2)Compare two |
| ConstantTimeUtils | back to summary |
|---|---|
| private ConstantTimeUtils() | |
| equalsConstantTime | back to summary |
|---|---|
| public static int equalsConstantTime(int x, int y) Compare two
The
int l1 = 1;
int l2 = 1;
int l3 = 1;
int l4 = 500;
boolean equals = (equalsConstantTime(l1, l2) & equalsConstantTime(l3, l4)) != 0;
| |
| equalsConstantTime | back to summary |
|---|---|
| public static int equalsConstantTime(long x, long y) Compare two
The
long l1 = 1;
long l2 = 1;
long l3 = 1;
long l4 = 500;
boolean equals = (equalsConstantTime(l1, l2) & equalsConstantTime(l3, l4)) != 0;
| |
| equalsConstantTime | back to summary |
|---|---|
| public static int equalsConstantTime(byte[] bytes1, int startPos1, byte[] bytes2, int startPos2, int length) Compare two
The
byte[] s1 = new {1, 2, 3};
byte[] s2 = new {1, 2, 3};
byte[] s3 = new {1, 2, 3};
byte[] s4 = new {4, 5, 6};
boolean equals = (equalsConstantTime(s1, 0, s2, 0, s1.length) &
equalsConstantTime(s3, 0, s4, 0, s3.length)) != 0;
| |
| equalsConstantTime | back to summary |
|---|---|
| public static int equalsConstantTime(CharSequence s1, CharSequence s2) Compare two
The
String s1 = "foo";
String s2 = "foo";
String s3 = "foo";
String s4 = "goo";
boolean equals = (equalsConstantTime(s1, s2) & equalsConstantTime(s3, s4)) != 0;
| |