-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transmit EPK and use as public key during decrypt (#2120)
* Propagate EPK and KID as defined by RFC7518 * Guard new behavior behind an app-compat switch * Encode EPK as a JSON object and not an escaped string --------- Co-authored-by: Greg Domzalski <greg@yubico.com>
- Loading branch information
1 parent
7ef3263
commit 245c831
Showing
4 changed files
with
139 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. | ||
|
||
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"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters