summaryrefslogtreecommitdiffstats
path: root/roseh.moe.go
diff options
context:
space:
mode:
Diffstat (limited to 'roseh.moe.go')
-rw-r--r--roseh.moe.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/roseh.moe.go b/roseh.moe.go
index 6d1ccea..5791f46 100644
--- a/roseh.moe.go
+++ b/roseh.moe.go
@@ -24,6 +24,7 @@ import (
"time"
"github.com/skip2/go-qrcode"
+ "roseh.moe/cmd/roseh.moe/internal/pwhash"
"roseh.moe/pkg/ccl"
"roseh.moe/pkg/wordlist"
)
@@ -39,8 +40,6 @@ var (
serverStartTime = time.Now()
)
-const targetSecurityLevel = 16
-
var notepadPassword, secretKey []byte
func loadSecrets() error {
@@ -322,14 +321,14 @@ func wormholeQR(w http.ResponseWriter, r *http.Request) {
w.Write(qr)
}
-const macSize = targetSecurityLevel
+const macSize = sha256.Size
func mac(msg []byte, purpose string) []byte {
mac := hmac.New(sha256.New, secretKey)
io.WriteString(mac, purpose)
io.WriteString(mac, ":")
mac.Write(msg)
- return mac.Sum(nil)[:macSize]
+ return mac.Sum(nil)
}
func verify(msg, messageMAC []byte, purpose string) bool {
@@ -422,9 +421,8 @@ func cookieAuth(w http.ResponseWriter, r *http.Request) bool {
}
func checkPassword(password string) bool {
- const pwHashSize = targetSecurityLevel
- hash := sha256.Sum256([]byte(password))
- return subtle.ConstantTimeCompare(hash[:pwHashSize], notepadPassword) != 0
+ hash, err := pwhash.Hash(password, notepadPassword[:pwhash.SaltSize])
+ return err == nil && subtle.ConstantTimeCompare(hash, notepadPassword[pwhash.SaltSize:]) != 0
}
var (