2012-12-15 27 views
2

自2010年问世以来,我一直在使用jBCrypt 0.3版本。我使用默认的getsalt()方法来设置“log_rounds”到10.鉴于密码破解硬件和方法的进展,这个值是否仍然适合作为默认值,或者我应该看一些更高的值。jBCrypt的默认log_rounds仍适用于2013

信息从javadoc中......

String pw_hash = BCrypt_v03.hashpw(plain_password, BCrypt_v03.gensalt()); 
String strong_salt = BCrypt_v03.gensalt(10) 
String stronger_salt = BCrypt_v03.gensalt(12) 

的工作成倍增加(2个** log_rounds)的量,使每个增量既是工作的两倍。默认log_rounds是10,有效范围是4到31.

回答

5

我做了一个小测试课,检查checkPw()在不同的salt log_rounds下的性能。

public void testCheckPerformance() { 
    int MULT = 1; 
    for(int i = 4; i < 31; i++) { 
     String salt = BCrypt_v03.gensalt(i); 
     String hashpw = BCrypt_v03.hashpw("my pwd", salt); 
     long startTs = System.currentTimeMillis(); 
     for(int mult = 0; mult < MULT; mult++) { 
      assertTrue(BCrypt_v03.checkpw("my pwd", hashpw)); 
     } 
     long endTs = System.currentTimeMillis(); 
     System.out.println(""+i+": " + ((endTs-startTs)/MULT)); 
    } 
} 

我的电脑是一个8核心i7 2.8GHz。结果如下:

log-rounds: time in millis. 
4: 3 
5: 3 
6: 6 
7: 11 
8: 22 
9: 46 
10: 92 
11: 188 
12: 349 
13: 780 
14: 1449 
15: 2785 
16: 5676 
17: 11247 
18: 22264 
19: 45170 

使用默认的log_rounds = 10意味着单个线程可以在0.1秒内检查登录。这可能会限制单个服务器可以实现的每秒登录检查次数。

所以我想问题是你准备花多少时间来进行密码检查,以及每秒想要调整系统的大小以应对多少次密码检查。

相关问题