examples
public class GenerateKeyPair extends java.lang.Object
Usage:
java -cp examples.jar examples.GenerateKeyPair
definition_file
The definition file is a standard Java property file which should
contain the following properties:
- format
- Format of keyfile. Valid values are
openssh
and
sshinc
. The default value is openssh.
- algorithm
- Which algorithm to generate a key for. Valid valus are
RSA
and DSA
. The default value is RSA.
- bits
- Number of bits in key. The default value is 1024.
- password
- Password used to encrypt the private key
- subject
- String identifying the owner of the key
- comment
- Key comment
- keyfile
- Base-name of files to save keys in. The private file will be
stored in keyfile and the public key in
keyfile
.pub
-
-
Constructor Summary
Constructors
Constructor and Description
GenerateKeyPair()
-
Method Summary
Methods
Modifier and Type
Method and Description
static java.security.KeyPair
generateKeyPair(java.lang.String alg,
int bits,
java.security.SecureRandom rand)
Actually generate the key pair
static void
main(java.lang.String[] argv)
Run the application
static void
saveKeyPair(java.security.KeyPair kp,
java.lang.String passwd,
java.lang.String fileName,
java.lang.String subject,
java.lang.String comment,
boolean sshComFormat,
java.security.SecureRandom rand)
Save the given keypair to a file.
-
-
Method Detail
-
generateKeyPair
public static java.security.KeyPair generateKeyPair(java.lang.String alg,
int bits,
java.security.SecureRandom rand)
throws java.security.NoSuchAlgorithmException
Actually generate the key pair
- Parameters:
alg
- algorithm to generate for (RSA or DSA)bits
- key sizerand
- random number source
- Throws:
java.security.NoSuchAlgorithmException
-
saveKeyPair
public static void saveKeyPair(java.security.KeyPair kp,
java.lang.String passwd,
java.lang.String fileName,
java.lang.String subject,
java.lang.String comment,
boolean sshComFormat,
java.security.SecureRandom rand)
throws java.io.IOException,
SSH2Exception
Save the given keypair to a file.
- Throws:
java.io.IOException
SSH2Exception
-
main
public static void main(java.lang.String[] argv)
Run the application