summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--crypto/src/security/DotNetUtilities.cs23
1 files changed, 23 insertions, 0 deletions
diff --git a/crypto/src/security/DotNetUtilities.cs b/crypto/src/security/DotNetUtilities.cs
index ef9322801..df9d327de 100644
--- a/crypto/src/security/DotNetUtilities.cs
+++ b/crypto/src/security/DotNetUtilities.cs
@@ -158,16 +158,32 @@ namespace Org.BouncyCastle.Security
             return CreateRSAProvider(ToRSAParameters(rsaKey));
         }
 
+        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);
+        }
+
         public static RSA ToRSA(RsaPrivateCrtKeyParameters privKey)
         {
             return CreateRSAProvider(ToRSAParameters(privKey));
         }
 
+        public static RSA ToRSA(RsaPrivateCrtKeyParameters privKey, CspParameters csp)
+        {
+            return CreateRSAProvider(ToRSAParameters(privKey), csp);
+        }
+
         public static RSA ToRSA(RsaPrivateKeyStructure privKey)
         {
             return CreateRSAProvider(ToRSAParameters(privKey));
         }
 
+        public static RSA ToRSA(RsaPrivateKeyStructure privKey, CspParameters csp)
+        {
+            return CreateRSAProvider(ToRSAParameters(privKey), csp);
+        }
+
         public static RSAParameters ToRSAParameters(RsaKeyParameters rsaKey)
         {
             RSAParameters rp = new RSAParameters();
@@ -231,6 +247,13 @@ namespace Org.BouncyCastle.Security
             rsaCsp.ImportParameters(rp);
             return rsaCsp;
         }
+
+        private static RSA CreateRSAProvider(RSAParameters rp, CspParameters csp)
+        {
+            RSACryptoServiceProvider rsaCsp = new RSACryptoServiceProvider(csp);
+            rsaCsp.ImportParameters(rp);
+            return rsaCsp;
+        }
     }
 }