Make raw p256 private key import work correctly #4
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.
Finally! I think p256 raw private key import works correctly. After a false start (nodejs/node#50174) I realized I had to bite the bullet and implement p256 derivation. Luckily it's something I've implemented in raw JS before, for Bitcoin! https://github.com/ArnaudBrousseau/arnaudbrousseau.com/blob/master/static/labs/keys.deconstructed/keys.deconstructed.js
And because this derivation isn't security sensitive (the only "bad" thing that can happen is the actual call to
crypto.subtle.importKey
will fail), I feel confident about this approach (as opposed to importing a library, which means we lose the self-contained nature of this page)Note that we already test this with the unit tests
imports recovery credentials correctly
. They used to pass because nodeJS is able to import bare pkcs8 private keys. Now they pass because the key derivation logic is sound/working!