diff options
Diffstat (limited to 'internal/cryptoutil')
| -rw-r--r-- | internal/cryptoutil/cryptoutil.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/internal/cryptoutil/cryptoutil.go b/internal/cryptoutil/cryptoutil.go index c5d2a86..b58282b 100644 --- a/internal/cryptoutil/cryptoutil.go +++ b/internal/cryptoutil/cryptoutil.go @@ -62,7 +62,7 @@ type EncryptionKey []byte // An EncryptedMessage is encrypted with AES-256-CTR-HMAC-SHA256. type EncryptedMessage []byte -// HashIter runs pbkdf2-sha256 for iter iterations. Useful for benchmarking. +// HashIter runs PBKDF2-SHA256 for iter iterations. Useful for benchmarking. func HashIter(password string, salt []byte, iter int) ([]byte, error) { return pbkdf2.Key(sha256.New, password, salt, iter, sha256.Size) } @@ -94,10 +94,10 @@ func Hash(password string) (PasswordHash, error) { return append(salt, pwHash...), nil } -// CheckPassword verifies password against expectedHash and returns an +// CheckPassword verifies password against a PasswordHash and returns an // EncryptionKey derived from the password if successful. -func CheckPassword(password string, expectedHash PasswordHash) (RawKey, error) { - salt, expectedHash := expectedHash[:saltSize], expectedHash[saltSize:] +func (h PasswordHash) CheckPassword(password string) (RawKey, error) { + salt, expectedHash := h[:saltSize], h[saltSize:] key, pwHash, err := hashWithSalt(password, salt) if err != nil { return RawKey{}, err |
