When you generate an ElGamal key pair, you have the option of specifying a prime modulus. If you do not specify the prime modulus, one will be generated, however because the modulus must be a safe prime (a prime p such that (p-1)/2 is also prime), and those are much rarer than regular primes, it takes a long time.
I suggest that you use an existing well known safe prime instead. For example the following 2048-bit one from http://www.ietf.org/internet-drafts/draft-ietf-ipsec-ike-modp-groups-04.txt :
"36F0255DDE973DCB3B399D747F23E32ED6FDB1F77598338BFDF44159C4EC64DDAEB5F78671CBFB22"
"106AE64C32C5BCE4CFD4F5920DA0EBC8B01ECA9292AE3DBA1B7A4A899DA181390BB3BD1659C81294"
"F400A3490BF9481211C79404A576605A5160DBEE83B4E019B6D799AE131BA4C23DFF83475E9C40FA"
"6725B7C9E3AA2C6596E9C05702DB30A07C9AA2DC235C5269E39D0CA9DF7AAD44612AD6F88F696992"
"98F3CAB1B54367FB0E8B93F735E7DE83CD6FA1B9D1C931C41C6188D3E7F179FC64D87C5D13F85D70"
"4A3AA20F90B3AD3621D434096AA7E8E7C66AB683156A951AEA2DD9E76705FAEFEA8D71A575535597"
"0000000000000001H"
The g (generator) value for this prime should be 2.
*2002-May-14 6:54pm weidai* |