Skip to content
Snippets Groups Projects
Commit 93b9d13c authored by Benjamin Wenger's avatar Benjamin Wenger
Browse files

made autnetication channel creation work

parent e968b2f4
No related branches found
No related tags found
No related merge requests found
...@@ -10,11 +10,11 @@ import ( ...@@ -10,11 +10,11 @@ import (
// so this user can send messages to the desired recipient Contact. // so this user can send messages to the desired recipient Contact.
// To receive confirmation from the remote user, clients must // To receive confirmation from the remote user, clients must
// register a listener to do that. // register a listener to do that.
func (c *Client) CreateAuthenticatedChannel(recipient contact.Contact, func (c *Client) CreateAuthenticatedChannel(recipient contact.Contact) error {
payload []byte) error { jww.INFO.Printf("CreateAuthenticatedChannel(%v)", recipient)
jww.INFO.Printf("CreateAuthenticatedChannel(%v, %v)", sesParam := e2e.GetDefaultSessionParams()
recipient, payload) return c.storage.E2e().AddPartner(recipient.ID, recipient.DhPubKey,
return nil sesParam, sesParam)
} }
// RegisterAuthConfirmationCb registers a callback for channel // RegisterAuthConfirmationCb registers a callback for channel
...@@ -32,15 +32,15 @@ func (c *Client) RegisterAuthRequestCb(cb func(contact contact.Contact, ...@@ -32,15 +32,15 @@ func (c *Client) RegisterAuthRequestCb(cb func(contact contact.Contact,
} }
// Create an insecure e2e relationship with a precanned user // Create an insecure e2e relationship with a precanned user
func (c *Client) MakePrecannedAuthenticatedChannel(precannedID uint) contact.Contact { func (c *Client) MakePrecannedAuthenticatedChannel(precannedID uint) (contact.Contact, error) {
precan := c.MakePrecannedContact(precannedID) precan := c.MakePrecannedContact(precannedID)
//add the precanned user as a e2e contact //add the precanned user as a e2e contact
sesParam := e2e.GetDefaultSessionParams() sesParam := e2e.GetDefaultSessionParams()
c.storage.E2e().AddPartner(precan.ID, precan.DhPubKey, sesParam, sesParam) err := c.storage.E2e().AddPartner(precan.ID, precan.DhPubKey, sesParam, sesParam)
return precan return precan, err
} }
// Create an insecure e2e contact object for a precanned user // Create an insecure e2e contact object for a precanned user
......
...@@ -144,10 +144,14 @@ func (s *Store) save() error { ...@@ -144,10 +144,14 @@ func (s *Store) save() error {
} }
func (s *Store) AddPartner(partnerID *id.ID, partnerPubKey *cyclic.Int, func (s *Store) AddPartner(partnerID *id.ID, partnerPubKey *cyclic.Int,
sendParams, receiveParams SessionParams) { sendParams, receiveParams SessionParams) error {
s.mux.Lock() s.mux.Lock()
defer s.mux.Unlock() defer s.mux.Unlock()
if _, ok := s.managers[*partnerID]; ok {
return errors.New("Cannot overwrite existing partner")
}
m := newManager(s.context, s.kv, partnerID, s.dhPrivateKey, partnerPubKey, m := newManager(s.context, s.kv, partnerID, s.dhPrivateKey, partnerPubKey,
sendParams, receiveParams) sendParams, receiveParams)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment