JWSAlgorithm should have knowledge of its Digital Signature Algorithm

Issue #197 resolved
Jan Brennenstuhl created an issue

As the "alg" Param Value (and based on that also the JWSAlgorithm) strictly correlate with a specific Digital Signature Algorithm, it should be possible to get this info directly from a JWSAlgorithm object or through a parse method on the Curve.

I imagine something like that...

ECKey.Curve curve = JWSAlgorithm.ES384.getCurve();
// or
ECKey.Curve curve = ECKey.Curve.parse(JWSAlgorithm.ES384)

... that would allow to easily build ECKeys from JWSAlgorithm and KeyPair, without having to implement that mapping oneself.

Hope, that makes sense to you.

Comments (4)

  1. Vladimir Dzhuvinov

    Hi Jan,

    The curve is a property of EC JWS algorithms. RSA and HMAC JWS algorithms don't make use of curves. Subclassing the JWSAlgorithm class into EC specific algs is not an option here. Adding a getCurve method that will return null for RSA and HMAC algs is bad OO.

    I think adding a static ECKey.Curve.forJWSAlgorithm is the best option here. But bear in mind that it will only work for the three hardwired EC algs and curves picked by the JOSE WG (there are a lot more EC curves in practice).

  2. Connect2id OSS

    @b33bl3br0x Released update as v4.28. Should be on Maven Central within couple of hours or so. Thanks for contributing with this!

  3. Jan Brennenstuhl reporter

    @vdzhuvinov thanks, I am happy with the feature and especially with your speed! if you wouldn't been so fast, I'd sent a pull request later this week ;D

    looking forward to get the release, thumbs up!

  4. Log in to comment