Question

I carried my RSA encryption method to MonoDevelop project. It already was working, but in mono
ExportParameters() function takes 4-5 minute. I can't understand it. Thanks for your helps.

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

RSAParameters rsaPar = rsa.ExportParameters(false);
Was it helpful?

Solution

You can find the answer in the source code of RSACryptoServiceProvider class:

public RSACryptoServiceProvider ()
    : this (1024)
{
    // Here it's not clear if we need to generate a keypair
    // (note: MS implementation generates a keypair in this case).
    // However we:
    // (a) often use this constructor to import an existing keypair.
    // (b) take a LOT of time to generate the RSA keypair
    // So we'll generate the keypair only when (and if) it's being
    // used (or exported). This should save us a lot of time (at 
    // least in the unit tests).
}

As you can see ExportParameters() method is performing RSA keypair generation which is time consuming operation. How much time it actually takes depends on the type of PRNG used and whether there is enough entropy available on your system to seed it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top