Create key 2048 with custom exponent size?

Is there a way to generate a 2048 RSA key pair using RSACryptoServiceProvider with a user defined metric?

 new RSACryptoServiceProvider(2048); // = 65537 always 

For example, I want to set the exponent to 65535 , but the hard-coded value seems to be 65537 .

I looked around, but could not find any information.

I am trying to create a new key pair and not import an existing key using RSACryptoServiceProvider .

I know that by importing an existing key, I can determine the module, exponent and other factors.

If this is not possible, what are my alternatives?

+5
source share
1 answer

You can use the cryptographic library Bouncy Castle . Use the RsaKeyPairGenerator class to generate keys with RsaKeyGenerationParameters to configure your overall RSA metric. See here an example of generating a key pair. But pay attention to the choice of exhibitor. The public RSA score should be a Fermat Number . See Question Consequences of not using RSA 65537 for more information on choosing an exhibitor.

See also helpful certificate creation messages Using .NET Bouncy Castle . For your convenience, you can create a Bouncy Castle certificate and convert it to a .NET X509Certificate2 object.

Update:

I think an example in this question using RSACryptoServiceProvider can help you.

0
source

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


All Articles