Skip to content

Commit

Permalink
For net4.6.2 select RSACng for PSS support. (#3085)
Browse files Browse the repository at this point in the history
Co-authored-by: id4s <[email protected]>
  • Loading branch information
brentschmaltz and HP712 authored Jan 9, 2025
1 parent 3f2fbf1 commit 6146f1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Microsoft.IdentityModel.Tokens/AsymmetricAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,9 @@ private void InitializeUsingRsaSecurityKey(RsaSecurityKey rsaSecurityKey, string
{
#if NET472 || NET6_0_OR_GREATER
var rsa = RSA.Create(rsaSecurityKey.Parameters);
#elif NET462
var rsa = new RSACng();
rsa.ImportParameters(rsaSecurityKey.Parameters);
#else
var rsa = RSA.Create();
rsa.ImportParameters(rsaSecurityKey.Parameters);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ internal static void AddSignUsingOffsets(byte[] bytes, SecurityKey securityKey,
{
Bytes = bytes,
Count = -1,
ExpectedException = ExpectedException.ArgumentException(),
ExpectedException = prefix == "RSA" ? ExpectedException.ArgumentOutOfRangeException() : ExpectedException.ArgumentException(),
Offset = 0,
SignatureProvider = CreateProvider(securityKey, algorithm)
});
Expand All @@ -1316,7 +1316,7 @@ internal static void AddSignUsingOffsets(byte[] bytes, SecurityKey securityKey,
{
Bytes = bytes,
Count = bytes.Length + 1,
ExpectedException = ExpectedException.ArgumentException(),
ExpectedException = prefix == "RSA" ? ExpectedException.ArgumentOutOfRangeException() : ExpectedException.ArgumentException(),
Offset = 0,
SignatureProvider = CreateProvider(securityKey, algorithm)
});
Expand All @@ -1325,7 +1325,7 @@ internal static void AddSignUsingOffsets(byte[] bytes, SecurityKey securityKey,
{
Bytes = bytes,
Count = 10,
ExpectedException = ExpectedException.ArgumentException(),
ExpectedException = prefix == "RSA" ? ExpectedException.ArgumentOutOfRangeException() : ExpectedException.ArgumentException(),
Offset = bytes.Length - 1,
SignatureProvider = CreateProvider(securityKey, algorithm)
});
Expand Down

0 comments on commit 6146f1f

Please sign in to comment.