Cryptography/CafeLib.Cryptography.BouncyCastle/Crypto/Generators/RsaKeyPairGenerator.cs
/// <summary>Choose a random prime value for use with RSA</summary>
/// <param name="bitlength">the bit-length of the returned prime</param>
/// <param name="e">the RSA public exponent</param>
/// <returns>a prime p, with (p-1) relatively prime to e</returns>
Choose a random prime value for use with RSA
Choose a random prime value for use with RSA
protected virtual BigInteger ChooseRandomPrime(int bitlength, BigInteger e)
        {
            for (;;)
            {
                BigInteger p = new BigInteger(bitlength, 1, param.Random);
                if (p.Mod(e).Equals(BigInteger.One))
                    continue;
                if (!p.IsProbablePrime(param.Certainty))
                    continue;
                if (!e.Gcd(p.Subtract(BigInteger.One)).Equals(BigInteger.One))
                    continue;
                return p;
            }
        }
protected virtual BigInteger ChooseRandomPrime ( int bitlength , BigInteger e ) { for ( ; ; ) { BigInteger p = new BigInteger ( bitlength , 1 , param . Random ) ; if ( p . Mod ( e ) . Equals ( BigInteger . One ) ) continue ; if ( ! p . IsProbablePrime ( param . Certainty ) ) continue ; if ( ! e . Gcd ( p . Subtract ( BigInteger . One ) ) . Equals ( BigInteger . One ) ) continue ; return p ; } }
Choose a random prime value for use with RSA
Choose a random prime value for use with RSA
a prime p, with (p-1) relatively prime to e
a prime p with ( p - 1 ) relatively prime to e
bitlength
int
the bit-length of the returned prime
the bit - length of the returned prime
e
BigInteger
the RSA public exponent
the RSA public exponent