0

我可以按照https://bitbucket.org/b_c/jose4j/wiki/JWT%20Examples创建 JWE 。 问题:无法使用 json web 密钥创建 JWE(如下所述的 EC 类型)。

要求:创建并验证以下类型的 JWE

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

我想避免EcJwkGenerator.generateJwk(EllipticCurves.P256);

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

我可以从 json 网络密钥创建 EllipticCurveJsonWebKey 吗?

这是 json 网络密钥:

{
  "kty":"EC",
  "d":"648B3L4cIM8oMDPshuo3jeV5nd8XjMp3bVDjMQgXqhE",
  "use":"enc",
  "crv":"P-256",
  "x":"w_UdBacxbKLLMbdvFaHWRK-O-GdnaBkRPtPaCQWcV44",
  "y":"tHYH0m2uHIFNotcTJxwDLyykUtVHHd8XSXlFwyxJXNQ"
}
4

1 回答 1

0

https://bitbucket.org/b_c/jose4j/wiki/JWS%20Examples#markdown-header-using-the-rfc-7797-jws-unencoded-payload-option中的第一件事有这个例子:

    // 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\"" +
            "}"); 

我确实希望您发布的 JWK 只是一个示例。它有私钥,d也就是参数,应该保密。

于 2021-03-19T16:17:50.813 回答