Add utility to convert JWKs to / from std Java keys in java.security.interfaces

Issue #25 resolved
Vladimir Dzhuvinov created an issue

Possible uses:

  • Convert between JWK sets and Java keystore keys.
  • Pass key args to crypto providers as JWKs.

The std Java key interfaces defined in java.security.interfaces:

ECKey
ECPrivateKey
ECPublicKey
RSAKey
RSAMultiPrimePrivateCrtKey
RSAPrivateCrtKey
RSAPrivateKey
RSAPublicKey

Comments (8)

  1. Justin Richer

    I think these should be handled by the JWK classes themselves. I'll add a branch that implements this.

  2. Vladimir Dzhuvinov reporter

    Good idea, and will fit solution 1 nicely (else we'll need to use full class names to prevent collision with java.security.interfaces.ECPublicKey and java.security.interfaces.RSAPublicKey).

    How about

    toECPublicKey()
    toECPrivateKey()
    toKeyPair()
    

    resp.

    toRSAPublicKey()
    toRSAPrivateKey()
    toKeyPair()
    

    ?

  3. Justin Richer

    Proposed solution pushed into branch native-keys.

    Handles RSA keys in and out, symmetric keys outbound, and has unimplemented stubs for EC keys. Does not handle RSA CRT-formatted keys yet.

  4. Vladimir Dzhuvinov reporter
    • changed status to open

    To generate the Java representations of the public + private ECKeys we'll need to lookup or hardwire the P curve constants defined in fips_186-3.pdf, page 89.

  5. Vladimir Dzhuvinov reporter

    Added CRT support to RSAKey.toRSAPrivateKey() in commit 9449eaa.

    With that the RSAKey class covers all required java.security imports + exports, JUnit tests still need to be written though :)

  6. Log in to comment