Hi Fred,
Following are the steps required are to create a Public/Private Keys:
1. Load the security provider (if not configured in $JAVAHOME/jre/lib/security/java.security)
2. Obtain a handle to a secure random number generator.
3. Obtain a handle to KeyPairGenerator for a specific public key algorithm.
4. Generate the public/private key pair
5. Extract the public and private keys
The following example shows how to generate public and private keys using the KeyPairGenerator and KeyPair interfaces using JCSI's security provider.
import java.security.*;
. . .
// Load JCSI's JCA security provider
Security.addProvider(new com.dstc.security.provider.DSTC());
// Seed random number generator using the default seeding
// "SHA1PRNG" = SHA1 Pseudo-random number generator
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
// Initialise KeyPairGenerator to create 1024-bit RSA keys.
// PK Algorithm = "RSA", Security Provider = "DSTC" (Wedgetail)
KeyPairGenerator keyGen = KeyPairGenerator.getInstance("RSA", "DSTC");
keyGen.initialize(1024, random);
// Generate RSA pulic/private key pair
KeyPair keyPair = keyGen.genKeyPair();
// Extract public and private keys
PrivateKey privKey = keyPair.getPrivate();
PublicKey pubKey = keyPair.getPublic();
Hope this will help you.
Regards,
Anil.
Techncial Support Engineer.
Hi,
Try this URL's:
http://java.sun.com/docs/books/tutorial/security1.2/apisign/step2.html
http://www.nusphere.com/products/library/ssl.htm
http://java.sun.com/docs/books/tutorial/security1.1/api/step2.html
http://developer.netscape.com/docs/manuals/security/pkin/contents.htm
Thanks,
Senthilkumar