/** * Generate a new RSA key pair of given strength. The strength should be given in number of bytes, * so for a 2048 bits key, you should use 256 (bytes) as the integer parameter. The minimum valid * strength is 2. * * <p>The key public exponent will be 0x10001. The probability a chosen prime could not be a real * prime will be smaller than 2^-{@value RSAKeyGenerationParameters#DEFAULT_CERTAINTY}. * * @param strength the strength in bytes. * @return an new asymmetric key pair. */ public AsymmetricKeyPair generateKeyPair(int strength) { return keyPairGenerator.generate(new RSAKeyGenerationParameters(strength)); }
/** * Build a new instance with all custom parameters. The strength should be given in number of * bytes, so for a 2048 bits key, you should use 256 (bytes) as the integer parameter. The minimum * valid strength is 2. The exponent should be an odd number. The probability a chosen prime could * not be a real prime will be smaller than 2^certainty. * * @param strength the key strength in bytes. * @param publicExponent the public exponent. * @param certainty certainty for prime evaluation. * @return an new asymmetric key pair. */ public AsymmetricKeyPair generateKeyPair(int strength, BigInteger publicExponent, int certainty) { return keyPairGenerator.generate( new RSAKeyGenerationParameters(strength, publicExponent, certainty)); }
/** * Generate a new RSA key pair. * * <p>The key strength will be {@value RSAKeyGenerationParameters#DEFAULT_STRENGTH}. The key * public exponent will be 0x10001. The probability a chosen prime could not be a real prime will * be smaller than 2^-{@value RSAKeyGenerationParameters#DEFAULT_CERTAINTY}. * * @return an new asymmetric key pair. */ public AsymmetricKeyPair generateKeyPair() { return keyPairGenerator.generate(); }