Skip to content
Snippets Groups Projects
Commit f403d392 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

attempt to lookup legacy keys when loading portable user info

parent b37953be
No related branches found
No related tags found
3 merge requests!510Release,!267Make BuildReceptionIdentity public, and make backup restore function return a...,!263Hotfix/refactor cmd
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
package user package user
import ( import (
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/storage/utility"
"gitlab.com/elixxir/crypto/backup" "gitlab.com/elixxir/crypto/backup"
"gitlab.com/elixxir/crypto/cyclic" "gitlab.com/elixxir/crypto/cyclic"
"gitlab.com/xx_network/crypto/signature/rsa" "gitlab.com/xx_network/crypto/signature/rsa"
...@@ -85,6 +87,7 @@ func NewUserFromBackup(backup *backup.Backup) Info { ...@@ -85,6 +87,7 @@ func NewUserFromBackup(backup *backup.Backup) Info {
func (u *User) PortableUserInfo() Info { func (u *User) PortableUserInfo() Info {
ci := u.CryptographicIdentity ci := u.CryptographicIdentity
pub, priv := u.loadLegacyDHKeys()
return Info{ return Info{
TransmissionID: ci.GetTransmissionID().DeepCopy(), TransmissionID: ci.GetTransmissionID().DeepCopy(),
TransmissionSalt: copySlice(ci.GetTransmissionSalt()), TransmissionSalt: copySlice(ci.GetTransmissionSalt()),
...@@ -94,14 +97,40 @@ func (u *User) PortableUserInfo() Info { ...@@ -94,14 +97,40 @@ func (u *User) PortableUserInfo() Info {
ReceptionSalt: copySlice(ci.GetReceptionSalt()), ReceptionSalt: copySlice(ci.GetReceptionSalt()),
ReceptionRSA: ci.GetReceptionRSA(), ReceptionRSA: ci.GetReceptionRSA(),
Precanned: ci.IsPrecanned(), Precanned: ci.IsPrecanned(),
//fixme: set these in the e2e layer, the command line layer E2eDhPrivateKey: priv,
//needs more logical separation so this can be removed E2eDhPublicKey: pub,
E2eDhPrivateKey: nil,
E2eDhPublicKey: nil,
} }
} }
// loadLegacyDHKeys attempts to load DH Keys from legacy storage. It
// prints a warning to the log as users should be using ReceptionIdentity
// instead of PortableUserInfo
func (u *User) loadLegacyDHKeys() (pub, priv *cyclic.Int) {
jww.WARN.Printf("loading legacy e2e keys in cmix layer, please " +
"update your code to use xxdk.ReceptionIdentity")
// Legacy package prefixes and keys, see e2e/ratchet/storage.go
packagePrefix := "e2eSession"
pubKeyKey := "DhPubKey"
privKeyKey := "DhPrivKey"
kv := u.kv.Prefix(packagePrefix)
privKey, err := utility.LoadCyclicKey(kv, privKeyKey)
if err != nil {
jww.ERROR.Printf("Failed to load e2e DH private key: %v", err)
return nil, nil
}
pubKey, err := utility.LoadCyclicKey(kv, pubKeyKey)
if err != nil {
jww.ERROR.Printf("Failed to load e2e DH public key: %v", err)
return nil, nil
}
return pubKey, privKey
}
func copySlice(s []byte) []byte { func copySlice(s []byte) []byte {
n := make([]byte, len(s)) n := make([]byte, len(s))
copy(n, s) copy(n, s)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment