mirror of
https://mau.dev/mautrix/go.git
synced 2026-03-14 14:25:53 +01:00
crypto/decryptmegolm: allow device key mismatches, but mark as untrusted
This commit is contained in:
parent
ae58161412
commit
974f7dc544
2 changed files with 13 additions and 2 deletions
|
|
@ -124,7 +124,13 @@ func (mach *OlmMachine) DecryptMegolmEvent(ctx context.Context, evt *event.Event
|
|||
Msg("Couldn't resolve trust level of session: sent by unknown device")
|
||||
trustLevel = id.TrustStateUnknownDevice
|
||||
} else if device.SigningKey != sess.SigningKey || device.IdentityKey != sess.SenderKey {
|
||||
return nil, ErrDeviceKeyMismatch
|
||||
log.Debug().
|
||||
Stringer("session_sender_key", sess.SenderKey).
|
||||
Stringer("device_sender_key", device.IdentityKey).
|
||||
Stringer("session_signing_key", sess.SigningKey).
|
||||
Stringer("device_signing_key", device.SigningKey).
|
||||
Msg("Device keys don't match keys in session, marking as untrusted")
|
||||
trustLevel = id.TrustStateDeviceKeyMismatch
|
||||
} else {
|
||||
trustLevel, err = mach.ResolveTrustContext(ctx, device)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ type TrustState int
|
|||
|
||||
const (
|
||||
TrustStateBlacklisted TrustState = -100
|
||||
TrustStateDeviceKeyMismatch TrustState = -5
|
||||
TrustStateUnset TrustState = 0
|
||||
TrustStateUnknownDevice TrustState = 10
|
||||
TrustStateForwarded TrustState = 20
|
||||
|
|
@ -23,7 +24,7 @@ const (
|
|||
TrustStateCrossSignedTOFU TrustState = 100
|
||||
TrustStateCrossSignedVerified TrustState = 200
|
||||
TrustStateVerified TrustState = 300
|
||||
TrustStateInvalid TrustState = (1 << 31) - 1
|
||||
TrustStateInvalid TrustState = -2147483647
|
||||
)
|
||||
|
||||
func (ts *TrustState) UnmarshalText(data []byte) error {
|
||||
|
|
@ -44,6 +45,8 @@ func ParseTrustState(val string) TrustState {
|
|||
switch strings.ToLower(val) {
|
||||
case "blacklisted":
|
||||
return TrustStateBlacklisted
|
||||
case "device-key-mismatch":
|
||||
return TrustStateDeviceKeyMismatch
|
||||
case "unverified":
|
||||
return TrustStateUnset
|
||||
case "cross-signed-untrusted":
|
||||
|
|
@ -67,6 +70,8 @@ func (ts TrustState) String() string {
|
|||
switch ts {
|
||||
case TrustStateBlacklisted:
|
||||
return "blacklisted"
|
||||
case TrustStateDeviceKeyMismatch:
|
||||
return "device-key-mismatch"
|
||||
case TrustStateUnset:
|
||||
return "unverified"
|
||||
case TrustStateCrossSignedUntrusted:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue