mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
crypto/keysharing: ensure forwarding chains is always set
This commit is contained in:
parent
a7faac33c8
commit
bef23edaea
3 changed files with 11 additions and 5 deletions
|
|
@ -347,9 +347,6 @@ func (mach *OlmMachine) HandleRoomKeyRequest(ctx context.Context, sender id.User
|
|||
mach.rejectKeyRequest(ctx, KeyShareRejectInternalError, device, content.Body)
|
||||
return
|
||||
}
|
||||
if igs.ForwardingChains == nil {
|
||||
igs.ForwardingChains = []string{}
|
||||
}
|
||||
|
||||
forwardedRoomKey := event.Content{
|
||||
Parsed: &event.ForwardedRoomKeyEventContent{
|
||||
|
|
@ -360,7 +357,7 @@ func (mach *OlmMachine) HandleRoomKeyRequest(ctx context.Context, sender id.User
|
|||
SessionKey: string(exportedKey),
|
||||
},
|
||||
SenderKey: content.Body.SenderKey,
|
||||
ForwardingKeyChain: igs.ForwardingChains,
|
||||
ForwardingKeyChain: igs.ForwardingChainsOrEmpty(),
|
||||
SenderClaimedKey: igs.SigningKey,
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@ func NewInboundGroupSession(senderKey id.SenderKey, signingKey id.Ed25519, roomI
|
|||
SigningKey: signingKey,
|
||||
SenderKey: senderKey,
|
||||
RoomID: roomID,
|
||||
ForwardingChains: nil,
|
||||
ForwardingChains: []string{},
|
||||
ReceivedAt: time.Now().UTC(),
|
||||
MaxAge: maxAge.Milliseconds(),
|
||||
MaxMessages: maxMessages,
|
||||
|
|
@ -133,6 +133,13 @@ func NewInboundGroupSession(senderKey id.SenderKey, signingKey id.Ed25519, roomI
|
|||
}, nil
|
||||
}
|
||||
|
||||
func (igs *InboundGroupSession) ForwardingChainsOrEmpty() []string {
|
||||
if igs.ForwardingChains == nil {
|
||||
return []string{}
|
||||
}
|
||||
return igs.ForwardingChains
|
||||
}
|
||||
|
||||
func (igs *InboundGroupSession) ID() id.SessionID {
|
||||
if igs.id == "" {
|
||||
igs.id = igs.Internal.ID()
|
||||
|
|
|
|||
|
|
@ -509,6 +509,8 @@ func (store *SQLCryptoStore) postScanInboundGroupSession(sessionBytes, ratchetSa
|
|||
}
|
||||
if forwardingChains != "" {
|
||||
chains = strings.Split(forwardingChains, ",")
|
||||
} else {
|
||||
chains = []string{}
|
||||
}
|
||||
var rs RatchetSafety
|
||||
if len(ratchetSafetyBytes) > 0 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue