-
Notifications
You must be signed in to change notification settings - Fork 329
feat(crypto): Add support for encrypted state events to matrix-sdk-crypto
#5519
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
4a93d4a
to
ac72e92
Compare
CodSpeed Performance ReportMerging #5519 will not alter performanceComparing Summary
|
ac72e92
to
0e56b6d
Compare
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5519 +/- ##
==========================================
+ Coverage 88.57% 88.59% +0.02%
==========================================
Files 340 340
Lines 93690 93701 +11
Branches 93690 93701 +11
==========================================
+ Hits 82982 83012 +30
+ Misses 6575 6556 -19
Partials 4133 4133 ☔ View full report in Codecov by Sentry. |
dc09c52
to
0504cf0
Compare
/// The outer state key could not be verified against the inner encrypted | ||
/// state key and type. | ||
#[cfg(feature = "experimental-encrypted-state-events")] | ||
#[error("decryption failed because the state key failed to validate")] | ||
StateKeyVerificationFailed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be split into a larger variety of cases:
MalformedStateKey
- when the outer encrypted event state key is not formatted asstr:str
.MismatchBodyType
- when the decrypted ciphertext is not a state event but the outer event is.EventTypeMismatch
- when the outer event type does not match the inner.StateKeyMismatch
- when the outer state key does not match the inner.
These may not be worth implementing?
|
||
/// The outer state key could not be verified against the inner encrypted | ||
/// state key and type. | ||
#[cfg(feature = "experimental-encrypted-state-events")] | ||
StateKeyVerificationFailed, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4edd1a2
to
dc93006
Compare
This commit also refactors out what would be common code between ::encrypt and ::encrypt_state to a helper ::encrypt_inner. Signed-off-by: Skye Elliot <[email protected]>
Signed-off-by: Skye Elliot <[email protected]>
Signed-off-by: Skye Elliot <[email protected]>
Modifies `OlmMachine::decrypt_room_event_inner` to call a new method `OlmMachine::verify_packed_state_key` which, if the event is a state event, verifies that the original event's state key, when unpacked, matches the state key and event type in the decrypted event content. Introduces MegolmError::StateKeyVerificationFailed and UnableToDecryptReason::StateKeyVerificationFailed which are thrown when the verification fails. Signed-off-by: Skye Elliot <[email protected]>
dc93006
to
17818dd
Compare
Closing in favour of a branch local to this repository for branch-matching. |
Depends on #5511, #5512 and #5523.
OutboundGroupSession::encrypt_state
.GroupSessionManager::encrypt_state
and a private helper function::encrypt_inner
.OlmMachine::encrypt_state_event
and::encrypt_state_event_raw
.OlmMachine::decrypt_room_event_inner
.