fixed to avoid exception on different length
@@ -251,10 +251,20 @@ public static boolean constantTimeAreEqual(String a, String b)
boolean isEqual = a.length() == b.length();
int len = a.length();
+ if (isEqual)
+ {
for (int i = 0; i != len; i++)
{
isEqual &= (a.charAt(i) == b.charAt(i));
}
+ }
+ else
+ {
+ for (int i = 0; i != len; i++)
+ {
+ isEqual &= (a.charAt(i) == ' ');
+ }
+ }
return isEqual;
}
