EdDSA using PEM keys generated by OpenSSL Ed25519 #862
-
I needed interoperable private/public keypair to use with EdDSA and different languages (for JWT).
This works nice with python implementation PyJWT Then I loaded this library and realized I should use Sodium like this
This works fine with PHP. How can I convert PEM keys to be compatible with binary output of Sodium? I would appreciate you or anyones help on this! Thank you p.s. I am thinking switching to ECDSA if this will help me find more support withing JWT libraries for different languages. |
Beta Was this translation helpful? Give feedback.
Replies: 10 comments
-
@igor-davidov I'm honestly clueless on how to make OpenSSL and libsodium to understand each other. I've found jedisct1/libsodium#963 that mentions a few interesting things. |
Beta Was this translation helpful? Give feedback.
-
Thank you - will take a look! |
Beta Was this translation helpful? Give feedback.
-
The easiest way to go would be to convert to the |
Beta Was this translation helpful? Give feedback.
-
I figured out that OpenSSL private key has just an ASN.1 header on top - which can be removed to get raw byte data foolishly thinking I could use that one with this library. What I figured out is that different systems have different implementations for producing ed25519 and they can be 32bit (openssl) and 64bit (sodium). Systems using different implementations cannot use keys between themselves. Regretfully I have to choose another signing mechanism... |
Beta Was this translation helpful? Give feedback.
-
I am satisfied with using ECDSA. |
Beta Was this translation helpful? Give feedback.
-
EdDSA keys are better 😉 @jedisct1 suggestion is easy:
It's still unreleased |
Beta Was this translation helpful? Give feedback.
-
Thanks @Slamdunk. From what I understand is that signing using Sodium generated keys won't correspond to signing using PEMs generated by OpenSSL. I was looking for platform that would allow me to manage signing process using one key pair. |
Beta Was this translation helpful? Give feedback.
-
That wouldn't make any sense, OpenSSL and Sodium operations are the same:
|
Beta Was this translation helpful? Give feedback.
-
I understand that Sodium vs OpenSSL are two Ed25519 implementations with NaCl implementation storing private scalar as part of private key - I understand they are same RFC implementation. I will try and test it. Thank you again - for me Sodium documentation wasn't initially very helpful. |
Beta Was this translation helpful? Give feedback.
-
This works with Sodium and OpenSSL key now. Thank you @Slamdunk !! Generate keys
Note: You can also cut key using PHP on the fly. Sign JWT / Sodium / Lcobucci-JWT
Decode using PyJWT / OpenSSL PEM / Python
Validate JWT / Sodium / Lcobucci-JWT
|
Beta Was this translation helpful? Give feedback.
EdDSA keys are better 😉
@jedisct1 suggestion is easy: