-
Notifications
You must be signed in to change notification settings - Fork 561
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
fix: properly decrypt legacy state blobs #2472
Conversation
@@ -454,6 +454,13 @@ export const DEFAULT_ENCRYPTION_KEY_DERIVATION_OPTIONS = { | |||
}, | |||
}; | |||
|
|||
export const LEGACY_ENCRYPTION_KEY_DERIVATION_OPTIONS = { |
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 move this to the Snap controller file (or a constants file) and use it as the fallback, to remove some duplication?
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.
Done!
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2472 +/- ##
=======================================
Coverage 94.34% 94.34%
=======================================
Files 438 438
Lines 9052 9053 +1
Branches 1391 1392 +1
=======================================
+ Hits 8540 8541 +1
Misses 512 512 ☔ View full report in Codecov by Sentry. |
Fixes a problem where encrypted state blobs produced before
keyMetadata
was added would fail to decrypt.The encryptor would attempt to use the latest key derivation parameters when no
keyMetadata
was passed in, causing a failure to decrypt: https://github.com/MetaMask/metamask-extension/blob/ed5ec2d28f7e118803c6fdc74abe90db4e00f480/app/scripts/lib/encryptor-factory.ts#L78-L82This PR simply falls back to the legacy key derivation parameters whenever
keyMetadata
isn't present strictly for decryption purposes. The default key derivation parameters are still in use for all encryption.