Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Key import/export as PEM (interop with go-ipfs 0.13+) #2887

Closed
Stebalien opened this issue Aug 2, 2019 · 4 comments
Closed

Key import/export as PEM (interop with go-ipfs 0.13+) #2887

Stebalien opened this issue Aug 2, 2019 · 4 comments
Labels
effort/days Estimated to take multiple days, but less than a week exp/intermediate Prior experience is likely helpful kind/enhancement A net-new feature or improvement to an existing feature kind/maintenance Work required to avoid breaking changes or harm to project's status quo P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked topic/interop Interoperability

Comments

@Stebalien
Copy link
Member

https://github.com/ipfs/interface-js-ipfs-core/blob/v0.103.0/SPEC/KEY.md#keyimport

However, libp2p uses a custom format that may or may not be convertible to PEM.

@achingbrain achingbrain transferred this issue from ipfs-inactive/interface-js-ipfs-core Mar 10, 2020
@achingbrain achingbrain added the kind/enhancement A net-new feature or improvement to an existing feature label Mar 10, 2020
@DougAnderson444
Copy link
Contributor

I'm interested in seeing this implemented for sure! We should be able to store any key type on the keychain, not just rsa-pem, right?

js-ipfs.key.import comes from keychain.importKey

keychain.importKey calls crypto.keys.import(pem, password) which only processes RSA pem at the moment.

I see crypto.keys.unmarshallPrivateKey(buf) already decodes the key type then returns the key based on type. We just need import to leverage this heavy lifting right?

What we could do is

  • rename crypto.keys.import(pem, password) to (privateKey, password)
  • crypto.keys.import(privateKey, password) determines which key type is given, based on length
  • if there is a password and it's RSA, then decryptRsaPrivateKey as before
  • perhaps add a symmetrical password cipher for the other two key types (pbkdf2 + AES?)
  • based on which key type, convert string to buf for crypto.keys.unmarshallPrivateKey
  • crypto.keys.unmarshallPrivateKey returns the appropriate key bytes, just like import did

Does that seem about right?
Anything I can do to help implement this change?

@DougAnderson444
Copy link
Contributor

Ongoing discussion about this also here libp2p/js-libp2p-crypto#145

@lidel
Copy link
Member

lidel commented Feb 11, 2022

Update:

@lidel lidel changed the title key import assumes PEM Support key import/export to cleartext PEM (interop with go-ipfs 0.13+) Feb 11, 2022
@lidel lidel changed the title Support key import/export to cleartext PEM (interop with go-ipfs 0.13+) Key import/export as PEM (interop with go-ipfs 0.13+) Feb 11, 2022
@lidel lidel added effort/days Estimated to take multiple days, but less than a week exp/intermediate Prior experience is likely helpful P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked topic/interop Interoperability kind/maintenance Work required to avoid breaking changes or harm to project's status quo labels Feb 11, 2022
@lidel lidel moved this to Todo in @lidel's IPFS wishlist Feb 11, 2022
@tinytb tinytb moved this to Backlog in IP JS (PL EngRes) v2 Oct 14, 2022
@tinytb
Copy link

tinytb commented Nov 22, 2022

backlog grooming: this will be tracked in libp2p/js-libp2p-crypto#244 going forward

@tinytb tinytb closed this as completed Nov 22, 2022
Repository owner moved this from Todo to Done in @lidel's IPFS wishlist Nov 22, 2022
Repository owner moved this from Backlog to Done in IP JS (PL EngRes) v2 Nov 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
effort/days Estimated to take multiple days, but less than a week exp/intermediate Prior experience is likely helpful kind/enhancement A net-new feature or improvement to an existing feature kind/maintenance Work required to avoid breaking changes or harm to project's status quo P2 Medium: Good to have, but can wait until someone steps up status/ready Ready to be worked topic/interop Interoperability
Projects
No open projects
Development

No branches or pull requests

5 participants