瀏覽代碼

Merge pull request #2112 from slingamn/testvector

include a fixed test vector in password tests
tags/v2.13.0-rc1
Shivaram Lingamneni 4 月之前
父節點
當前提交
cc1c491afe
沒有連結到貢獻者的電子郵件帳戶。
共有 1 個檔案被更改,包括 10 行新增0 行删除
  1. 10
    0
      irc/passwd/bcrypt_test.go

+ 10
- 0
irc/passwd/bcrypt_test.go 查看文件

@@ -22,6 +22,16 @@ func TestBasic(t *testing.T) {
22 22
 	}
23 23
 }
24 24
 
25
+func TestVector(t *testing.T) {
26
+	// sanity check for persisted hashes
27
+	if CompareHashAndPassword(
28
+		[]byte("$2a$12$sJokyLJ5px3Nb51DEDhsQ.wh8nfwEYuMbVYrpqO5v9Ylyj0YyVWj."),
29
+		[]byte("this is my passphrase"),
30
+	) != nil {
31
+		t.Errorf("hash comparison failed unexpectedly")
32
+	}
33
+}
34
+
25 35
 func TestLongPassphrases(t *testing.T) {
26 36
 	longPassphrase := make([]byte, 168)
27 37
 	for i := range longPassphrase {

Loading…
取消
儲存