diff --git a/bridge/bridgeconfig/config.go b/bridge/bridgeconfig/config.go index c7534de7..fcfc93a8 100644 --- a/bridge/bridgeconfig/config.go +++ b/bridge/bridgeconfig/config.go @@ -178,7 +178,7 @@ type EncryptionConfig struct { DeleteKeys struct { DeleteOutboundOnAck bool `yaml:"delete_outbound_on_ack"` RatchetOnDecrypt bool `yaml:"ratchet_on_decrypt"` - DeleteFullyUsedOnDecrypt bool `yamL:"delete_fully_used_on_decrypt"` + DeleteFullyUsedOnDecrypt bool `yaml:"delete_fully_used_on_decrypt"` DeletePrevOnNewSession bool `yaml:"delete_prev_on_new_session"` DeleteOnDeviceDelete bool `yaml:"delete_on_device_delete"` PeriodicallyDeleteExpired bool `yaml:"periodically_delete_expired"` diff --git a/crypto/machine.go b/crypto/machine.go index d23e4634..aaf970e7 100644 --- a/crypto/machine.go +++ b/crypto/machine.go @@ -557,9 +557,6 @@ func (mach *OlmMachine) receiveRoomKey(ctx context.Context, evt *DecryptedOlmEve Str("algorithm", string(content.Algorithm)). Str("session_id", content.SessionID.String()). Str("room_id", content.RoomID.String()). - Bool("scheduled", content.IsScheduled). - Int64("max_age", content.MaxAge). - Int("max_messages", content.MaxMessages). Logger() if content.Algorithm != id.AlgorithmMegolmV1 || evt.Keys.Ed25519 == "" { log.Debug().Msg("Ignoring weird room key") @@ -571,7 +568,13 @@ func (mach *OlmMachine) receiveRoomKey(ctx context.Context, evt *DecryptedOlmEve var maxMessages int if config != nil { maxAge = time.Duration(config.RotationPeriodMillis) * time.Millisecond + if maxAge == 0 { + maxAge = 7 * 24 * time.Hour + } maxMessages = config.RotationPeriodMessages + if maxMessages == 0 { + maxMessages = 100 + } } if content.MaxAge != 0 { maxAge = time.Duration(content.MaxAge) * time.Millisecond diff --git a/crypto/sql_store.go b/crypto/sql_store.go index faf57ec6..085ead84 100644 --- a/crypto/sql_store.go +++ b/crypto/sql_store.go @@ -408,7 +408,7 @@ func (store *SQLCryptoStore) RedactExpiredGroupSessions() ([]id.SessionID, error } func (store *SQLCryptoStore) PutWithheldGroupSession(content event.RoomKeyWithheldEventContent) error { - _, err := store.DB.Exec("INSERT INTO crypto_megolm_inbound_session (session_id, sender_key, room_id, withheld_code, withheld_reason, received_at, account_id) VALUES ($1, $2, $3, $4, $5, $6. $7)", + _, err := store.DB.Exec("INSERT INTO crypto_megolm_inbound_session (session_id, sender_key, room_id, withheld_code, withheld_reason, received_at, account_id) VALUES ($1, $2, $3, $4, $5, $6, $7)", content.SessionID, content.SenderKey, content.RoomID, content.Code, content.Reason, time.Now().UTC(), store.AccountID) return err } diff --git a/crypto/sql_store_upgrade/10-mark-ratchetable-keys.sql b/crypto/sql_store_upgrade/10-mark-ratchetable-keys.sql index 0a8d896f..6dabc2df 100644 --- a/crypto/sql_store_upgrade/10-mark-ratchetable-keys.sql +++ b/crypto/sql_store_upgrade/10-mark-ratchetable-keys.sql @@ -1,4 +1,4 @@ --- v10: Add flag for megolm sessions to mark them as safe to delete +-- v10: Add metadata for detecting when megolm sessions are safe to delete ALTER TABLE crypto_megolm_inbound_session ADD COLUMN ratchet_safety jsonb; ALTER TABLE crypto_megolm_inbound_session ADD COLUMN received_at timestamp; ALTER TABLE crypto_megolm_inbound_session ADD COLUMN max_age BIGINT;