device ID is now a random uuid generated by the client

This commit is contained in:
David Dworken
2022-04-03 21:00:46 -07:00
parent 32e74eb3a1
commit c5eea01a23
6 changed files with 26 additions and 33 deletions

View File

@@ -5,7 +5,6 @@ import (
"io"
"os"
"path"
"strconv"
"strings"
"time"
@@ -74,10 +73,6 @@ func UserId(key string) string {
return Hmac(key, KDF_USER_ID)
}
func DeviceId(key string, id int) string {
return Hmac(key, KDF_DEVICE_ID+strconv.Itoa(id))
}
func EncryptionKey(userSecret string) ([]byte, error) {
encryptionKey, err := base64.URLEncoding.DecodeString(Hmac(userSecret, KDF_ENCRYPTION_KEY))
if err != nil {
@@ -150,13 +145,10 @@ func EncryptHistoryEntry(userSecret string, entry HistoryEntry) (EncHistoryEntry
}, nil
}
func DecryptHistoryEntry(userSecret string, deviceId int, entry EncHistoryEntry) (HistoryEntry, error) {
func DecryptHistoryEntry(userSecret string, entry EncHistoryEntry) (HistoryEntry, error) {
if entry.UserId != UserId(userSecret) {
return HistoryEntry{}, fmt.Errorf("Refusing to decrypt history entry with mismatching UserId")
}
if entry.DeviceId != DeviceId(userSecret, deviceId) {
return HistoryEntry{}, fmt.Errorf("Refusing to decrypt history entry with mismatching DeviceId")
}
plaintext, err := Decrypt(userSecret, entry.EncryptedData, []byte(UserId(userSecret)), entry.Nonce)
if err != nil {
return HistoryEntry{}, nil