Replace old GroupID with new Dervied GroupID #357

Merged
erinn merged 6 commits from groupwiring into master 2021-05-18 19:37:18 +00:00
1 changed files with 3 additions and 1 deletions
Showing only changes of commit 967c04f9cf - Show all commits

View File

@ -88,13 +88,15 @@ func (g *Group) CheckGroup() bool {
return g.GroupID == deriveGroupID(g.GroupKey[:], g.GroupServer)
}
// deriveGroupID hashes together the key and the hostname to create a bound identifier that can later
// be referenced and checked by profiles when they receive invites and messages.
func deriveGroupID(groupKey []byte, serverHostname string) string {
data, _ := base32.StdEncoding.DecodeString(strings.ToUpper(serverHostname))
pubkey := data[0:ed25519.PublicKeySize]
return hex.EncodeToString(pbkdf2.Key(groupKey, pubkey, 4096, 16, sha512.New))
}
// Compromised should be called if we detect a a groupkey leak
// Compromised should be called if we detect a groupkey leak
func (g *Group) Compromised() {
g.IsCompromised = true
}