bcrypt-ruby 2.1.3-java → 2.1.4-java
Sign up to get free protection for your applications and to get access to all the features.
- data/bcrypt-ruby.gemspec +1 -1
- data/ext/jruby/bcrypt_jruby/BCrypt.java +7 -7
- data/lib/bcrypt_ext.jar +0 -0
- data/spec/TestBCrypt.java +19 -0
- metadata +3 -3
data/bcrypt-ruby.gemspec
CHANGED
@@ -63,7 +63,7 @@ import java.security.SecureRandom;
|
|
63
63
|
*/
|
64
64
|
public class BCrypt {
|
65
65
|
// BCrypt parameters
|
66
|
-
private static int GENSALT_DEFAULT_LOG2_ROUNDS = 10;
|
66
|
+
private static final int GENSALT_DEFAULT_LOG2_ROUNDS = 10;
|
67
67
|
private static final int BCRYPT_SALT_LEN = 16;
|
68
68
|
|
69
69
|
// Blowfish parameters
|
@@ -655,13 +655,14 @@ public class BCrypt {
|
|
655
655
|
|
656
656
|
if (salt.charAt(0) != '$' || salt.charAt(1) != '2')
|
657
657
|
throw new IllegalArgumentException ("Invalid salt version");
|
658
|
-
if (salt.charAt(
|
658
|
+
if (salt.charAt(2) == '$')
|
659
|
+
off = 3;
|
660
|
+
else {
|
659
661
|
minor = salt.charAt(2);
|
660
662
|
if (minor != 'a' || salt.charAt(3) != '$')
|
661
663
|
throw new IllegalArgumentException ("Invalid salt revision");
|
662
664
|
off = 4;
|
663
|
-
}
|
664
|
-
off = 3;
|
665
|
+
}
|
665
666
|
|
666
667
|
// Extract number of rounds
|
667
668
|
if (salt.charAt(off + 2) > '$')
|
@@ -670,10 +671,9 @@ public class BCrypt {
|
|
670
671
|
|
671
672
|
real_salt = salt.substring(off + 3, off + 25);
|
672
673
|
try {
|
673
|
-
passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes("
|
674
|
+
passwordb = (password + (minor >= 'a' ? "\000" : "")).getBytes("UTF-8");
|
674
675
|
} catch (UnsupportedEncodingException uee) {
|
675
|
-
|
676
|
-
throw new AssertionError("US-ASCII is not supported");
|
676
|
+
throw new AssertionError("UTF-8 is not supported");
|
677
677
|
}
|
678
678
|
|
679
679
|
saltb = decode_base64(real_salt, BCRYPT_SALT_LEN);
|
data/lib/bcrypt_ext.jar
CHANGED
Binary file
|
data/spec/TestBCrypt.java
CHANGED
@@ -172,4 +172,23 @@ public class TestBCrypt extends TestCase {
|
|
172
172
|
}
|
173
173
|
System.out.println("");
|
174
174
|
}
|
175
|
+
|
176
|
+
/**
|
177
|
+
* Test for correct hashing of non-US-ASCII passwords
|
178
|
+
*/
|
179
|
+
public void testInternationalChars() {
|
180
|
+
System.out.print("BCrypt.hashpw w/ international chars: ");
|
181
|
+
String pw1 = "ππππππππ";
|
182
|
+
String pw2 = "????????";
|
183
|
+
|
184
|
+
String h1 = BCrypt.hashpw(pw1, BCrypt.gensalt());
|
185
|
+
assertFalse(BCrypt.checkpw(pw2, h1));
|
186
|
+
System.out.print(".");
|
187
|
+
|
188
|
+
String h2 = BCrypt.hashpw(pw2, BCrypt.gensalt());
|
189
|
+
assertFalse(BCrypt.checkpw(pw1, h2));
|
190
|
+
System.out.print(".");
|
191
|
+
System.out.println("");
|
192
|
+
}
|
193
|
+
|
175
194
|
}
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 2
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 2.1.
|
8
|
+
- 4
|
9
|
+
version: 2.1.4
|
10
10
|
platform: java
|
11
11
|
authors:
|
12
12
|
- Coda Hale
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2011-01-08 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|