forked from cwtch.im/cwtch
Compare commits
1 Commits
master
...
constructe
Author | SHA1 | Date |
---|---|---|
Sarah Jamie Lewis | 40934b4a47 |
|
@ -26,6 +26,7 @@ type Group struct {
|
||||||
Owner string
|
Owner string
|
||||||
IsCompromised bool
|
IsCompromised bool
|
||||||
InitialMessage []byte
|
InitialMessage []byte
|
||||||
|
Constructed bool
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
NewMessage chan Message `json:"-"`
|
NewMessage chan Message `json:"-"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,6 +246,7 @@ func (p *Profile) ProcessInvite(gci *protocol.GroupChatInvite, peerHostname stri
|
||||||
group.InitialMessage = gci.GetInitialMessage()[:]
|
group.InitialMessage = gci.GetInitialMessage()[:]
|
||||||
group.Accepted = false
|
group.Accepted = false
|
||||||
group.Owner = peerHostname
|
group.Owner = peerHostname
|
||||||
|
group.SignedGroupID = []byte{}
|
||||||
p.AddGroup(group)
|
p.AddGroup(group)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -261,6 +262,10 @@ func (p *Profile) AddGroup(group *Group) {
|
||||||
defer p.lock.Unlock()
|
defer p.lock.Unlock()
|
||||||
p.Groups[group.GroupID] = group
|
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 {
|
} else if exists && existingGroup.Owner == group.Owner {
|
||||||
p.lock.Lock()
|
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.
|
// 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.
|
// 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.
|
// We set the flag to be handled by the UX and reject the message.
|
||||||
if !valid {
|
if !valid && !group.Constructed {
|
||||||
group.Compromised()
|
group.Compromised()
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
@ -328,7 +333,7 @@ func (p *Profile) EncryptMessageToGroup(message string, groupID string) ([]byte,
|
||||||
prevSig = group.SignedGroupID
|
prevSig = group.SignedGroupID
|
||||||
}
|
}
|
||||||
|
|
||||||
lenPadding := 1024 - len(message)
|
lenPadding := 1800 - len(message)
|
||||||
padding := make([]byte, lenPadding)
|
padding := make([]byte, lenPadding)
|
||||||
getRandomness(&padding)
|
getRandomness(&padding)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue