diff --git a/model/group.go b/model/group.go index b43fbcc..109ef3b 100644 --- a/model/group.go +++ b/model/group.go @@ -26,6 +26,7 @@ type Group struct { Owner string IsCompromised bool InitialMessage []byte + Constructed bool lock sync.Mutex NewMessage chan Message `json:"-"` } diff --git a/model/profile.go b/model/profile.go index 0563cb0..beb4be7 100644 --- a/model/profile.go +++ b/model/profile.go @@ -246,6 +246,7 @@ func (p *Profile) ProcessInvite(gci *protocol.GroupChatInvite, peerHostname stri group.InitialMessage = gci.GetInitialMessage()[:] group.Accepted = false group.Owner = peerHostname + group.SignedGroupID = []byte{} p.AddGroup(group) } @@ -261,6 +262,10 @@ func (p *Profile) AddGroup(group *Group) { defer p.lock.Unlock() p.Groups[group.GroupID] = group } + } else if group.Constructed { + p.lock.Lock() + defer p.lock.Unlock() + p.Groups[group.GroupID] = group } } else if exists && existingGroup.Owner == group.Owner { p.lock.Lock() @@ -286,7 +291,7 @@ func (p *Profile) AttemptDecryption(ciphertext []byte, signature []byte) (bool, // this message is from someone who was not invited to the group. // As such this group has been compromised, probably by one of the other members. // We set the flag to be handled by the UX and reject the message. - if !valid { + if !valid && !group.Constructed { group.Compromised() return false, nil } @@ -328,7 +333,7 @@ func (p *Profile) EncryptMessageToGroup(message string, groupID string) ([]byte, prevSig = group.SignedGroupID } - lenPadding := 1024 - len(message) + lenPadding := 1800 - len(message) padding := make([]byte, lenPadding) getRandomness(&padding)