{"action":"created","issue":{"url":"https://api.github.com/repos/rohe/pyjwkest/issues/28","labels_url":"https://api.github.com/repos/rohe/pyjwkest/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/rohe/pyjwkest/issues/28/comments","events_url":"https://api.github.com/repos/rohe/pyjwkest/issues/28/events","html_url":"https://github.com/rohe/pyjwkest/issues/28","id":96427261,"number":28,"title":"Cannot encrypt JWE with RSA encryption keys that have a kid (keyId)","user":{"login":"arjunsharma","id":1245477,"avatar_url":"https://avatars.githubusercontent.com/u/1245477?v=3","gravatar_id":"","url":"https://api.github.com/users/arjunsharma","html_url":"https://github.com/arjunsharma","followers_url":"https://api.github.com/users/arjunsharma/followers","following_url":"https://api.github.com/users/arjunsharma/following{/other_user}","gists_url":"https://api.github.com/users/arjunsharma/gists{/gist_id}","starred_url":"https://api.github.com/users/arjunsharma/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arjunsharma/subscriptions","organizations_url":"https://api.github.com/users/arjunsharma/orgs","repos_url":"https://api.github.com/users/arjunsharma/repos","events_url":"https://api.github.com/users/arjunsharma/events{/privacy}","received_events_url":"https://api.github.com/users/arjunsharma/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-07-21T22:08:06Z","updated_at":"2015-07-23T06:19:14Z","closed_at":null,"body":"When I follow the example code for creating a JWE, it does not work when I add a \"kid\" to the encryption key.\r\n\r\nHere's what happens when I follow the example as written:\r\n\r\n```\r\n>>> encryption_keys = [RSAKey(use=\"enc\", key=RSA.generate(2048))]\r\n>>> jwe = JWE(\"some content\", alg=\"RSA-OAEP\", enc=\"A256CBC-HS512\")\r\n>>> jwe.encrypt(keys=encryption_keys)\r\n'eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZDQkMtSFM1MTIifQ.LnOxoMXW_W96Kg51ccpoMDTaHzL1Owky4JCo1zNzZSPZrKWSbil_4DEdOrGPE9Tv3TMNunfJnN0pcB5fu8zXCvoVVUHwshrgIA9mOlHkfkb-4Xq4jOFfemMTpuW-uJhL2wzXa2FvRv96ZpRTEZaC0iYcKJya9aJ0WZOm3hibj1xRJd-ORLEYEjNJco8o5EqGZj4mcT8OaODLvOuqEuq3Bc01S8OORZ5MjUWvjVkc0co5ZmnPyKXvsMhdaT60e2xAzcoQJblhuRJY0j85zqz9IIkufAVFdVieExK-zZRasZ9xvVleuJpXCYCuPzxGL_z4HHz-7go2nlBB4HrnL7CoDA.eEOu1PwmmsQFvbwK67yBEA.SWecjp-pSsgY3-hvtezFGA.n5CtpyZ-GKBCxcL0uSpUlKlPdYpNBvrXEBEk7OX628Q'\r\n```\r\n\r\nHere's what happens when I add a \"kid\" to the encryption key:\r\n\r\n```\r\n>>> encryption_keys = [RSAKey(use=\"enc\", key=RSA.generate(2048), kid=\"some-key-id\")]\r\n>>> jwe = JWE(\"some content\", alg=\"RSA-OAEP\", enc=\"A256CBC-HS512\")\r\n>>> jwe.encrypt(keys=encryption_keys, kid=\"some-key-id\")\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/Library/Python/2.7/site-packages/pyjwkest-1.0.1-py2.7.egg/jwkest/jwe.py\", line 655, in encrypt\r\n    raise NoSuitableEncryptionKey()\r\njwkest.jwe.NoSuitableEncryptionKey\r\n```\r\n\r\nIt does seem possible to do this with symmetric encryption keys:\r\n\r\n```\r\n>>> symkey = {\"kty\":\"oct\",\"alg\":\"A128KW\",\"k\":\"GawgguFyGrWKav7AX4VKUg\",\"kid\":\"some-key-id\"}\r\n>>> k = KEYS()\r\n>>> k.load_dict({\"keys\":[symkey]})\r\n>>> jwe = JWE(\"some content\", alg=\"A128KW\", enc=\"A256CBC-HS512\")\r\n>>> jwe.encrypt(keys=k, kid=\"some-key-id\")\r\n'eyJhbGciOiJBMTI4S1ciLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwia2lkIjoic29tZS1rZXktaWQifQ.OIQzQZaIlR7vH6ZsZalefqk5fTh7j4wz4ypRj0dYTCiOVR6U7xwAdJGssKiEYntme6KyxBP6RB3CKJft3tqv0nLNMuP2WUfz.go8CePZYfQhRgVfbnBXKOw.wbPTCMZWRE14p1P1vS9fYQ.k3AsKWJ6pnrgFLFZAfL1pOLL7yPU53sMfZAFZPVAkqg'\r\n```"},"comment":{"url":"https://api.github.com/repos/rohe/pyjwkest/issues/comments/123990668","html_url":"https://github.com/rohe/pyjwkest/issues/28#issuecomment-123990668","issue_url":"https://api.github.com/repos/rohe/pyjwkest/issues/28","id":123990668,"user":{"login":"rohe","id":99900,"avatar_url":"https://avatars.githubusercontent.com/u/99900?v=3","gravatar_id":"","url":"https://api.github.com/users/rohe","html_url":"https://github.com/rohe","followers_url":"https://api.github.com/users/rohe/followers","following_url":"https://api.github.com/users/rohe/following{/other_user}","gists_url":"https://api.github.com/users/rohe/gists{/gist_id}","starred_url":"https://api.github.com/users/rohe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rohe/subscriptions","organizations_url":"https://api.github.com/users/rohe/orgs","repos_url":"https://api.github.com/users/rohe/repos","events_url":"https://api.github.com/users/rohe/events{/privacy}","received_events_url":"https://api.github.com/users/rohe/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T06:19:14Z","updated_at":"2015-07-23T06:19:14Z","body":"Fixed !\nJust pushed a patch.\n\n> 22 jul 2015 kl. 23:37 skrev Arjun Sharma <notifications@github.com>:\n> \n> keyset = {\"keys\": [\n> {\n> \"alg\": \"RS512\",\n> \"kty\":\"RSA\",\n> \"d\":\"ckLyXxkbjC4szg8q8G0ERBZV-9CszeOxpRtx1KM9BLl0Do3li_Km2vvFvfXJ7MxQpiZ18pBoCcyYQEU262ym8wI22JWMPrZe24HCNxLxqzr_JEuBhpKFxQF6EFTSvJEJD1FkoTuCTvN0zD7YHGaJQG6JzVEuFUY3ewxjH0FYNa_ppTnPP3LC-T9u_GX9Yqyuw1KOYoHSzhWSWQOeAgs4dH9-iAxN1wdZ6eH1jFWAs43svk_rhwdgyJMlihFtV9MAInBlfi_Zu8wRVhVl5urkJrLf0tGFnMbnzb6dYSlUXxEYClpY12W7kXW9aePDqkCwI4oZyxmOmgq4hunKGR1dAQ\",\n> \"e\":\"AQAB\",\n> \"use\":\"sig\",\n> \"kid\": \"af22448d-4c7b-464d-b63a-f5bd90f6d7d1\",\n> \"n\":\"o9g8DpUwBW6B1qmcm-TfEh4rNX7n1t38jdo4Gkl_cI3q--7n0Blg0kN88LHZvyZjUB2NhBdFYNxMP8ucy0dOXvWGWzaPmGnq3DM__lN8P4WjD1cCTAVEYKawNBAmGKqrFj1SgpPNsSqiqK-ALM1w6mZ-QGimjOgwCyJy3l9lzZh5D8tKnS2t1pZgE0X5P7lZQWHYpHPqp4jKhETzrCpPGfv0Rl6nmmjp7NlRYBkWKf_HEKE333J6M039m2FbKgxrBg3zmYYpmHuMzVgxxb8LSiv5aqyeyJjxM-YDUAgNQBfKNhONqXyu9DqtSprNkw6sqmuxK0QUVrNYl3b03PgS5Q\"\n> }\n> ]\n> }\n> >>> from jwkest.jwk import KEYS\n> >>> keys = KEYS()\n> >>> keys.load_dict(keyset)\n> >>> jws = JWS(\"payload\", alg=\"RS512\")\n> >>> jws.sign_compact(keys=keys)\n> \n\n- Roland\n\n”Capitalism is the extraordinary belief that the nastiest of men for the nastiest of motives will somehow work for the benefit of all\" - John Maynard Keynes.\n\n"}}