1*ebfedea0SLionel Sambuc=pod 2*ebfedea0SLionel Sambuc 3*ebfedea0SLionel Sambuc=head1 NAME 4*ebfedea0SLionel Sambuc 5*ebfedea0SLionel Sambucgenpkey - generate a private key 6*ebfedea0SLionel Sambuc 7*ebfedea0SLionel Sambuc=head1 SYNOPSIS 8*ebfedea0SLionel Sambuc 9*ebfedea0SLionel SambucB<openssl> B<genpkey> 10*ebfedea0SLionel Sambuc[B<-out filename>] 11*ebfedea0SLionel Sambuc[B<-outform PEM|DER>] 12*ebfedea0SLionel Sambuc[B<-pass arg>] 13*ebfedea0SLionel Sambuc[B<-cipher>] 14*ebfedea0SLionel Sambuc[B<-engine id>] 15*ebfedea0SLionel Sambuc[B<-paramfile file>] 16*ebfedea0SLionel Sambuc[B<-algorithm alg>] 17*ebfedea0SLionel Sambuc[B<-pkeyopt opt:value>] 18*ebfedea0SLionel Sambuc[B<-genparam>] 19*ebfedea0SLionel Sambuc[B<-text>] 20*ebfedea0SLionel Sambuc 21*ebfedea0SLionel Sambuc=head1 DESCRIPTION 22*ebfedea0SLionel Sambuc 23*ebfedea0SLionel SambucThe B<genpkey> command generates a private key. 24*ebfedea0SLionel Sambuc 25*ebfedea0SLionel Sambuc=head1 OPTIONS 26*ebfedea0SLionel Sambuc 27*ebfedea0SLionel Sambuc=over 4 28*ebfedea0SLionel Sambuc 29*ebfedea0SLionel Sambuc=item B<-out filename> 30*ebfedea0SLionel Sambuc 31*ebfedea0SLionel Sambucthe output filename. If this argument is not specified then standard output is 32*ebfedea0SLionel Sambucused. 33*ebfedea0SLionel Sambuc 34*ebfedea0SLionel Sambuc=item B<-outform DER|PEM> 35*ebfedea0SLionel Sambuc 36*ebfedea0SLionel SambucThis specifies the output format DER or PEM. 37*ebfedea0SLionel Sambuc 38*ebfedea0SLionel Sambuc=item B<-pass arg> 39*ebfedea0SLionel Sambuc 40*ebfedea0SLionel Sambucthe output file password source. For more information about the format of B<arg> 41*ebfedea0SLionel Sambucsee the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>. 42*ebfedea0SLionel Sambuc 43*ebfedea0SLionel Sambuc=item B<-cipher> 44*ebfedea0SLionel Sambuc 45*ebfedea0SLionel SambucThis option encrypts the private key with the supplied cipher. Any algorithm 46*ebfedea0SLionel Sambucname accepted by EVP_get_cipherbyname() is acceptable such as B<des3>. 47*ebfedea0SLionel Sambuc 48*ebfedea0SLionel Sambuc=item B<-engine id> 49*ebfedea0SLionel Sambuc 50*ebfedea0SLionel Sambucspecifying an engine (by its unique B<id> string) will cause B<genpkey> 51*ebfedea0SLionel Sambucto attempt to obtain a functional reference to the specified engine, 52*ebfedea0SLionel Sambucthus initialising it if needed. The engine will then be set as the default 53*ebfedea0SLionel Sambucfor all available algorithms. If used this option should precede all other 54*ebfedea0SLionel Sambucoptions. 55*ebfedea0SLionel Sambuc 56*ebfedea0SLionel Sambuc=item B<-algorithm alg> 57*ebfedea0SLionel Sambuc 58*ebfedea0SLionel Sambucpublic key algorithm to use such as RSA, DSA or DH. If used this option must 59*ebfedea0SLionel Sambucprecede any B<-pkeyopt> options. The options B<-paramfile> and B<-algorithm> 60*ebfedea0SLionel Sambucare mutually exclusive. 61*ebfedea0SLionel Sambuc 62*ebfedea0SLionel Sambuc=item B<-pkeyopt opt:value> 63*ebfedea0SLionel Sambuc 64*ebfedea0SLionel Sambucset the public key algorithm option B<opt> to B<value>. The precise set of 65*ebfedea0SLionel Sambucoptions supported depends on the public key algorithm used and its 66*ebfedea0SLionel Sambucimplementation. See B<KEY GENERATION OPTIONS> below for more details. 67*ebfedea0SLionel Sambuc 68*ebfedea0SLionel Sambuc=item B<-genparam> 69*ebfedea0SLionel Sambuc 70*ebfedea0SLionel Sambucgenerate a set of parameters instead of a private key. If used this option must 71*ebfedea0SLionel Sambucprecede and B<-algorithm>, B<-paramfile> or B<-pkeyopt> options. 72*ebfedea0SLionel Sambuc 73*ebfedea0SLionel Sambuc=item B<-paramfile filename> 74*ebfedea0SLionel Sambuc 75*ebfedea0SLionel SambucSome public key algorithms generate a private key based on a set of parameters. 76*ebfedea0SLionel SambucThey can be supplied using this option. If this option is used the public key 77*ebfedea0SLionel Sambucalgorithm used is determined by the parameters. If used this option must 78*ebfedea0SLionel Sambucprecede and B<-pkeyopt> options. The options B<-paramfile> and B<-algorithm> 79*ebfedea0SLionel Sambucare mutually exclusive. 80*ebfedea0SLionel Sambuc 81*ebfedea0SLionel Sambuc=item B<-text> 82*ebfedea0SLionel Sambuc 83*ebfedea0SLionel SambucPrint an (unencrypted) text representation of private and public keys and 84*ebfedea0SLionel Sambucparameters along with the PEM or DER structure. 85*ebfedea0SLionel Sambuc 86*ebfedea0SLionel Sambuc=back 87*ebfedea0SLionel Sambuc 88*ebfedea0SLionel Sambuc=head1 KEY GENERATION OPTIONS 89*ebfedea0SLionel Sambuc 90*ebfedea0SLionel SambucThe options supported by each algorith and indeed each implementation of an 91*ebfedea0SLionel Sambucalgorithm can vary. The options for the OpenSSL implementations are detailed 92*ebfedea0SLionel Sambucbelow. 93*ebfedea0SLionel Sambuc 94*ebfedea0SLionel Sambuc=head1 RSA KEY GENERATION OPTIONS 95*ebfedea0SLionel Sambuc 96*ebfedea0SLionel Sambuc=over 4 97*ebfedea0SLionel Sambuc 98*ebfedea0SLionel Sambuc=item B<rsa_keygen_bits:numbits> 99*ebfedea0SLionel Sambuc 100*ebfedea0SLionel SambucThe number of bits in the generated key. If not specified 1024 is used. 101*ebfedea0SLionel Sambuc 102*ebfedea0SLionel Sambuc=item B<rsa_keygen_pubexp:value> 103*ebfedea0SLionel Sambuc 104*ebfedea0SLionel SambucThe RSA public exponent value. This can be a large decimal or 105*ebfedea0SLionel Sambuchexadecimal value if preceded by B<0x>. Default value is 65537. 106*ebfedea0SLionel Sambuc 107*ebfedea0SLionel Sambuc=back 108*ebfedea0SLionel Sambuc 109*ebfedea0SLionel Sambuc=head1 DSA PARAMETER GENERATION OPTIONS 110*ebfedea0SLionel Sambuc 111*ebfedea0SLionel Sambuc=over 4 112*ebfedea0SLionel Sambuc 113*ebfedea0SLionel Sambuc=item B<dsa_paramgen_bits:numbits> 114*ebfedea0SLionel Sambuc 115*ebfedea0SLionel SambucThe number of bits in the generated parameters. If not specified 1024 is used. 116*ebfedea0SLionel Sambuc 117*ebfedea0SLionel Sambuc=back 118*ebfedea0SLionel Sambuc 119*ebfedea0SLionel Sambuc=head1 DH PARAMETER GENERATION OPTIONS 120*ebfedea0SLionel Sambuc 121*ebfedea0SLionel Sambuc=over 4 122*ebfedea0SLionel Sambuc 123*ebfedea0SLionel Sambuc=item B<dh_paramgen_prime_len:numbits> 124*ebfedea0SLionel Sambuc 125*ebfedea0SLionel SambucThe number of bits in the prime parameter B<p>. 126*ebfedea0SLionel Sambuc 127*ebfedea0SLionel Sambuc=item B<dh_paramgen_generator:value> 128*ebfedea0SLionel Sambuc 129*ebfedea0SLionel SambucThe value to use for the generator B<g>. 130*ebfedea0SLionel Sambuc 131*ebfedea0SLionel Sambuc=back 132*ebfedea0SLionel Sambuc 133*ebfedea0SLionel Sambuc=head1 EC PARAMETER GENERATION OPTIONS 134*ebfedea0SLionel Sambuc 135*ebfedea0SLionel Sambuc=over 4 136*ebfedea0SLionel Sambuc 137*ebfedea0SLionel Sambuc=item B<ec_paramgen_curve:curve> 138*ebfedea0SLionel Sambuc 139*ebfedea0SLionel Sambucthe EC curve to use. 140*ebfedea0SLionel Sambuc 141*ebfedea0SLionel Sambuc=back 142*ebfedea0SLionel Sambuc 143*ebfedea0SLionel Sambuc=head1 GOST2001 KEY GENERATION AND PARAMETER OPTIONS 144*ebfedea0SLionel Sambuc 145*ebfedea0SLionel SambucGost 2001 support is not enabled by default. To enable this algorithm, 146*ebfedea0SLionel Sambucone should load the ccgost engine in the OpenSSL configuration file. 147*ebfedea0SLionel SambucSee README.gost file in the engines/ccgost directiry of the source 148*ebfedea0SLionel Sambucdistribution for more details. 149*ebfedea0SLionel Sambuc 150*ebfedea0SLionel SambucUse of a parameter file for the GOST R 34.10 algorithm is optional. 151*ebfedea0SLionel SambucParameters can be specified during key generation directly as well as 152*ebfedea0SLionel Sambucduring generation of parameter file. 153*ebfedea0SLionel Sambuc 154*ebfedea0SLionel Sambuc=over 4 155*ebfedea0SLionel Sambuc 156*ebfedea0SLionel Sambuc=item B<paramset:name> 157*ebfedea0SLionel Sambuc 158*ebfedea0SLionel SambucSpecifies GOST R 34.10-2001 parameter set according to RFC 4357. 159*ebfedea0SLionel SambucParameter set can be specified using abbreviated name, object short name or 160*ebfedea0SLionel Sambucnumeric OID. Following parameter sets are supported: 161*ebfedea0SLionel Sambuc 162*ebfedea0SLionel Sambuc paramset OID Usage 163*ebfedea0SLionel Sambuc A 1.2.643.2.2.35.1 Signature 164*ebfedea0SLionel Sambuc B 1.2.643.2.2.35.2 Signature 165*ebfedea0SLionel Sambuc C 1.2.643.2.2.35.3 Signature 166*ebfedea0SLionel Sambuc XA 1.2.643.2.2.36.0 Key exchange 167*ebfedea0SLionel Sambuc XB 1.2.643.2.2.36.1 Key exchange 168*ebfedea0SLionel Sambuc test 1.2.643.2.2.35.0 Test purposes 169*ebfedea0SLionel Sambuc 170*ebfedea0SLionel Sambuc=back 171*ebfedea0SLionel Sambuc 172*ebfedea0SLionel Sambuc 173*ebfedea0SLionel Sambuc 174*ebfedea0SLionel Sambuc=head1 NOTES 175*ebfedea0SLionel Sambuc 176*ebfedea0SLionel SambucThe use of the genpkey program is encouraged over the algorithm specific 177*ebfedea0SLionel Sambucutilities because additional algorithm options and ENGINE provided algorithms 178*ebfedea0SLionel Sambuccan be used. 179*ebfedea0SLionel Sambuc 180*ebfedea0SLionel Sambuc=head1 EXAMPLES 181*ebfedea0SLionel Sambuc 182*ebfedea0SLionel SambucGenerate an RSA private key using default parameters: 183*ebfedea0SLionel Sambuc 184*ebfedea0SLionel Sambuc openssl genpkey -algorithm RSA -out key.pem 185*ebfedea0SLionel Sambuc 186*ebfedea0SLionel SambucEncrypt output private key using 128 bit AES and the passphrase "hello": 187*ebfedea0SLionel Sambuc 188*ebfedea0SLionel Sambuc openssl genpkey -algorithm RSA -out key.pem -aes-128-cbc -pass pass:hello 189*ebfedea0SLionel Sambuc 190*ebfedea0SLionel SambucGenerate a 2048 bit RSA key using 3 as the public exponent: 191*ebfedea0SLionel Sambuc 192*ebfedea0SLionel Sambuc openssl genpkey -algorithm RSA -out key.pem -pkeyopt rsa_keygen_bits:2048 \ 193*ebfedea0SLionel Sambuc -pkeyopt rsa_keygen_pubexp:3 194*ebfedea0SLionel Sambuc 195*ebfedea0SLionel SambucGenerate 1024 bit DSA parameters: 196*ebfedea0SLionel Sambuc 197*ebfedea0SLionel Sambuc openssl genpkey -genparam -algorithm DSA -out dsap.pem \ 198*ebfedea0SLionel Sambuc -pkeyopt dsa_paramgen_bits:1024 199*ebfedea0SLionel Sambuc 200*ebfedea0SLionel SambucGenerate DSA key from parameters: 201*ebfedea0SLionel Sambuc 202*ebfedea0SLionel Sambuc openssl genpkey -paramfile dsap.pem -out dsakey.pem 203*ebfedea0SLionel Sambuc 204*ebfedea0SLionel SambucGenerate 1024 bit DH parameters: 205*ebfedea0SLionel Sambuc 206*ebfedea0SLionel Sambuc openssl genpkey -genparam -algorithm DH -out dhp.pem \ 207*ebfedea0SLionel Sambuc -pkeyopt dh_paramgen_prime_len:1024 208*ebfedea0SLionel Sambuc 209*ebfedea0SLionel SambucGenerate DH key from parameters: 210*ebfedea0SLionel Sambuc 211*ebfedea0SLionel Sambuc openssl genpkey -paramfile dhp.pem -out dhkey.pem 212*ebfedea0SLionel Sambuc 213*ebfedea0SLionel Sambuc 214*ebfedea0SLionel Sambuc=cut 215*ebfedea0SLionel Sambuc 216