Adding ghe ability to construct groups

This commit is contained in:
Sarah Jamie Lewis 2018-10-08 11:45:44 -07:00
parent e2b5e5db91
commit 40934b4a47
2 changed files with 8 additions and 2 deletions

View File

@ -26,6 +26,7 @@ type Group struct {
Owner string
IsCompromised bool
InitialMessage []byte
Constructed bool
lock sync.Mutex
NewMessage chan Message `json:"-"`
}

View File

@ -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)