I've updated the Nimbus library to use the different hash, and the new token works under BouncyCastle in Java7. I did hit the bug mentioned [0] when running with the Sun provider. Also important, the old token doesn't work anymore.
-- Justin On May 7, 2014, at 9:29 AM, Brian Campbell <[email protected]<mailto:[email protected]>> wrote: Thanks again Matt for checking my homework. As Antonio surmised, I used the "RSA/ECB/OAEPWithSHA-256AndMGF1Padding" transformation to get a cipher instance but then also initialized it with the OAEPParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, PSource.PSpecified.DEFAULT), which is what gets MGF to use SHA2 as well. I did run into the issue that Antonio pointed out [0]. Thanks BTW, I didn't really see the applicability of it when you sent it yesterday but having the reference was very helpful later. FWIW, I didn't use Bouncy Castle but rather the default Sun/Oracle provider with Java 8, which seems to have fixed that issue between 7 & 8. I'm not sure how to articulate all that in the JWA's Key Management Algorithm Identifier Cross-Reference [1] as "RSA/ECB/OAEPWithSHA-256AndMGF1Padding" is correct but not sufficient. And as Matt pointed out, the XMLENC cross-ref probably isn't quite right either. I also agree with Matt that my first attempt at this as well as the other Java based implementations yesterday were not properly implementing the spec, which is pretty clear about "RSAES OAEP using SHA-256 and MGF1 with SHA-256" [2]. And that MGF1 with SHA-256 vs SHA-1 for RSAES OAEP using SHA-256 is a separate debate but, as JWA is written now, it's MGF1 with SHA-256. Given that this RSA-OAEP-256 was added at the request of the AD, it's likely to be a short debate. [0] https://bugs.openjdk.java.net/browse/JDK-7038158 [1] http://tools.ietf.org/id/draft-ietf-jose-json-web-algorithms-26.html#rfc.appendix.A.1 [2] tools.ietf.org/id/draft-ietf-jose-json-web-algorithms-26.html#KeyEncryptionRSAOAEP<http://tools.ietf.org/id/draft-ietf-jose-json-web-algorithms-26.html#KeyEncryptionRSAOAEP> On Wed, May 7, 2014 at 5:35 AM, Matt Miller <[email protected]<mailto:[email protected]>> wrote: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 On 5/7/14, 2:21 AM, [email protected]<mailto:[email protected]> wrote: > I think that the java implementations implemented the spec and > everything is ok from that POV. > > These implementations are not broken. The JOSE Java implementations did not implement the spec, though. draft-ietf-jose-json-web-algorithms § 4.3 clearly states the hash and mask generation functions are to use the same algorithm -- SHA-1 (and MGF1 with SHA-1) in the case of "RSA-OAEP", and SHA-256 (and MGF1 with SHA-256) in the case of "RSA-OAEP-256". > > > > One could argue that when we replace SHA-1 by SHA-256 in one place > then we might consider to replace it in the padding too. That is exactly what draft-ietf-jose-json-web-algorithms specified. > > My feeling is that using sha-256 for the padding does not give us > more security. YMMW > That is a separate debate, I think. The prevailing opinion (at least around the IETF) is "don't mix the algorithms". - -- - - m&m Matt Miller < [email protected]<mailto:[email protected]> > Cisco Systems, Inc. > > > > > *From:*jose [mailto:[email protected]<mailto:[email protected]>] *On > Behalf Of *Brian > Campbell *Sent:* Wednesday, May 07, 2014 6:54 AM *To:* Matt Miller > *Cc:* Antonio Sanso; [email protected]<mailto:[email protected]> *Subject:* Re: [jose] > RSA-OAEP-256 Example > > > > Thanks Matt. > > That is why I was looking for someone to verify using a different > platform. Though I was hoping it'd just work. > > Matt, can you try decrypting this one by chance? Using the same > key. I was more explicit with the parameters and, I think, MGF1 > should be using SHA-256 now too. > > > eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMTI4Q0JDLUhTMjU2In0.fL5IL5cMCjjU9G9_ZjsD2XO0HIwTOwbVwulcZVw31_rx2qTcHzbYhIvrvbcVLTfJzn8xbQ3UEL442ZgZ1PcFYKENYePXiEyvYxPN8dmvj_OfLSJDEqR6kvwOb6nghGtxfzdB_VRvFt2eehbCA3gWpiOYHHvSTFdBPGx2KZHQisLz3oZR8EWiZ1woEpHy8a7FoQ2zzuDlZEJQOUrh09b_EJxmcE2jL6wmEtgabyxy3VgWg3GqSPUISlJZV9HThuVJezzktJdpntRDnAPUqjc8IwByGpMleIQcPuBUseRRPr_OsroOJ6eTl5DuFCmBOKb-eNNw5v-GEcVYr1w7X9oXoA.0frdIwx8P8UAzh1s9_PgOA.RAzILH0xfs0yxzML1CzzGExCfE2_wzWKs0FVuXfM8R5H68yTqTbqIqRCp2feAH5GSvluzmztk2_CkGNSjAyoaw.4nMUXOgmgWvM-08tIZ-h5w > > > > > On Tue, May 6, 2014 at 8:39 PM, Matt Miller > <[email protected]<mailto:[email protected]> > <mailto:[email protected]<mailto:[email protected]>>> wrote: > > Short answer: You are all equally broken -- except from a certain > point of view d-: > > Long answer: The code I have is based on OpenSSL, which is > hard-coded to use SHA1 for the hash and mask generation (boo!), > which means one has to implement OAEP-SHA256 from scratch > (hiss!!). > > When I implemented it per RFC 3447 and > draft-ietf-jose-json-web-algorithms-26#section-4.3, I could not > decrypt the provided results. When I hard-coded MGF1 to use > "SHA1", I could decrypt provided results. A search through > BouncyCastle's code shows that > "RSA/ECB/OAEPWithSHA-256AndMGF1Padding" uses a Hash function of > SHA-256 generate the lHash but its MGF1 uses a "SHA-1". Further > evidence is shown with how [FORGE] can be made to work with Java > (search their homepage for "Compatible with Java's > RSA/ECB/OAEPWithSHA-256AndMGF1Padding"). > > Reconciling all of this with > draft-ietf-jose-json-web-algorithms#appendix-A.2 does not look to > be very straight-forward. It appears that the JCA identifier is > meant to be "MGF1 with SHA1"; that ought to be explicitly noted. > The XMLENC reference is arguably incomplete, since > "http://www.w3.org/2009/xmlenc11#rsa-oaep" defaults to > "http://www.w3.org/2009/xmlenc11#mgf1sha1" (MGF1 with SHA1); this > can probably be addressed by explicitly stating the mask > generation function is "http://www.w3.org/2009/xmlenc11#mgf1sha256" > (MGF1 with SHA-256). > > > > > -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.22 (Darwin) Comment: GPGTools - https://gpgtools.org<https://gpgtools.org/> Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCgAGBQJTaih6AAoJEDWi+S0W7cO1dqMIAIgB0qPxKOkFRQ1w16tiAW0P KZ3bFZ0LX5RnaiL2t0bAfMo4ivSdawRmabLmNVuOrTbKZ5cPpdI9jSYqzAs/3SS6 oLDnFFB6PHCz8nBWRvEtwxGII3t6e3LEoqW7ndcvO/1Le77uy+zAB6Xs0xh1mxWY NEHpVQsKs2Ytjk9ZxcqdUjivZhU17PPmam2hu2xYcZLxI8eHav8uzQJWCYTzg4my uVy8JTbQ6odtx7hiJSpTiY6cYOaa2TcRbroQNKmOsHIQ3em86Esme4cOlPiJ6vds VbBHZXh3NqSjWcmAc5ysTmP7j9ATIn1+ZWlXAZEXAi3mBKme+VGGraO079bhR7Y= =zfUl -----END PGP SIGNATURE----- -- [Ping Identity logo]<https://www.pingidentity.com/> Brian Campbell Portfolio Architect @ [email protected]<mailto:[email protected]> [phone] +1 720.317.2061 Connect with us… [twitter logo]<https://twitter.com/pingidentity> [youtube logo] <https://www.youtube.com/user/PingIdentityTV> [LinkedIn logo] <https://www.linkedin.com/company/21870> [Facebook logo] <https://www.facebook.com/pingidentitypage> [Google+ logo] <https://plus.google.com/u/0/114266977739397708540> [slideshare logo] <http://www.slideshare.net/PingIdentity> [flipboard logo] <http://flip.it/vjBF7> [rss feed icon] <https://www.pingidentity.com/blogs/> [Register for Cloud Identity Summit 2014 | Modern Identity Revolution | 19–23 July, 2014 | Monterey, CA]<https://www.cloudidentitysummit.com/> _______________________________________________ jose mailing list [email protected]<mailto:[email protected]> https://www.ietf.org/mailman/listinfo/jose
_______________________________________________ jose mailing list [email protected] https://www.ietf.org/mailman/listinfo/jose
