网络知识 娱乐 跟老韩学Ubuntu Server 2204-openssl-genpkey帮助手册

跟老韩学Ubuntu Server 2204-openssl-genpkey帮助手册

跟老韩学Ubuntu Server 2204-openssl-genpkey帮助手册

跟老韩学Linux SRE

风,带走的,是我不变的心。

root@hanyw:~# man openssl-genpkey |grep -Ev "^$"nOPENSSL-GENPKEY(1SSL) OpenSSL OPENSSL-GENPKEY(1SSL)nNAMEn openssl-genpkey - generate a private keynSYNOPSISn openssl genpkey [-help] [-out filename] [-outform DER|PEM] [-quiet] [-pass arg] [-cipher] [-paramfile file] [-algorithmn alg] [-pkeyopt opt:value] [-genparam] [-text] [-engine id] [-provider name] [-provider-path path] [-propquery propq]n [-config configfile]nDESCRIPTIONn This command generates a private key.nOPTIONSn -helpn Print out a usage message.n -out filenamen Output the key to the specified file. If this argument is not specified then standard output is used.n -outform DER|PEMn The output format, except when -genparam is given; the default is PEM. See openssl-format-options(1) for details.n When -genparam is given, -outform is ignored.n -quietn Do not output "status dots" while generating keys.n -pass argn The output file password source. For more information about the format of arg see openssl-passphrase-options(1).n -ciphern This option encrypts the private key with the supplied cipher. Any algorithm name accepted by EVP_get_cipherbyname()n is acceptable such as des3.n -algorithm algn Public key algorithm to use such as RSA, DSA, DH or DHX. If used this option must precede any -pkeyopt options. Then options -paramfile and -algorithm are mutually exclusive. Engines may add algorithms in addition to the standardn built-in ones.n Valid built-in algorithm names for private key generation are RSA, RSA-PSS, EC, X25519, X448, ED25519 and ED448.n Valid built-in algorithm names for parameter generation (see the -genparam option) are DH, DSA and EC.n Note that the algorithm name X9.42 DH may be used as a synonym for DHX keys and PKCS#3 refers to DH Keys. Somen options are not shared between DH and DHX keys.n -pkeyopt opt:valuen Set the public key algorithm option opt to value. The precise set of options supported depends on the public keyn algorithm used and its implementation. See "KEY GENERATION OPTIONS" and "PARAMETER GENERATION OPTIONS" below forn more details.n -genparamn Generate a set of parameters instead of a private key. If used this option must precede any -algorithm, -paramfilen or -pkeyopt options.n -paramfile filenamen Some public key algorithms generate a private key based on a set of parameters. They can be supplied using thisn option. If this option is used the public key algorithm used is determined by the parameters. If used this optionn must precede any -pkeyopt options. The options -paramfile and -algorithm are mutually exclusive.n -textn Print an (unencrypted) text representation of private and public keys and parameters along with the PEM or DERn structure.n -engine idn See "Engine Options" in openssl(1). This option is deprecated.n -provider namen -provider-path pathn -propquery propqn See "Provider Options" in openssl(1), provider(7), and property(7).n -config configfilen See "Configuration Option" in openssl(1).nKEY GENERATION OPTIONSn The options supported by each algorithm and indeed each implementation of an algorithm can vary. The options for then OpenSSL implementations are detailed below. There are no key generation options defined for the X25519, X448, ED25519 orn ED448 algorithms.n RSA Key Generation Optionsn rsa_keygen_bits:numbitsn The number of bits in the generated key. If not specified 2048 is used.n rsa_keygen_primes:numprimesn The number of primes in the generated key. If not specified 2 is used.n rsa_keygen_pubexp:valuen The RSA public exponent value. This can be a large decimal or hexadecimal value if preceded by "0x". Default valuen is 65537.n RSA-PSS Key Generation Optionsn Note: by default an RSA-PSS key has no parameter restrictions.n rsa_keygen_bits:numbits, rsa_keygen_primes:numprimes, rsa_keygen_pubexp:valuen These options have the same meaning as the RSA algorithm.n rsa_pss_keygen_md:digestn If set the key is restricted and can only use digest for signing.n rsa_pss_keygen_mgf1_md:digestn If set the key is restricted and can only use digest as it's MGF1 parameter.n rsa_pss_keygen_saltlen:lenn If set the key is restricted and len specifies the minimum salt length.n EC Key Generation Optionsn The EC key generation options can also be used for parameter generation.n ec_paramgen_curve:curven The EC curve to use. OpenSSL supports NIST curve names such as "P-256".n ec_param_enc:encodingn The encoding to use for parameters. The encoding parameter must be either named_curve or explicit. The default valuen is named_curve.n DH Key Generation Optionsn group:namen The paramfile option is not required if a named group is used here. See the "DH Parameter Generation Options"n section below.nPARAMETER GENERATION OPTIONSn The options supported by each algorithm and indeed each implementation of an algorithm can vary. The options for then OpenSSL implementations are detailed below.n DSA Parameter Generation Optionsn dsa_paramgen_bits:numbitsn The number of bits in the generated prime. If not specified 2048 is used.n dsa_paramgen_q_bits:numbitsn qbits:numbitsn The number of bits in the q parameter. Must be one of 160, 224 or 256. If not specified 224 is used.n dsa_paramgen_md:digestn digest:digestn The digest to use during parameter generation. Must be one of sha1, sha224 or sha256. If set, then the number ofn bits in q will match the output size of the specified digest and the dsa_paramgen_q_bits parameter will be ignored.n If not set, then a digest will be used that gives an output matching the number of bits in q, i.e. sha1 if q lengthn is 160, sha224 if it 224 or sha256 if it is 256.n properties:queryn The digest property query string to use when fetching a digest from a provider.n type:typen The type of generation to use. Set this to 1 to use legacy FIPS186-2 parameter generation. The default of 0 usesn FIPS186-4 parameter generation.n gindex:indexn The index to use for canonical generation and verification of the generator g. Set this to a positive value rangingn from 0..255 to use this mode. Larger values will only use the bottom byte. This index must then be reused duringn key validation to verify the value of g. If this value is not set then g is not verifiable. The default value isn -1.n hexseed:seedn The seed seed data to use instead of generating a random seed internally. This should be used for testing purposesn only. This will either produced fixed values for the generated parameters OR it will fail if the seed did notn generate valid primes.n DH Parameter Generation Optionsn For most use cases it is recommended to use the group option rather than the type options. Note that the group option isn not used by default if no parameter generation options are specified.n group:namen dh_param:namen Use a named DH group to select constant values for the DH parameters. All other options will be ignored if thisn value is set.n Valid values that are associated with the algorithm of "DH" are: "ffdhe2048", "ffdhe3072", "ffdhe4096", "ffdhe6144",n "ffdhe8192", "modp_1536", "modp_2048", "modp_3072", "modp_4096", "modp_6144", "modp_8192".n Valid values that are associated with the algorithm of "DHX" are the RFC5114 names "dh_1024_160", "dh_2048_224",n "dh_2048_256".n dh_rfc5114:numn If this option is set, then the appropriate RFC5114 parameters are used instead of generating new parameters. Then value num can be one of 1, 2 or 3 that are equivalant to using the option group with one of "dh_1024_160",n "dh_2048_224" or "dh_2048_256". All other options will be ignored if this value is set.n pbits:numbitsn dh_paramgen_prime_len:numbitsn The number of bits in the prime parameter p. The default is 2048.n qbits:numbitsn dh_paramgen_subprime_len:numbitsn The number of bits in the sub prime parameter q. The default is 224. Only relevant if used in conjunction with then dh_paramgen_type option to generate DHX parameters.n safeprime-generator:valuen dh_paramgen_generator:valuen The value to use for the generator g. The default is 2. The algorithm option must be "DH" for this parameter to ben used.n type:stringn The type name of DH parameters to generate. Valid values are:n "generator"n Use a safe prime generator with the option safeprime_generator The algorithm option must be "DH".n "fips186_4"n FIPS186-4 parameter generation. The algorithm option must be "DHX".n "fips186_2"n FIPS186-4 parameter generation. The algorithm option must be "DHX".n "group"n Can be used with the option pbits to select one of "ffdhe2048", "ffdhe3072", "ffdhe4096", "ffdhe6144" orn "ffdhe8192". The algorithm option must be "DH".n "default"n Selects a default type based on the algorithm. This is used by the OpenSSL default provider to set the type forn backwards compatability. If algorithm is "DH" then "generator" is used. If algorithm is "DHX" then "fips186_2"n is used.n dh_paramgen_type:valuen The type of DH parameters to generate. Valid values are 0, 1, 2 or 3 which correspond to setting the option type ton "generator", "fips186_2", "fips186_4" or "group".n digest:digestn The digest to use during parameter generation. Must be one of sha1, sha224 or sha256. If set, then the number ofn bits in qbits will match the output size of the specified digest and the qbits parameter will be ignored. If notn set, then a digest will be used that gives an output matching the number of bits in q, i.e. sha1 if q length is 160,n sha224 if it is 224 or sha256 if it is 256. This is only used by "fips186_4" and "fips186_2" key generation.n properties:queryn The digest property query string to use when fetching a digest from a provider. This is only used by "fips186_4"n and "fips186_2" key generation.n gindex:indexn The index to use for canonical generation and verification of the generator g. Set this to a positive value rangingn from 0..255 to use this mode. Larger values will only use the bottom byte. This index must then be reused duringn key validation to verify the value of g. If this value is not set then g is not verifiable. The default value isn -1. This is only used by "fips186_4" and "fips186_2" key generation.n hexseed:seedn The seed seed data to use instead of generating a random seed internally. This should be used for testing purposesn only. This will either produced fixed values for the generated parameters OR it will fail if the seed did notn generate valid primes. This is only used by "fips186_4" and "fips186_2" key generation.n EC Parameter Generation Optionsn The EC parameter generation options are the same as for key generation. See "EC Key Generation Options" above.nNOTESn The use of the genpkey program is encouraged over the algorithm specific utilities because additional algorithm optionsn and ENGINE provided algorithms can be used.nEXAMPLESn Generate an RSA private key using default parameters:n openssl genpkey -algorithm RSA -out key.pemn Encrypt output private key using 128 bit AES and the passphrase "hello":n openssl genpkey -algorithm RSA -out key.pem -aes-128-cbc -pass pass:hellon Generate a 2048 bit RSA key using 3 as the public exponent:n openssl genpkey -algorithm RSA -out key.pem n -pkeyopt rsa_keygen_bits:2048 -pkeyopt rsa_keygen_pubexp:3n Generate 2048 bit DSA parameters that can be validated: The output values for gindex and seed are required for keyn validation purposes and are not saved to the output pem file).n openssl genpkey -genparam -algorithm DSA -out dsap.pem -pkeyopt pbits:2048 n -pkeyopt qbits:224 -pkeyopt digest:SHA256 -pkeyopt gindex:1 -textn Generate DSA key from parameters:n openssl genpkey -paramfile dsap.pem -out dsakey.pemn Generate 4096 bit DH Key using safe prime group ffdhe4096:n openssl genpkey -algorithm DH -out dhkey.pem -pkeyopt group:ffdhe4096n Generate 2048 bit X9.42 DH key with 256 bit subgroup using RFC5114 group3:n openssl genpkey -algorithm DHX -out dhkey.pem -pkeyopt dh_rfc5114:3n Generate a DH key using a DH parameters file:n openssl genpkey -paramfile dhp.pem -out dhkey.pemn Output DH parameters for safe prime group ffdhe2048:n openssl genpkey -genparam -algorithm DH -out dhp.pem -pkeyopt group:ffdhe2048n Output 2048 bit X9.42 DH parameters with 224 bit subgroup using RFC5114 group2:n openssl genpkey -genparam -algorithm DHX -out dhp.pem -pkeyopt dh_rfc5114:2n Output 2048 bit X9.42 DH parameters with 224 bit subgroup using FIP186-4 keygen:n openssl genpkey -genparam -algorithm DHX -out dhp.pem -text n -pkeyopt pbits:2048 -pkeyopt qbits:224 -pkeyopt digest:SHA256 n -pkeyopt gindex:1 -pkeyopt dh_paramgen_type:2n Output 1024 bit X9.42 DH parameters with 160 bit subgroup using FIP186-2 keygen:n openssl genpkey -genparam -algorithm DHX -out dhp.pem -text n -pkeyopt pbits:1024 -pkeyopt qbits:160 -pkeyopt digest:SHA1 n -pkeyopt gindex:1 -pkeyopt dh_paramgen_type:1n Output 2048 bit DH parameters:n openssl genpkey -genparam -algorithm DH -out dhp.pem n -pkeyopt dh_paramgen_prime_len:2048n Output 2048 bit DH parameters using a generator:n openssl genpkey -genparam -algorithm DH -out dhpx.pem n -pkeyopt dh_paramgen_prime_len:2048 n -pkeyopt dh_paramgen_type:1n Generate EC parameters:n openssl genpkey -genparam -algorithm EC -out ecp.pem n -pkeyopt ec_paramgen_curve:secp384r1 n -pkeyopt ec_param_enc:named_curven Generate EC key from parameters:n openssl genpkey -paramfile ecp.pem -out eckey.pemn Generate EC key directly:n openssl genpkey -algorithm EC -out eckey.pem n -pkeyopt ec_paramgen_curve:P-384 n -pkeyopt ec_param_enc:named_curven Generate an X25519 private key:n openssl genpkey -algorithm X25519 -out xkey.pemn Generate an ED448 private key:n openssl genpkey -algorithm ED448 -out xkey.pemnHISTORYn The ability to use NIST curve names, and to generate an EC key directly, were added in OpenSSL 1.0.2. The ability ton generate X25519 keys was added in OpenSSL 1.1.0. The ability to generate X448, ED25519 and ED448 keys was added inn OpenSSL 1.1.1.n The -engine option was deprecated in OpenSSL 3.0.nCOPYRIGHTn Copyright 2006-2021 The OpenSSL Project Authors. All Rights Reserved.n Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License.n You can obtain a copy in the file LICENSE in the source distribution or atn <https://www.openssl.org/source/license.html>.n3.0.2 2022-07-04 OPENSSL-GENPKEY(1SSL)