public static RSACryptoServiceProvider CreateCSPFromPrimes() { var p = PrimeGenerator.GetPrime1(512); var q = PrimeGenerator.GetPrime1(512); var csp = new RSACryptoServiceProvider(); csp.ImportParameters(RSAGenerator.GenerateKey(p, q)); return(csp); }
static void Main(string[] args) { BigInteger p = PrimeGenerator.GetPrime1(1024); BigInteger q = PrimeGenerator.GetPrime1(1024); var rsaparams = RSAGenerator.GenerateKey(p, q); using var csp = new RSACryptoServiceProvider(); csp.ImportParameters(rsaparams); Console.Clear(); Console.WriteLine("KEYSIZE: " + csp.KeySize); }
public void GeneratedPrimeIsPrime() { var prime = PrimeGenerator.GetPrime1(); Assert.True(PrimeChecker.IsPrime(prime)); }