Here you can find the source of generateKeyPair(int keysize)
public static KeyPair generateKeyPair(int keysize) throws NoSuchAlgorithmException
//package com.java2s; /*//from w ww.j av a 2 s.c om * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ import java.security.KeyPair; import java.security.KeyPairGenerator; import java.security.NoSuchAlgorithmException; public class Main { /** * Generates a RSA key pair with the provided key size (in bits) */ public static KeyPair generateKeyPair(int keysize) throws NoSuchAlgorithmException { // generate a private key KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(keysize); return keyPairGenerator.generateKeyPair(); } }