Code example for RSAKeyGenParameterSpec

Methods: getKeysize, getPublicExponent

0
            throw new InvalidAlgorithmParameterException("parameter object not a RSAKeyGenParameterSpec");
        } 
        RSAKeyGenParameterSpec rsaParams = (RSAKeyGenParameterSpec)params;
 
        param = new RSAKeyGenerationParameters(
            rsaParams.getPublicExponent(),
            random, rsaParams.getKeysize(), defaultTests);
 
        engine.init(param);
    } 
 
    public KeyPair generateKeyPair()
    { 
        AsymmetricCipherKeyPair pair = engine.generateKeyPair();
        RSAKeyParameters pub = (RSAKeyParameters)pair.getPublic();
        RSAPrivateCrtKeyParameters priv = (RSAPrivateCrtKeyParameters)pair.getPrivate();
 
        return new KeyPair(new BCRSAPublicKey(pub),
            new BCRSAPrivateCrtKey(priv));
    } 
}