-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance RSA.Create #17344
Comments
(Marked as api-approved since this is an action item which came out of the EC import/export design discussion) |
Removing NS2.0 label as this isn't in desktop yet |
Should be fairly simple to implement (10 mins + adding new API) - up for grabs. |
So the x-plat problem still exists in netstandard 2.0 RSA.Create will create a 1k key on .NET Framework 4.6.1 and a 2k key on .NET Core 2. Is there a workaround for that that doesn't involve multi-targeting our library (because of 1 API)? Am I missing something? |
private static RSA CreateRSA(int keySize)
{
RSA rsa = RSA.Create();
if (rsa is RSACryptoServiceProvider)
{
rsa.Dispose();
return new RSACng(keySize);
}
rsa.KeySize = keySize;
return rsa;
} Or static YourClass()
{
using (RSA rsa = RSA.Create())
{
if (rsa is RSACryptoServiceProvider)
{
CryptoConfig.AddAlgorithm(typeof(RSACng), "System.Security.Cryptography.RSA");
}
}
} Though the latter is harmful to code that does blind casting. |
Thanks - but where do I find According to this It is not supported by netstandard2 libs. |
nevermind - I think I found it. |
Thanks! It is working! |
For those like me, |
During the API review of #16960 it was decided that to enable better cross-plat authoring we should have Create() methods on the following crypto base classes:
ECDsa: Create(), Create(ECCurve), Create(ECParameters)
RSA: Create(), Create(int), Create(RSAParameters)
ECDiffieHellman: Create(), Create(ECCurve), Create(ECParameters)
DSA: Create(), Create(int), Create(DSAParameters)
Hopefully all of these make it for net463, and we should have them in .NET Core as well.
This specific issue tracks adding the int and RSAParameters create overloads for RSA, and is an offshoot of #17266.
The text was updated successfully, but these errors were encountered: