Skip to content
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

Device Dehydration | js-sdk: store/load dehydration key #4599

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

BillCarsonFr
Copy link
Member

Fixes #4483

Draft because depends on rust-sdk: matrix-org/matrix-rust-sdk#4399 and needs new wasm bindings version.

Added basic support to cache created keys and read from store instead of in memory.
Then adding some basic signalling to DeviceDehydrationManager, helpfull for tests and also for apps to have some feedbacks on device rehydration (reports progress for example)

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.
  • Sign-off given on the changes (see CONTRIBUTING.md).

Copy link
Member

@uhoreg uhoreg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only did a quick review because the the compiler errors are distracting

const keyB64 = await this.secretStorage.get(SECRET_STORAGE_NAME);
if (keyB64 === undefined) {
if (!create) {
return null;
}
await this.resetKey();
} else {
this.key = decodeBase64(keyB64);
const bytes = decodeBase64(keyB64);
const key = RustSdkCryptoJs.DehydratedDeviceKey.createKeyFromArray(bytes);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bytes should be zeroed out after this line, to avoid keeping the key in memory

@@ -190,7 +202,7 @@ export class DehydratedDeviceManager {
* Returns whether or not a dehydrated device was found.
*/
public async rehydrateDeviceIfAvailable(): Promise<boolean> {
const key = await this.getKey(false);
const key = (await this.getCachedKey()) || (await this.getKey(false));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is getCachedKey called, when getKey already calls getCachedKey and returns its value if it's non-empty?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Device Dehydration | js-sdk: store dehydration key
2 participants