static KeyPair generateRsaKeyPair(int keySize) {
    KeyPairGenerator rsaGenerator;
    try {
      rsaGenerator = KeyPairGenerator.getInstance("RSA");
      rsaGenerator.initialize(keySize);
    } catch (NoSuchAlgorithmException e) {
      throw new IllegalStateException("No support for RSA algorithm.", e);
    }
    return rsaGenerator.generateKeyPair();
  }
Generates a random BigInteger in (0, max) (excluding 0 and max) and converts the result to a
byte array having the same length as max.
java_src/src/main/java/com/google/crypto/tink/hybrid/subtle/RsaKem.java