You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Misleading function name DecodingKey::from_ed_der. #362
It seems like DecodingKey::from_ed_der function actually expects raw 32 bytes public key, which ring's Ed25519KeyPair::public_key returns.
Also running openssl asn1parse -inform der -in file-with-pubkey shows again that these 32 bytes are not DER encoded. I've also additionally checked it using ed25519-dalek crate.
So essentially it seems DecodingKey::from_ed_der name is just misleading and DecodingKey doesn't yet support DER encoded ed25519 public keys. Maybe it would be a good idea to add a new method like DecodingKey::from_ed behaving exactly the same as existing DecodingKey::from_ed_der, but specified in the descrition that it expects raw 32 bytes public key.
What to do with existing misleading name of DecodingKey::from_ed_der I'm not sure, changing implementation would be a (potentially) quite annoying breaking change.
changed the title [-]Misleading function name [`DecodingKey::from_ed_der`](https://docs.rs/jsonwebtoken/latest/jsonwebtoken/struct.DecodingKey.html#method.from_ed_der).[/-][+]Misleading function name `DecodingKey::from_ed_der`.[/+]on Jan 13, 2024
It would be a breaking change but it doesn't do what it says it does it should be more of a bug fix? How hard is it to to actually have a DecodingKey::from_ed_der?
Maybe it can be called a bugfix, but I think a lot of people already depend on the current behaviour and their code would crash at runtime if implementation changed, no compiler warning, so maybe it would be a good idea to somehow check in the body of DecodingKey::from_ed_der that input is actually just a raw 32 bytes, not a DER, and panic with a helpful message. Maybe also even bump a major version or include a fix for the current problem when the next major version bump happens. Or maybe there's some other way I didn't think about.
Regarding how hard it is to implement a DER pubkey (I think we actually need SPKI?) decoding I don't know, I don't think this crate depends on anything that can do that (ring can't afaik). I've used some dependency of ed25519-dalek for it.
I have just spent hours checking why my openssl DER key was not being accepted until I found this 😢
If the function is not expecting proper der as created with openssl -outform der please rename it
Activity
[-]Misleading function name [`DecodingKey::from_ed_der`](https://docs.rs/jsonwebtoken/latest/jsonwebtoken/struct.DecodingKey.html#method.from_ed_der).[/-][+]Misleading function name `DecodingKey::from_ed_der`.[/+]Houndie commentedon Mar 24, 2024
Thank you for this, I 100% agree, and you just saved me 30 minutes of debugging.
Keats commentedon Mar 25, 2024
It would be a breaking change but it doesn't do what it says it does it should be more of a bug fix? How hard is it to to actually have a
DecodingKey::from_ed_der?tokarevart commentedon Mar 25, 2024
Maybe it can be called a bugfix, but I think a lot of people already depend on the current behaviour and their code would crash at runtime if implementation changed, no compiler warning, so maybe it would be a good idea to somehow check in the body of
DecodingKey::from_ed_derthat input is actually just a raw 32 bytes, not a DER, and panic with a helpful message. Maybe also even bump a major version or include a fix for the current problem when the next major version bump happens. Or maybe there's some other way I didn't think about.Regarding how hard it is to implement a DER pubkey (I think we actually need SPKI?) decoding I don't know, I don't think this crate depends on anything that can do that (
ringcan't afaik). I've used some dependency ofed25519-dalekfor it.tokarevart commentedon Mar 25, 2024
Oh it seems #318 adds
ed25519-dalekas a dependency, so when/if it's merged adding DER/SPKI decoding wouldn't be much of a problem I think.Keats commentedon Apr 1, 2024
Yes #318 is an interesting one. Can you try it if you have time?
tokarevart commentedon Apr 2, 2024
You mean implement a proper
DecodingKey::from_ed_deron top of #318 branch? I'll try it this week/weekend.Keats commentedon Apr 2, 2024
I meant the branch in general.
tokarevart commentedon Apr 2, 2024
Oh okay, I'll take a look later then.
ferdonline commentedon Aug 2, 2024
I have just spent hours checking why my openssl DER key was not being accepted until I found this 😢
If the function is not expecting proper
deras created withopenssl -outform derplease rename itKeats commentedon Aug 3, 2024
I'll happily accept a PR fixing it