diff options
author | Peter Dettman <peter.dettman@bouncycastle.org> | 2018-04-08 18:16:27 +0700 |
---|---|---|
committer | Peter Dettman <peter.dettman@bouncycastle.org> | 2018-04-08 18:16:27 +0700 |
commit | 96b2f7423511351f7009b563626de035b56ec6ad (patch) | |
tree | 65af17ca666bd9264b8dd524584164f563f6c7f2 /crypto/src | |
parent | Merge branch 'ZZMarquis-patch-1' (diff) | |
download | BouncyCastle.NET-ed25519-96b2f7423511351f7009b563626de035b56ec6ad.tar.xz |
Provide methods taking explicit CspParameters
- https://github.com/bcgit/bc-csharp/issues/107
Diffstat (limited to 'crypto/src')
-rw-r--r-- | crypto/src/security/DotNetUtilities.cs | 23 |
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; + } } } |