-
Notifications
You must be signed in to change notification settings - Fork 267
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
feat(crypto): Support storing the dehydrated device pickle key #4383
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4383 +/- ##
==========================================
+ Coverage 85.27% 85.30% +0.02%
==========================================
Files 282 282
Lines 31207 31257 +50
==========================================
+ Hits 26613 26663 +50
Misses 4594 4594 ☔ View full report in Codecov by Sentry. |
821df3d
to
3162d33
Compare
@@ -846,6 +852,11 @@ impl CryptoStore for SqliteCryptoStore { | |||
txn.set_kv("backup_version_v1", &serialized_backup_version)?; | |||
} | |||
|
|||
if let Some(pickle_key) = &changes.dehydrated_device_pickle_key { |
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.
Same as for the indexedDB implementation, docs and implementation don't match.
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.
Looks good, left a question and some nits about moving the public methods around.
async fn delete_dehydrated_device_pickle_key(&self) -> Result<()> { | ||
let mut lock = self.dehydrated_device_pickle_key.write().await; | ||
*lock = None; | ||
Ok(()) | ||
} |
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.
Maybe I'm missing something, but is this method used anywhere? It's part of the trait, but It's not exposed to users nor do we internally delete the key anywhere.
Would it make sense to delete it automagically when we create a new dehydrated device?
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.
Exposed now. Should be used by apps.
It could make sense if we changed a bit the API, currently create does not need the pickle key, it's upload_keys that use it. Not sure how it would work. Need to talk a bit with @uhoreg to see if can have a better integrated usage of pickle key handling
key.copy_from_slice(pickle_key); | ||
|
||
// safe to unwrap because we checked the size | ||
let raw_bytes: [u8; 32] = pickle_key.try_into().unwrap(); |
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.
I would leave the copy from slice, try_into()
moves self
and moves are copies in Rust. Now here it's fine because you move a reference so we only copy the reference instead of the whole byte array.
But we always handle secret key material using copy_from_slice()
and there it's obvious where the copy is made. The panic/unwrap is then also implicit and it's understood that you need a size check before.
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.
604e379
to
2b39476
Compare
Fixes #4186
No need for migration, the pickle key is stored in the generic Key/Value store.
Signed-off-by: