Home

go-spectre @main - refs - log -
-
https://git.jolheiser.com/go-spectre.git
Go implementation for spectre/masterpassword
go-spectre / site_key.go
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
package spectre

import (
	"crypto/hmac"
	"crypto/sha256"
)

func siteKey(userKey []byte, scoper Scoper, siteName string, counter int, scope Scope) []byte {
	nameBytes := []byte(siteName)
	scopeBytes := []byte(scoper.Scope(scope))
	nameBytesLen := len(nameBytes)

	keySalt := append(scopeBytes, bigEndian(nameBytesLen)...)
	keySalt = append(keySalt, nameBytes...)
	keySalt = append(keySalt, bigEndian(counter)...)

	sign := hmac.New(sha256.New, userKey)
	sign.Write(keySalt)
	return sign.Sum(nil)
}