Here you can find the source of generateKeyPair()
public static KeyPair generateKeyPair() throws NoSuchProviderException, NoSuchAlgorithmException
//package com.java2s; //License from project: Apache License import java.security.*; public class Main { /**/*from w w w .j a v a 2 s . c om*/ * Generate a random key pair. * @return KeyPair containg private and public key */ public static KeyPair generateKeyPair() throws NoSuchProviderException, NoSuchAlgorithmException { KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA", "SUN"); SecureRandom random = SecureRandom.getInstance("SHA1PRNG", "SUN"); keyGen.initialize(1024, random); return keyGen.generateKeyPair(); } }