JWSAlgorithm should have knowledge of its Digital Signature Algorithm
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)
-
-
Added new ECKey.Curve.forJWSAlgorithm method (commit 6dd9ace47d537339e42513ed8441ae235609bd72).
-
- changed status to resolved
@b33bl3br0x Released update as v4.28. Should be on Maven Central within couple of hours or so. Thanks for contributing with this!
-
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!
- Log in to comment
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).