Transmit EPK and use as public key during decrypt - #2120
Transmit EPK and use as public key during decrypt#2120BrentSchmaltz (brentschmaltz) merged 3 commits into
Conversation
|
@microsoft-github-policy-service agree company="Yubico" |
|
Greg Domzalski (@GregDomzalski) we might as well drop #2119 and just take this PR. |
|
Yup. Fair enough. I'll close that PR. |
dbf32c5 to
410893a
Compare
|
I've updated this PR to be based on the new 7.x code. I still need to do some regression testing on my side. But it would be really nice if we could get some traction on this PR. We're about to launch a product that takes a dependency on ECDH based key exchange / wrap algorithms working properly. I would really like to get these changes pushed upstream. Please let me know what I can do to help make that a reality 😄 |
|
Greg Domzalski (@GregDomzalski) this looks good, we will have to account for users who have used the work-around. |
|
BrentSchmaltz (@brentschmaltz) Thanks for the feedback. That seems like a reasonable approach. What would you like the default behavior to be? Based on the documentation and assuming an opt-in to the new behavior, a possible switch identifier could be: I'm not quite sure how to describe the change in behavior, so I'm happy to take other name suggestions 😄 |
|
Alrighty. Let me know if that aligns with what you were thinking. The diff definitely looks a lot cleaner - basically just adds at this point. I introduced a centralized (public) class in Here's the signature and accompanying documentation: namespace Microsoft.IdentityModel.Tokens;
/// <summary>
/// Identifiers used for switching between different app compat behaviors within the Microsoft.IdentityModel libraries.
/// </summary>
/// <remarks>
/// The Microsoft.IdentityModel libraries use <see cref="System.AppContext" /> to turn on or off certain API behavioral
/// changes that might have an effect on application compatibility. This class defines the set of switches that are
/// available to modify library behavior. Application compatibility is favored as the default - so if your application
/// needs to rely on the new behavior, you will need to enable the switch manually. Setting a switch's value can be
/// done programmatically through the <see cref="System.AppContext.SetSwitch" /> method, or through other means such as
/// setting it through MSBuild, app configuration, or registry settings. These alternate methods are described in the
/// <see cref="System.AppContext.SetSwitch" /> documentation.
/// </remarks>
public static class AppCompatSwitches
{
/// <summary>
/// Uses <see cref="EncryptingCredentials.KeyExchangePublicKey"/> for the token's `kid` header parameter. When using
/// ECDH-based key wrap algorithms the public key portion of <see cref="EncryptingCredentials.Key" /> is also written
/// to the token's `epk` header parameter.
/// </summary>
/// <remarks>
/// Enabling this switch improves the library's conformance to RFC 7518 with regards to how the header values for
/// `kid` and `epk` are set in ECDH key wrap scenarios. The previous behavior erroneously used key ID of
/// <see cref="EncryptingCredentials.Key"/> as the `kid` parameter, and did not automatically set `epk` as the spec
/// defines. This switch enables the intended behavior where <see cref="EncryptingCredentials.KeyExchangePublicKey"/>
/// is used for `kid` and the public portion of <see cref="EncryptingCredentials.Key"/> is used for `epk`.
/// </remarks>
public const string UseRfcDefinitionOfEpkAndKid = "Switch.Microsoft.IdentityModel.UseRfcDefinitionOfEpkAndKid";
}Let me know if there's any additional API or doc review that needs to happen as a result of this addition. I really appreciate your time looking into this and providing feedback. Thanks! |
|
Hey BrentSchmaltz (@brentschmaltz) - just following up here. |
315cf38 to
a1983ba
Compare
|
BrentSchmaltz (@brentschmaltz) do we want to take this? |
|
jennyf19 we should take this for 8. |
|
Greg Domzalski (@GregDomzalski) there are some conflicts, are you able to fix them? |
|
Jamie A Hankins (@jamiehankins) Aaron Fortner (@AaFortner) - Can you guys take this over? |
|
Hi BrentSchmaltz (@brentschmaltz) - I won't be able to do this personally as I'm no longer with Yubico, but I did hand this off prior to my departure. I'll work with my former colleagues to make sure we get this branch updated and merged in a timely manner. Thanks for the sign-off. |
|
I don't and Aaron Fortner (@AaFortner) doesn't likely have write access to the fork. It takes less than five minutes to pull dev and rebase this branch on it. The only conflict is in a class header comment. If Greg Domzalski (@GregDomzalski) still has write access to this, then maybe he can add us. Otherwise, we'd need to get our IT people involved. |
|
Looks like I do still have access to this PR itself which means I can simply clone the fork and point the PR to that. I'll give that a try in the morning. |
|
I sync'd up with Greg Domzalski (@GregDomzalski) offline, and it sounds like he hit some access issues after all. I'll follow up with our IT to see if we can get Jamie and/or myself added. |
|
Aaron Fortner (@AaFortner) Greg Domzalski (@GregDomzalski) the PR is small enough that i could cherry pick in the commits. |
a1983ba to
daad6d9
Compare
|
BrentSchmaltz (@brentschmaltz) It wasn't big at all. Just had to get access handled. It should be up to date now. |
daad6d9 to
9219d4e
Compare
|
Jamie A Hankins (@jamiehankins) Greg Domzalski (@GregDomzalski) thanks folks, merged. |
RFC 7518 Section 4.6.1.1 states:
EPK was referred to by comments in the code, but it seems that it was never used. Since the spec clearly states that the "Header Parameter MUST be present and MUST be understood and processed", I make the argument that this PR fixes a bug (#1951) and is not a feature enhancement.
This change does the following:
TokenValidationParameters.TokenDecryptionKey)This PR also contains an extra commit that I've covered in PR #2119 . I can remove that from this change list if we decide not to proceed with that other PR.This other PR / commit has been addressed in the 7.x release line and this PR has been rebased onto that.