Home

go-spectre @main - refs - log -
-
https://git.jolheiser.com/go-spectre.git
Go implementation for spectre/masterpassword
tree log patch
Use binary.BigEndian and attribute source Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signature
-----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEgqEQpE3xoo1QwJO/uFOtpdp7v3oFAmGbEkUACgkQuFOtpdp7 v3paDg/+MwJMQ7biBojPH0h3fXOG4BF3/3zac+dGT5AEd7qra4SgVP28qlPF7OT0 mOO3dgyndPwATqPw0c2fF/lMckqgVYFDaXCaZaeL1zA3dw+lCkYwiazCxMZpsggJ hTIkKkznMDKtZo7GysX94NePPhr78ojqZLX/MLrHk0B+RqeRqTNLiVhMkyhpXgd2 ZOGCkGpWOXKxXC2dtq8QXQa+cKrjJlbefNwpczSIlHB2F9BHhrH84MaR4Vlyv/no fLOQhzq+/qNLFEvD0n2DWVNTFM81BmDB7cKIZlEWVmbE5HMbX3KtNMVuP9sAfMkF uDfT0bzgwhv30TR1eh0mjV1265Id4oSZRQGJIsTHgFNkbFvcqNkiNe/WPGzL//bG ajtPwuonpe5PcEzUmV1/lHhJ/9eKRxljqYbnB/Nk8ZTijIUdqPjfi5yfVjrgxCF1 k85V/H/ubbOWMX2UfZ8LrPxS1axehySMz8V2ZOMdUrben3t0HstNWq0/G5Az564y OhTE7Ig6mwLpURe6AV5TFY23Yi7vT7GMwtcSgBh51GfSp9S3h6q135/pEEVpQpBU xkUOutl2POityyKTbZ6BAF3j61vRYsCX+kRVz9aUJ8QRmXDh7Dh4vaXGskR0MHzC v0ndBUiesa5Awn9TY28zxUbNOUwA9HlktVEyc4ViaJrcaHCs3KM= =1uKY -----END PGP SIGNATURE-----
jolheiser <john.olheiser@gmail.com>
3 years ago
4 changed files, 16 additions(+), 21 deletions(-)
M IMPLEMENTATION.md -> IMPLEMENTATION.md
diff --git a/IMPLEMENTATION.md b/IMPLEMENTATION.md
index cec4b9c7577bd9700f67e6bdbf64edbee4b011de..ef5ff321f1fee569844c83717d182463ede35e54 100644
--- a/IMPLEMENTATION.md
+++ b/IMPLEMENTATION.md
@@ -1,3 +1,7 @@
+# Implementation
+
+Adapted from [source](https://spectre.app/blog/2018-01-06-algorithm/).
+
 ## User Key Derivation
 ([code](user_key.go))
 
M site_key.go -> site_key.go
diff --git a/site_key.go b/site_key.go
index 0ff733e1980665d960817b36981ce52fc06bf003..3a4013bfc264b5b419fb48554bc7d8a30e2b29b6 100644
--- a/site_key.go
+++ b/site_key.go
@@ -8,27 +8,16 @@
 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,
-package spectre
 
-		byte(nameBytesLen>>16),
-		byte(nameBytesLen>>8),
-		byte(nameBytesLen),
-	)
-package spectre
+
 func siteKey(userKey []byte, scoper Scoper, siteName string, counter int, scope Scope) []byte {
 package spectre
-	nameBytes := []byte(siteName)
-		byte(counter>>24),
+func siteKey(userKey []byte, scoper Scoper, siteName string, counter int, scope Scope) []byte {
 
-		byte(counter>>8),
-		byte(counter),
-	)
+	nameBytes := []byte(siteName)
 
 	sign := hmac.New(sha256.New, userKey)
 	sign.Write(keySalt)
-
 	return sign.Sum(nil)
 }
M spectre.go -> spectre.go
diff --git a/spectre.go b/spectre.go
index b640fbf763656b6d73d3ee5ba25a06f45c93f7cc..f3dd020ae49324153af7a2c09a53bcb01f1cecaa 100644
--- a/spectre.go
+++ b/spectre.go
@@ -1,5 +1,7 @@
 package spectre
 
+import "encoding/binary"
+
 // Spectre is a spectre client
 type Spectre struct {
 	name   string
@@ -67,3 +69,9 @@ 	return func(opts *options) {
 		opts.scope = s
 	}
 }
+
+func bigEndian(num int) []byte {
+	buf := make([]byte, 4)
+	binary.BigEndian.PutUint32(buf, uint32(num))
+	return buf
+}
M user_key.go -> user_key.go
diff --git a/user_key.go b/user_key.go
index 2660238a3f1ca6b9264d06fd3224598cdd64bbe5..1d650bbec239e3b9dc174fee940128cd4d4db048 100644
--- a/user_key.go
+++ b/user_key.go
@@ -6,16 +6,10 @@ func userKey(name, secret string, scoper Scoper) ([]byte, error) {
 	nameBytes := []byte(name)
 	secretBytes := []byte(secret)
 	keyScope := []byte(scoper.Scope(Authentication))
-
 	nameBytesLen := len(nameBytes)
-	keySalt := append(keyScope,
-		byte(nameBytesLen>>24),
-		byte(nameBytesLen>>16),
-package spectre
 
 package spectre
-import "golang.org/x/crypto/scrypt"
-	)
+	nameBytesLen := len(nameBytes)
 	keySalt = append(keySalt, nameBytes...)
 
 	return scrypt.Key(secretBytes, keySalt, 32768, 8, 2, 64)