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

Add a wait loop to wait for rekeying when we run out of keys

parent 0583d19d
Branches
Tags
No related merge requests found
...@@ -15,12 +15,15 @@ import ( ...@@ -15,12 +15,15 @@ import (
type E2E struct { type E2E struct {
Type SendType Type SendType
RetryCount int
CMIX CMIX
} }
func GetDefaultE2E() E2E { func GetDefaultE2E() E2E {
return E2E{Type: Standard, return E2E{
Type: Standard,
CMIX: GetDefaultCMIX(), CMIX: GetDefaultCMIX(),
RetryCount: 10,
} }
} }
func (e E2E) Marshal() ([]byte, error) { func (e E2E) Marshal() ([]byte, error) {
......
...@@ -50,7 +50,7 @@ func (m *Manager) handleMessage(ecrMsg format.Message, identity reception.Identi ...@@ -50,7 +50,7 @@ func (m *Manager) handleMessage(ecrMsg format.Message, identity reception.Identi
forMe, err := fingerprint2.CheckIdentityFP(ecrMsg.GetIdentityFP(), forMe, err := fingerprint2.CheckIdentityFP(ecrMsg.GetIdentityFP(),
ecrMsg.GetContents(), identity.Source) ecrMsg.GetContents(), identity.Source)
if err != nil { if err != nil {
jww.FATAL.Panicf("Could not check IdentityFIngerprint: %+v", err) jww.FATAL.Panicf("Could not check IdentityFingerprint: %+v", err)
} }
if !forMe { if !forMe {
return return
......
...@@ -9,6 +9,7 @@ package message ...@@ -9,6 +9,7 @@ package message
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/interfaces/message" "gitlab.com/elixxir/client/interfaces/message"
"gitlab.com/elixxir/client/interfaces/params" "gitlab.com/elixxir/client/interfaces/params"
"gitlab.com/elixxir/client/keyExchange" "gitlab.com/elixxir/client/keyExchange"
...@@ -17,7 +18,6 @@ import ( ...@@ -17,7 +18,6 @@ import (
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"sync" "sync"
"time" "time"
jww "github.com/spf13/jwalterweatherman"
) )
func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, e2e.MessageID, error) { func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, e2e.MessageID, error) {
...@@ -51,7 +51,6 @@ func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, e2e.M ...@@ -51,7 +51,6 @@ func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, e2e.M
jww.INFO.Printf("E2E sending %d messages to %s", jww.INFO.Printf("E2E sending %d messages to %s",
len(partitions), msg.Recipient) len(partitions), msg.Recipient)
for i, p := range partitions { for i, p := range partitions {
//create the cmix message //create the cmix message
msgCmix := format.NewMessage(m.Session.Cmix().GetGroup().GetP().ByteLen()) msgCmix := format.NewMessage(m.Session.Cmix().GetGroup().GetP().ByteLen())
...@@ -59,6 +58,18 @@ func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, e2e.M ...@@ -59,6 +58,18 @@ func (m *Manager) SendE2E(msg message.Send, param params.E2E) ([]id.Round, e2e.M
//get a key to end to end encrypt //get a key to end to end encrypt
key, err := partner.GetKeyForSending(param.Type) key, err := partner.GetKeyForSending(param.Type)
keyTries := 0
for err != nil && keyTries < param.RetryCount {
jww.WARN.Printf("Out of sending keys for %s "+
"(msgDigest: %s, partition: %d), this can "+
"happen when sending messages faster than "+
"the client can negotiate keys. Please "+
"adjust your e2e key parameters",
msg.Recipient, msgCmix.Digest(), i)
keyTries++
time.Sleep(param.RetryDelay)
key, err = partner.GetKeyForSending(param.Type)
}
if err != nil { if err != nil {
return nil, e2e.MessageID{}, errors.WithMessagef(err, "Failed to get key "+ return nil, e2e.MessageID{}, errors.WithMessagef(err, "Failed to get key "+
"for end to end encryption") "for end to end encryption")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment