forked from cwtch.im/cwtch
Adding ghe ability to construct groups
This commit is contained in:
parent
e2b5e5db91
commit
40934b4a47
|
@ -26,6 +26,7 @@ type Group struct {
|
|||
Owner string
|
||||
IsCompromised bool
|
||||
InitialMessage []byte
|
||||
Constructed bool
|
||||
lock sync.Mutex
|
||||
NewMessage chan Message `json:"-"`
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in New Issue