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

Fix the contact information to make sure the user returned by api has the dh keys

parent 5da5f482
Branches
Tags
3 merge requests!510Release,!207WIP: Client Restructure,!203Symmetric broadcast
......@@ -290,7 +290,7 @@ func Login(storageDir string, password []byte,
return nil, err
}
u := c.GetUser()
u := c.userState.PortableUserInfo()
jww.INFO.Printf("Client Logged in: \n\tTransmisstionID: %s "+
"\n\tReceptionID: %s", u.TransmissionID, u.ReceptionID)
......@@ -334,8 +334,10 @@ func Login(storageDir string, password []byte,
return nil, err
}
user := c.userState.PortableUserInfo()
c.e2e, err = e2e.Load(c.storage.GetKV(), c.network,
c.GetUser().ReceptionID, c.storage.GetE2EGroup(),
user.ReceptionID, c.storage.GetE2EGroup(),
c.rng, c.events)
if err != nil {
return nil, err
......@@ -700,7 +702,12 @@ func (c *Client) AddService(sp Service) error {
// can be serialized into a byte stream for out-of-band sharing.
func (c *Client) GetUser() user.Info {
jww.INFO.Printf("GetUser()")
return c.userState.PortableUserInfo()
cMixUser := c.userState.PortableUserInfo()
// Add e2e dh keys
e2e := c.GetE2EHandler()
cMixUser.E2eDhPrivateKey = e2e.GetHistoricalDHPrivkey().DeepCopy()
cMixUser.E2eDhPublicKey = e2e.GetHistoricalDHPubkey().DeepCopy()
return cMixUser
}
// GetComms returns the client comms object
......
......@@ -82,6 +82,7 @@ func writeContact(c contact.Contact) {
if outfilePath == "" {
return
}
jww.INFO.Printf("PubKey WRITE: %s", c.DhPubKey.Text(10))
err := ioutil.WriteFile(outfilePath, c.Marshal(), 0644)
if err != nil {
jww.FATAL.Panicf("%+v", err)
......@@ -102,5 +103,6 @@ func readContact() contact.Contact {
if err != nil {
jww.FATAL.Panicf("Failed to unmarshal contact: %+v", err)
}
jww.INFO.Printf("PubKey READ: %s", c.DhPubKey.Text(10))
return c
}
......@@ -27,11 +27,25 @@ func Load(kv *versioned.KV, myID *id.ID, grp *cyclic.Group,
*Ratchet, error) {
kv = kv.Prefix(packagePrefix)
privKey, err := util.LoadCyclicKey(kv, privKeyKey)
if err != nil {
return nil, errors.WithMessage(err,
"Failed to load e2e DH private key")
}
pubKey, err := util.LoadCyclicKey(kv, pubKeyKey)
if err != nil {
return nil, errors.WithMessage(err,
"Failed to load e2e DH public key")
}
r := &Ratchet{
managers: make(map[id.ID]partner.Manager),
services: make(map[string]message.Processor),
myID: myID,
advertisedDHPrivateKey: privKey,
advertisedDHPublicKey: pubKey,
kv: kv,
......@@ -92,6 +106,15 @@ func (r *Ratchet) marshal() ([]byte, error) {
index++
}
err := util.StoreCyclicKey(r.kv, r.advertisedDHPrivateKey, privKeyKey)
if err != nil {
return nil, err
}
err = util.StoreCyclicKey(r.kv, r.advertisedDHPublicKey, pubKeyKey)
if err != nil {
return nil, err
}
return json.Marshal(&contacts)
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment