diff options
| author | Rose Hogenson <rosehogenson@posteo.net> | 2025-09-25 22:06:53 -0700 |
|---|---|---|
| committer | Rose Hogenson <rosehogenson@posteo.net> | 2025-09-25 22:06:53 -0700 |
| commit | 08e3307721bebd9416ea6b12eeb3fe464216ef52 (patch) | |
| tree | fdcb1c16bee8d641cf84ae19402f9d2cfb5fa74c /internal/cryptoutil/cryptoutil.go | |
| parent | 240e6e995745185c34249f1939d4c0d469a6746e (diff) | |
| download | roseh.moe-08e3307721bebd9416ea6b12eeb3fe464216ef52.tar.zst | |
Make CheckPassword a method
This works better in godoc
Diffstat (limited to 'internal/cryptoutil/cryptoutil.go')
| -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 |
