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

Cannot export keys with p256 plugin #108

Open
kshinn opened this issue Mar 4, 2024 · 1 comment
Open

Cannot export keys with p256 plugin #108

kshinn opened this issue Mar 4, 2024 · 1 comment

Comments

@kshinn
Copy link
Contributor

kshinn commented Mar 4, 2024

Context

I'm trying to use the EcdsaKeyPair as a utility to generate a stable keypair. For testing purposes I'm:

  1. Creating a keypair with exportable = true
  2. Exporting that keypair
  3. Loading the private key so I have a stable key to reuse across tests / experiments

This works fine using the EdKeypair, but fails with "key is not extractable" when using the p256 plugin.

I believe the problem is that, when creating a new key, the static method does not allow you to specify exportable and hardcodes the extraction parameter to "false" when creating the key.

I have a PR that addresses this issue that I will reference here.

kshinn added a commit to kshinn/ts-ucan that referenced this issue Mar 4, 2024
@kshinn
Copy link
Contributor Author

kshinn commented Mar 4, 2024

On further inspection it could be that I'm misunderstanding the use of the methods on this class. With the provided fix, I can successfully export the key, however it exports it in pkcs8 format. There doesn't seem to be a symmetrical way to import this key material. The import function uses the jwk format instead of a raw format. In order to make this change useful, we would need to also add an importFromRaw type of method to this class. This may start to diverge from the original intent of these classes. Happy to add if it makes sense.

matheus23 pushed a commit that referenced this issue Mar 15, 2024
Addresses issue #108

---

* Add an `exportable` option to EcdsaKeyPair
Addresses issue #108

* Implement and test import / export for ECDSA Keypair

* Import and Export for RSA keys

* Import / Export for EdKeypair

* [WIP] Remove unit8array as a dependency

* [bug] remove unused dependency

* [fix] Normalize back to uintarrays

[Fix] Normalize on uint8arrays

* [feat] Normalize `export` to use JWK types

* [fix] added notes about ed25519 export

* [fix] Revised comment about export to include other parameters

* [fix] Generify ExportableKey type to allow for PrivateKeyJwk return
types
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

No branches or pull requests

1 participant