Search code examples
c#cryptographyrsacryptoserviceprovider

RSACryptoServiceProvider - where does the seed data is being generated?


I have the following code that generates public and private keys using RSA.

// generate RSA 1024
                using (var rsa = new RSACryptoServiceProvider(1024))
                {
                    var publicString = RSACryptoService.ExportPublicKeyNoHeaderFooter(rsa);
                    var privateString = RSACryptoService.ExportPrivateKey(rsa);

                    rsaKey = Convert.FromBase64String(publicString);
                }

My question is on how does RSACryptoServiceProvider generates everytime a random one, does it uses kind of a seed that is based on hardware or on timestamp?


Solution

  • how does RSACryptoServiceProvider generate a random seed? is it based on hardware or on timestamp?

    It depends on what hardware is available and what operating system you're running on. If you're running on Windows, the entropy for the seed can come from several sources: