From 40ad220fd0e26e3bf3be93c536b25cde1c00490f Mon Sep 17 00:00:00 2001 From: Rose Hogenson Date: Tue, 23 Sep 2025 22:33:30 -0700 Subject: Combine password hash and salt secrets --- roseh.moe.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'roseh.moe.go') diff --git a/roseh.moe.go b/roseh.moe.go index c75acca..f24bc58 100644 --- a/roseh.moe.go +++ b/roseh.moe.go @@ -50,15 +50,11 @@ func loadSecrets() error { } for _, line := range bytes.Split(bytes.TrimSuffix(secrets, []byte("\n")), []byte("\n")) { if pw, ok := bytes.CutPrefix(line, []byte("notepad-password=")); ok { - notepadPassword = make([]byte, hex.DecodedLen(len(pw))) + buf := make([]byte, hex.DecodedLen(len(pw))) if _, err := hex.Decode(notepadPassword, pw); err != nil { return err } - } else if salt, ok := bytes.CutPrefix(line, []byte("salt=")); ok { - notepadPasswordSalt = make([]byte, hex.DecodedLen(len(salt))) - if _, err := hex.Decode(notepadPasswordSalt, salt); err != nil { - return err - } + notepadPasswordSalt, notepadPassword = buf[:pwhash.SaltLen], buf[pwhash.SaltLen:] } else if key, ok := bytes.CutPrefix(line, []byte("secret-key=")); ok { if hex.DecodedLen(len(key)) != sha512.Size256 { return fmt.Errorf("invalid HMAC-SHA512/256 key") -- cgit v1.3.1