diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-25 21:47:21 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2022-10-25 21:47:21 +0700 |
commit | 296a22544c63b43e72b8fbfe8c70bf46768d5d16 (patch) | |
tree | ab08d0e34adc12cad137591183230e7407ef3ce8 /crypto | |
parent | Refactoring in Keccak code (diff) | |
download | BouncyCastle.NET-ed25519-296a22544c63b43e72b8fbfe8c70bf46768d5d16.tar.xz |
FIne-grained SupportedOSPlatform attributes
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/src/security/DotNetUtilities.cs | 27 | ||||
-rw-r--r-- | crypto/test/src/security/test/TestDotNetUtil.cs | 9 |
2 files changed, 29 insertions, 7 deletions
diff --git a/crypto/src/security/DotNetUtilities.cs b/crypto/src/security/DotNetUtilities.cs index ccfb2b2b8..3a7c5f0cb 100644 --- a/crypto/src/security/DotNetUtilities.cs +++ b/crypto/src/security/DotNetUtilities.cs @@ -18,9 +18,6 @@ namespace Org.BouncyCastle.Security /// <summary> /// A class containing methods to interface the BouncyCastle world to the .NET Crypto world. /// </summary> -#if NET5_0_OR_GREATER - [SupportedOSPlatform("windows")] -#endif public static class DotNetUtilities { /// <summary> @@ -153,33 +150,51 @@ namespace Org.BouncyCastle.Security throw new ArgumentException("Unsupported algorithm specified", "privateKey"); } +#if NET5_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public static RSA ToRSA(RsaKeyParameters rsaKey) { // TODO This appears to not work for private keys (when no CRT info) return CreateRSAProvider(ToRSAParameters(rsaKey)); } +#if NET5_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public static RSA ToRSA(RsaKeyParameters rsaKey, CspParameters csp) { // TODO This appears to not work for private keys (when no CRT info) return CreateRSAProvider(ToRSAParameters(rsaKey), csp); } +#if NET5_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public static RSA ToRSA(RsaPrivateCrtKeyParameters privKey) { return CreateRSAProvider(ToRSAParameters(privKey)); } +#if NET5_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public static RSA ToRSA(RsaPrivateCrtKeyParameters privKey, CspParameters csp) { return CreateRSAProvider(ToRSAParameters(privKey), csp); } +#if NET5_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public static RSA ToRSA(RsaPrivateKeyStructure privKey) { return CreateRSAProvider(ToRSAParameters(privKey)); } +#if NET5_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif public static RSA ToRSA(RsaPrivateKeyStructure privKey, CspParameters csp) { return CreateRSAProvider(ToRSAParameters(privKey), csp); @@ -229,6 +244,9 @@ namespace Org.BouncyCastle.Security return BigIntegers.AsUnsignedByteArray(size, n); } +#if NET5_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif private static RSACryptoServiceProvider CreateRSAProvider(RSAParameters rp) { CspParameters csp = new CspParameters(); @@ -236,6 +254,9 @@ namespace Org.BouncyCastle.Security return CreateRSAProvider(rp, csp); } +#if NET5_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif private static RSACryptoServiceProvider CreateRSAProvider(RSAParameters rp, CspParameters csp) { RSACryptoServiceProvider rsaCsp = new RSACryptoServiceProvider(csp); diff --git a/crypto/test/src/security/test/TestDotNetUtil.cs b/crypto/test/src/security/test/TestDotNetUtil.cs index 3ca3efdbb..b83a94a36 100644 --- a/crypto/test/src/security/test/TestDotNetUtil.cs +++ b/crypto/test/src/security/test/TestDotNetUtil.cs @@ -20,12 +20,13 @@ using Org.BouncyCastle.X509; namespace Org.BouncyCastle.Security.Tests { [TestFixture] -#if NET5_0_OR_GREATER - [SupportedOSPlatform("windows")] -#endif public class TestDotNetUtilities { - [Test] +//#if NET5_0_OR_GREATER +#if NET6_0_OR_GREATER + [SupportedOSPlatform("windows")] +#endif + [Test] public void TestRsaInterop() { for (int i = 0; i < 100; ++i) |