.NET RSA.Create (String algName): What is included in algName?

According to the MSDN documentation for the RSA class, there are two RSA.Create () methods. One default implementation and one that accepts the string parameter "algName". I could not find examples using the RSA.Create (String) version anywhere on the Internet.

So my questions are: what does the "algName" parameter usually contain? What algorithms can I use? Or where can I find information on valid algorithm names?

+4
source share
3 answers

You can put whatever you want, but I think you need to implement it yourself. There is only one implementation of the RSA in the .NET framework out of the box, namely RSACryptoServiceProvider . http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsacryptoserviceprovider.aspx

The Create(String) method inherits from AsymmetricAlgorithm , and you can pass multiple values ​​to the method, see http://msdn.microsoft.com/en-us/library/bf2t8ayw.aspx for a complete list ...

+8
source

Various methods for creating a cryptographic API.NET are designed to work with the machine.config file and the System.Security.Cryptography.CryptoConfig type.

This allows the application using them to use the machine implementation of the algorithm (hence the use of machine.config ). For instance.

 RSA rsa = RSA.Create (); 

will create by default (nothing in the machine.config file), RSACryptoServiceProvider. Now, if you modify the machine.config file, your application may return an instance of RSAManaged (for example, by configuring it to use Mono.Security.dll). This is very useful so that applications can choose specific implementations (for example, certified FIPS-140) or HSM (hardware security modules), that is, there is no need to recompile the application to support them!

Returning to the original Create (string) , this method allows you to choose which implementation to use. It simply calls CryptoConfig.CreateFromName (string) and returns the result, in this case, RSA .

This is useful if you want to be sure to use a specific implementation, for example. RSAManaged - even without binding your application to a specific assembly (eg. Mono.Security.dll).

+5
source

Eric A. Brandstadmoen's answer has been correct so far, but with .NET 4.6 there is now a second RSA class:

RSACng

https://msdn.microsoft.com/en-us/library/system.security.cryptography.rsacng(v=vs.110).aspx

RSA.Create () still returns the RSACryptoServiceProvider by default, but as mentioned above, you can change this behavior in the machine.config file.

If you are interested in a more detailed comparison and examples of how to override it in machine.config, you can check out this blog post:

http://dusted.codes/how-to-use-rsa-in-dotnet-rsacryptoserviceprovider-vs-rsacng-and-good-practise-patterns

+2
source

Source: https://habr.com/ru/post/1369551/


All Articles