summaryrefslogtreecommitdiffstats
path: root/internal/pwhash/pwhash.go
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2025-09-25 21:53:40 -0700
committerRose Hogenson <rosehogenson@posteo.net>2025-09-25 21:53:40 -0700
commit240e6e995745185c34249f1939d4c0d469a6746e (patch)
treeb739a4ab16f3b6ab9981c6c433dbe92ff6bdeddc /internal/pwhash/pwhash.go
parent251ea4f8fcfd0960f6a627501eb556e109a3e2b6 (diff)
downloadroseh.moe-240e6e995745185c34249f1939d4c0d469a6746e.tar.zst
Move complex crypto logic into a helper package
Diffstat (limited to 'internal/pwhash/pwhash.go')
-rw-r--r--internal/pwhash/pwhash.go33
1 files changed, 0 insertions, 33 deletions
diff --git a/internal/pwhash/pwhash.go b/internal/pwhash/pwhash.go
deleted file mode 100644
index 9ef5d2a..0000000
--- a/internal/pwhash/pwhash.go
+++ /dev/null
@@ -1,33 +0,0 @@
-package pwhash
-
-import (
- "crypto/hkdf"
- "crypto/pbkdf2"
- "crypto/sha256"
-)
-
-const SaltLen = 2 * sha256.Size
-
-const defaultIterations = 3749890 // from cmd/finditers
-
-func HashIter(password string, salt []byte, iter int) ([]byte, error) {
- return pbkdf2.Key(sha256.New, password, salt, iter, sha256.Size)
-}
-
-func Hash(password string, salt []byte) (rawKey, pwHash []byte, err error) {
- const hashLen = 32
-
- key, err := HashIter(password, salt[:sha256.Size], defaultIterations)
- if err != nil {
- return nil, nil, err
- }
- key, err = hkdf.Extract(sha256.New, key, salt[sha256.Size:])
- if err != nil {
- return nil, nil, err
- }
- pwHash, err = hkdf.Expand(sha256.New, key, "pwhash", hashLen)
- if err != nil {
- return nil, nil, err
- }
- return key, pwHash, nil
-}