-
-
Notifications
You must be signed in to change notification settings - Fork 620
MatrixRTC: Refactor | Introduce a new Encryption manager (used with experimental to device transport) #4799
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
Open
BillCarsonFr
wants to merge
18
commits into
develop
Choose a base branch
from
valere/rtc/simple_encryption_manager
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
0f4e370
refactor: New encryption manager BasicEncryptionManager for todevice
BillCarsonFr b19c7a6
fix: ToDevice transport not setting the sent_ts
BillCarsonFr 6411597
test: BasicEncryptionManager add statistics tests
BillCarsonFr 7e0cf4d
code review
BillCarsonFr ecf3f82
Merge branch 'develop' into valere/rtc/simple_encryption_manager
BillCarsonFr c1b9e0f
feat: Encryption manager just reshare on new joiner
BillCarsonFr 8ad79ef
refactor: Rename BasicEncryptionManger to RTCEncryptionManager
BillCarsonFr ec4c466
fixup: RTC experimental todevice should use new encryption mgr
BillCarsonFr 80bd66d
fixup: use proper logger hierarchy
BillCarsonFr d79fc58
fixup: RTC rollout first key asap even if no members to send to
BillCarsonFr 8e9af36
fixup: RTC add test for first key use
BillCarsonFr 9b06920
Merge branch 'develop' into valere/rtc/simple_encryption_manager
BillCarsonFr a9413f9
fixup! emitting outbound key before anyone registered
BillCarsonFr be3c359
fix: quick patch for transport switch, need test
BillCarsonFr 07af3d9
test: RTC encryption manager, add test for transport switch
BillCarsonFr 5e7043f
Merge branch 'develop' into valere/rtc/simple_encryption_manager
BillCarsonFr cf05a8f
post rebase fix
BillCarsonFr 64cbec1
Merge branch 'develop' into valere/rtc/simple_encryption_manager
BillCarsonFr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -129,5 +129,6 @@ | |
"outputDirectory": "coverage", | ||
"outputName": "jest-sonar-report.xml", | ||
"relativePaths": true | ||
} | ||
}, | ||
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" | ||
} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
Copyright 2025 The Matrix.org Foundation C.I.C. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
import { KeyBuffer } from "../../../src/matrixrtc/utils.ts"; | ||
import { type InboundEncryptionSession } from "../../../src/matrixrtc"; | ||
|
||
describe("KeyBuffer Test", () => { | ||
it("Should buffer and disambiguate keys by timestamp", () => { | ||
jest.useFakeTimers(); | ||
|
||
const buffer = new KeyBuffer(1000); | ||
|
||
const aKey = fakeInboundSessionWithTimestamp(1000); | ||
const olderKey = fakeInboundSessionWithTimestamp(300); | ||
// Simulate receiving out of order keys | ||
|
||
const init = buffer.disambiguate(aKey.participantId, aKey); | ||
expect(init).toEqual(aKey); | ||
// Some time pass | ||
jest.advanceTimersByTime(600); | ||
// Then we receive the most recent key out of order | ||
|
||
const key = buffer.disambiguate(aKey.participantId, olderKey); | ||
// this key is older and should be ignored even if received after | ||
expect(key).toBe(null); | ||
}); | ||
|
||
it("Should clear buffer after ttl", () => { | ||
jest.useFakeTimers(); | ||
|
||
const buffer = new KeyBuffer(1000); | ||
|
||
const aKey = fakeInboundSessionWithTimestamp(1000); | ||
const olderKey = fakeInboundSessionWithTimestamp(300); | ||
// Simulate receiving out of order keys | ||
|
||
const init = buffer.disambiguate(aKey.participantId, aKey); | ||
expect(init).toEqual(aKey); | ||
|
||
// Similar to previous test but there is too much delay | ||
// We don't want to keep key material for too long | ||
jest.advanceTimersByTime(1200); | ||
|
||
const key = buffer.disambiguate(aKey.participantId, olderKey); | ||
// The buffer is cleared so should return this key | ||
expect(key).toBe(olderKey); | ||
}); | ||
|
||
function fakeInboundSessionWithTimestamp(ts: number): InboundEncryptionSession { | ||
return { | ||
keyIndex: 0, | ||
creationTS: ts, | ||
participantId: "@alice:localhost|ABCDE", | ||
key: new Uint8Array(16), | ||
}; | ||
} | ||
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 looks like corepack is enabled.