Skip to content

Commit 6d7085f

Browse files
committed
Changed PBKDF2 hash from SHA512 to SHA256 (according to Crypt4GH specification)
1 parent 35584b2 commit 6d7085f

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

kdf/kdf.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
package kdf
33

44
import (
5-
"crypto/sha512"
5+
"crypto/sha256"
66

77
// package is old but corresponds to "golang.org/x/crypto/ssh/internal/bcrypt_pbkdf"
88
"github.com/dchest/bcrypt_pbkdf"
@@ -15,7 +15,7 @@ import (
1515
var KDFS = map[string]KDF{
1616
"scrypt": sCrypt{},
1717
"bcrypt": bCrypt{},
18-
"pbkdf2_hmac_sha256": pbkdf2sha512{},
18+
"pbkdf2_hmac_sha256": pbkdf2sha256{},
1919
}
2020

2121
// KDF interface holding "Derive" method.
@@ -37,9 +37,9 @@ func (bCrypt) Derive(rounds int, password, salt []byte) (derivedKey []byte, err
3737
return bcrypt_pbkdf.Key(password, salt, rounds, chacha20poly1305.KeySize)
3838
}
3939

40-
type pbkdf2sha512 struct {
40+
type pbkdf2sha256 struct {
4141
}
4242

43-
func (pbkdf2sha512) Derive(rounds int, password, salt []byte) (derivedKey []byte, err error) {
44-
return pbkdf2.Key(password, salt, rounds, chacha20poly1305.KeySize, sha512.New), nil
43+
func (pbkdf2sha256) Derive(rounds int, password, salt []byte) (derivedKey []byte, err error) {
44+
return pbkdf2.Key(password, salt, rounds, chacha20poly1305.KeySize, sha256.New), nil
4545
}

kdf/kdf_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func TestKDF(t *testing.T) {
2020
},
2121
{
2222
name: "pbkdf2_hmac_sha256",
23-
hash: "72bf7d2b4d1f18c97a333e3a89e7f22dc9771b968ddcbc1a494fbbf507059b13",
23+
hash: "dd3352defb9aa734875f7a32b60e4bcf9e3671216d6e0c39f135f0297bf8e121",
2424
},
2525
}
2626
for _, test := range tests {

0 commit comments

Comments
 (0)