bin-y / standard-ecies

Standard ECIES implemention for NodeJS based on crypto.ECDH with no other dependencies.
Creative Commons Zero v1.0 Universal
8 stars 3 forks source link

How to get to JWE #4

Closed OR13 closed 4 years ago

OR13 commented 4 years ago

This package is awesome!

I'm interested in building JWE interoperability between a module that takes this package as a dependency and https://github.com/panva/jose

Mostly to better understand how to get JWE from lower level cryptographic primitives... wondering if you are aware of any existing work in this area?

If you are not, feel free to state so and close this issue as off-topic.

bin-y commented 4 years ago

I didn't know JWE before, but I read some documents after read your question and here is what I got.

Unfortunately, according to rfc7516 4.1.1, rfc7515 4.1.1, and rfc7518 3.1. ECIES is not supported by JWE/JWA by default, you need to build your own implementation to add that algorithm if the jose library didn't support registering algorithm as a custom JWA.

But if you are not thinking about make this library registered as a JWA to your JWE library, here are simple solutions that seem to work.

You can create a crypto.ECDH object from aforementioned jose library and use it to this library. But I'm not sure what is improvedDH of that library.

If you want to use improvedDH of that library. Since my library only relies on generateKeys/getPublickey/setPrivateKey of crypto.ECDH module and aforementioned jose library have implemented ECDH and key importing/exporting. You can create a warper class between crypto.ECDH and jose's ECDH, and I can add a option field to support custom ecdh implementation to this library.

OR13 commented 4 years ago

@bin-y thanks you can close this issue whenever you like.

bin-y commented 4 years ago

Okay, you can create a new issue/pr if you need this library to support custom ECDH implementation.