mirror of
https://github.com/ddworken/hishtory.git
synced 2025-08-19 11:20:18 +02:00
device ID is now a random uuid generated by the client
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user