2012-12-15 33 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秒內檢查登錄。這可能會限制單個服務器可以實現的每秒登錄檢查次數。

所以我想問題是你準備花多少時間來進行密碼檢查,以及每秒想要調整系統的大小以應對多少次密碼檢查。

相關問題