Skip to content

Commit

Permalink
removing obsoleted ifdefs since net452 support was removed
Browse files Browse the repository at this point in the history
  • Loading branch information
karoberts committed Jan 11, 2024
1 parent c547f07 commit 510745b
Show file tree
Hide file tree
Showing 9 changed files with 0 additions and 24 deletions.
2 changes: 0 additions & 2 deletions src/Microsoft.IdentityModel.Tokens/SecurityAlgorithms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public static class SecurityAlgorithms
public const string Aes256KW = "A256KW";
public const string RsaPKCS1 = "RSA1_5";
public const string RsaOAEP = "RSA-OAEP";
#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
public const string RsaOAEP256 = "RSA-OAEP-256";
#endif

// See: https://www.w3.org/TR/xmlenc-core1/#sec-Exclusive-Canonicalization
public const string ExclusiveC14n = "http://www.w3.org/2001/10/xml-exc-c14n#";
Expand Down
2 changes: 0 additions & 2 deletions src/Microsoft.IdentityModel.Tokens/SupportedAlgorithms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ internal static class SupportedAlgorithms
internal static readonly ICollection<string> RsaEncryptionAlgorithms = new Collection<string>
{
SecurityAlgorithms.RsaOAEP,
#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
SecurityAlgorithms.RsaOAEP256,
#endif
SecurityAlgorithms.RsaPKCS1,
SecurityAlgorithms.RsaOaepKeyWrap
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2711,7 +2711,6 @@ public static TheoryData<CreateTokenTheoryData> RoundTripJWEKeyWrapTestCases
SigningCredentials = Default.SymmetricSigningCredentials,
EncryptingCredentials = new EncryptingCredentials(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaOAEP, SecurityAlgorithms.Aes128CbcHmacSha256)
},
#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
new CreateTokenTheoryData
{
TestId = "RsaOAEP256_Aes128CbcHmacSha256",
Expand All @@ -2736,7 +2735,6 @@ public static TheoryData<CreateTokenTheoryData> RoundTripJWEKeyWrapTestCases
SigningCredentials = Default.SymmetricSigningCredentials,
EncryptingCredentials = new EncryptingCredentials(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaOAEP256, SecurityAlgorithms.Aes256CbcHmacSha512)
},
#endif
new CreateTokenTheoryData
{
TestId = "RsaOAEP_Aes192CbcHmacSha384",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,12 @@ public static TheoryData<KeyWrapProviderTheoryData> DisposeProviderTheoryData
ExpectedException = ExpectedException.NoExceptionExpected,
TestId = nameof(SecurityAlgorithms.RsaOAEP),
},
#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
new KeyWrapProviderTheoryData
{
Algorithm = SecurityAlgorithms.RsaOAEP256,
ExpectedException = ExpectedException.NoExceptionExpected,
TestId = nameof(SecurityAlgorithms.RsaOAEP256),
},
#endif
};
}

Expand Down
2 changes: 0 additions & 2 deletions test/Microsoft.IdentityModel.Tokens.Tests/KeyVaultVerify.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@ public void DecryptValidate(KeyWrapTestParams testParams)
CryptoProviderFactory.Default.ReleaseKeyWrapProvider(keyWrapProvider);
}
else if (testParams.Algorithm.Equals(SecurityAlgorithms.RsaOAEP, StringComparison.OrdinalIgnoreCase)
#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
|| testParams.Algorithm.Equals(SecurityAlgorithms.RsaOAEP256, StringComparison.OrdinalIgnoreCase)
#endif
|| testParams.Algorithm.Equals(SecurityAlgorithms.RsaPKCS1, StringComparison.OrdinalIgnoreCase))
{
var keyWrapProvider = CryptoProviderFactory.Default.CreateKeyWrapProvider(testParams.Key, testParams.Algorithm);
Expand Down
2 changes: 0 additions & 2 deletions test/Microsoft.IdentityModel.Tokens.Tests/ReferenceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,7 @@ public void KeyWrapReferenceTest(KeyWrapTestParams testParams)
}
else if (testParams.Algorithm.Equals(SecurityAlgorithms.RsaOAEP, StringComparison.OrdinalIgnoreCase)
|| testParams.Algorithm.Equals(SecurityAlgorithms.RsaPKCS1, StringComparison.OrdinalIgnoreCase)
#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
|| testParams.Algorithm.Equals(SecurityAlgorithms.RsaOAEP256, StringComparison.OrdinalIgnoreCase)
#endif
)
{
var rsaKeyWrapProvider = CryptoProviderFactory.Default.CreateKeyWrapProvider(testParams.Key, testParams.Algorithm);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,6 @@ public static TheoryData<KeyWrapTheoryData> RsaKeyWrapConstructorTheoryData()
WrapAlgorithm = SecurityAlgorithms.RsaOAEP,
WrapKey = KeyingMaterial.RsaSecurityKey_1024
},
#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
new KeyWrapTheoryData
{
ExpectedException = ExpectedException.SecurityTokenKeyWrapException("IDX10661:"),
Expand All @@ -111,7 +110,6 @@ public static TheoryData<KeyWrapTheoryData> RsaKeyWrapConstructorTheoryData()
WrapAlgorithm = SecurityAlgorithms.RsaOAEP256,
WrapKey = KeyingMaterial.RsaSecurityKey_1024
},
#endif
new KeyWrapTheoryData
{
ExpectedException = ExpectedException.SecurityTokenKeyWrapException("IDX10661:"),
Expand Down Expand Up @@ -221,7 +219,6 @@ public static TheoryData<KeyWrapTheoryData> RsaUnwrapMismatchTheoryData()
WrapAlgorithm = SecurityAlgorithms.RsaPKCS1,
WrapKey = KeyingMaterial.RsaSecurityKey_4096_Public,
},
#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
new KeyWrapTheoryData
{
ExpectedException = ExpectedException.KeyWrapException("IDX10659:"),
Expand Down Expand Up @@ -249,7 +246,6 @@ public static TheoryData<KeyWrapTheoryData> RsaUnwrapMismatchTheoryData()
WrapAlgorithm = SecurityAlgorithms.RsaPKCS1,
WrapKey = KeyingMaterial.RsaSecurityKey_4096_Public,
}
#endif
};
}

Expand Down Expand Up @@ -407,14 +403,12 @@ public static TheoryData<KeyWrapTheoryData> RsaWrapUnwrapTheoryData()
ExpectedException.ArgumentNullException(),
theoryData);

#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
AddWrapUnwrapTheoryData(
"Test4",
SecurityAlgorithms.RsaOAEP256,
KeyingMaterial.RsaSecurityKey_2048_Public,
KeyingMaterial.RsaSecurityKey_2048,
theoryData);
#endif

return theoryData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,6 @@ public static TheoryData<string, SecurityTokenDescriptor, TokenValidationParamet
ExpectedException.NoExceptionExpected
);

#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
encryptingCredentials = new EncryptingCredentials(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaOAEP256, SecurityAlgorithms.Aes128CbcHmacSha256);
theoryData.Add(
"RsaOAEP256-Aes128CbcHmacSha256",
Expand All @@ -826,7 +825,6 @@ public static TheoryData<string, SecurityTokenDescriptor, TokenValidationParamet
Default.TokenValidationParameters(KeyingMaterial.RsaSecurityKey_2048, Default.SymmetricSigningKey256),
ExpectedException.NoExceptionExpected
);
#endif

encryptingCredentials = new EncryptingCredentials(KeyingMaterial.RsaSecurityKey_2048, SecurityAlgorithms.RsaOaepKeyWrap, SecurityAlgorithms.Aes128CbcHmacSha256);
theoryData.Add(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2707,9 +2707,7 @@ public static TheoryData<KeyWrapTokenTheoryData> KeyWrapTokenTheoryData()
var theoryData = new TheoryData<KeyWrapTokenTheoryData>();
var handler = new JwtSecurityTokenHandler();
var rsaOAEPEncryptingCredential = new EncryptingCredentials(KeyingMaterial.DefaultX509Key_2048, SecurityAlgorithms.RsaOAEP, SecurityAlgorithms.Aes256CbcHmacSha512);
#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
var rsaOAEP256EncryptingCredential = new EncryptingCredentials(KeyingMaterial.DefaultX509Key_2048, SecurityAlgorithms.RsaOAEP256, SecurityAlgorithms.Aes256CbcHmacSha512);
#endif
var rsaPKCS1EncryptingCredential = new EncryptingCredentials(KeyingMaterial.DefaultX509Key_2048, SecurityAlgorithms.RsaPKCS1, SecurityAlgorithms.Aes256CbcHmacSha512);

theoryData.Add(new KeyWrapTokenTheoryData
Expand All @@ -2719,14 +2717,12 @@ public static TheoryData<KeyWrapTokenTheoryData> KeyWrapTokenTheoryData()
TestId = "Key wrap token test using OAEP padding"
});

#if NET461 || NET462 || NET472 || NETSTANDARD2_0 || NET6_0_OR_GREATER
theoryData.Add(new KeyWrapTokenTheoryData
{
EncryptingCredentials = rsaOAEP256EncryptingCredential,
DecryptingCredentials = rsaOAEP256EncryptingCredential,
TestId = "Key wrap token test using OAEP-256 padding"
});
#endif

theoryData.Add(new KeyWrapTokenTheoryData
{
Expand Down

0 comments on commit 510745b

Please sign in to comment.