0

I am able to create JWE as per https://bitbucket.org/b_c/jose4j/wiki/JWT%20Examples. Problem: Unable to create JWE (EC type as mentioned below) using json web key.

Requirement: Create & Verify below type of JWE

  "typ": "JWT",
  "alg": "ECDH-ES+A256KW",
  "enc": "A128CBC-HS256",

I want to avoid EcJwkGenerator.generateJwk(EllipticCurves.P256);

EllipticCurveJsonWebKey senderJwk = EcJwkGenerator.generateJwk(EllipticCurves.P256);
    

Can I create EllipticCurveJsonWebKey from the json web key?

Here is the json web key:

{
  "kty":"EC",
  "d":"648B3L4cIM8oMDPshuo3jeV5nd8XjMp3bVDjMQgXqhE",
  "use":"enc",
  "crv":"P-256",
  "x":"w_UdBacxbKLLMbdvFaHWRK-O-GdnaBkRPtPaCQWcV44",
  "y":"tHYH0m2uHIFNotcTJxwDLyykUtVHHd8XSXlFwyxJXNQ"
}
jps
  • 20,041
  • 15
  • 75
  • 79

1 Answers1

0

The first thing in https://bitbucket.org/b_c/jose4j/wiki/JWS%20Examples#markdown-header-using-the-rfc-7797-jws-unencoded-payload-option has this example:

    // The public/private key pair for this example as a JWK
    PublicJsonWebKey jwk = PublicJsonWebKey.Factory.newPublicJwk("{" +
            "  \"kty\": \"EC\"," +
            "  \"d\": \"Tk7qzHNnSBMioAU7NwZ9JugFWmWbUCyzeBRjVcTp_so\"," +
            "  \"use\": \"sig\"," +
            "  \"crv\": \"P-256\"," +
            "  \"kid\": \"example\"," +
            "  \"x\": \"qqeGjWmYZU5M5bBrRw1zqZcbPunoFVxsfaa9JdA0R5I\"," +
            "  \"y\": \"wnoj0YjheNP80XYh1SEvz1-wnKByEoHvb6KrDcjMuWc\"" +
            "}"); 

I do hope that the JWK you've posted is just an example. It has the private key, the d parameter, which is supposed to be kept private.

Brian Campbell
  • 2,293
  • 12
  • 13