summaryrefslogtreecommitdiffstats
path: root/internal/pwhash/pwhash.go
diff options
context:
space:
mode:
authorRose Hogenson <rosehogenson@posteo.net>2025-12-07 14:46:56 -0800
committerRose Hogenson <rosehogenson@posteo.net>2025-12-07 14:46:56 -0800
commit66e4d0829d919d575bf23d5b6bb76e69bde0c3c8 (patch)
treed3bb13e08de41763a22b560ff3aef241f3440706 /internal/pwhash/pwhash.go
parent1c63df9bb9be05182f681c96412cda304c5051f2 (diff)
downloadroseh.moe-66e4d0829d919d575bf23d5b6bb76e69bde0c3c8.tar.zst
Increase target security to 32 bytes
Diffstat (limited to 'internal/pwhash/pwhash.go')
-rw-r--r--internal/pwhash/pwhash.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/internal/pwhash/pwhash.go b/internal/pwhash/pwhash.go
new file mode 100644
index 0000000..22b5368
--- /dev/null
+++ b/internal/pwhash/pwhash.go
@@ -0,0 +1,18 @@
+package pwhash
+
+import (
+ "crypto/pbkdf2"
+ "crypto/sha512"
+)
+
+const SaltSize = 8
+
+const defaultIter = 12500992 // from tools/finditer
+
+func HashIter(password string, salt []byte, iter int) ([]byte, error) {
+ return pbkdf2.Key(sha512.New, password, salt, iter, 32)
+}
+
+func Hash(password string, salt []byte) ([]byte, error) {
+ return HashIter(password, salt, defaultIter)
+}