summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--internal/cryptoutil/cryptoutil.go8
-rw-r--r--roseh.moe.go2
2 files changed, 5 insertions, 5 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
diff --git a/roseh.moe.go b/roseh.moe.go
index 6624706..e38677d 100644
--- a/roseh.moe.go
+++ b/roseh.moe.go
@@ -205,7 +205,7 @@ type loginTemplateArgs struct {
}
func login(w http.ResponseWriter, r *http.Request) {
- rawKey, err := cryptoutil.CheckPassword(r.FormValue("password"), notepadPassword)
+ rawKey, err := notepadPassword.CheckPassword(r.FormValue("password"))
if err != nil {
if err := loginTemplate.Execute(w, loginTemplateArgs{Error: true}); err != nil {
log.Printf("Warning: login: %s", err)