1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =begin comment 4 1.1 christos {- join("\n", @autowarntext) -} 5 1.1 christos 6 1.1 christos =end comment 7 1.1 christos 8 1.1 christos =head1 NAME 9 1.1 christos 10 1.1 christos openssl-pkey - public or private key processing command 11 1.1 christos 12 1.1 christos =head1 SYNOPSIS 13 1.1 christos 14 1.1 christos B<openssl> B<pkey> 15 1.1 christos [B<-help>] 16 1.1 christos {- $OpenSSL::safe::opt_engine_synopsis -}{- $OpenSSL::safe::opt_provider_synopsis -} 17 1.1 christos [B<-check>] 18 1.1 christos [B<-pubcheck>] 19 1.1 christos [B<-in> I<filename>|I<uri>] 20 1.1 christos [B<-inform> B<DER>|B<PEM>|B<P12>|B<ENGINE>] 21 1.1 christos [B<-passin> I<arg>] 22 1.1 christos [B<-pubin>] 23 1.1 christos [B<-out> I<filename>] 24 1.1 christos [B<-outform> B<DER>|B<PEM>] 25 1.1 christos [B<-I<cipher>>] 26 1.1 christos [B<-passout> I<arg>] 27 1.1 christos [B<-traditional>] 28 1.1 christos [B<-pubout>] 29 1.1 christos [B<-noout>] 30 1.1 christos [B<-text>] 31 1.1 christos [B<-text_pub>] 32 1.1 christos [B<-ec_conv_form> I<arg>] 33 1.1 christos [B<-ec_param_enc> I<arg>] 34 1.1 christos 35 1.1 christos =head1 DESCRIPTION 36 1.1 christos 37 1.1 christos This command processes public or private keys. They can be 38 1.1 christos converted between various forms and their components printed. 39 1.1 christos 40 1.1 christos =head1 OPTIONS 41 1.1 christos 42 1.1 christos =head2 General options 43 1.1 christos 44 1.1 christos =over 4 45 1.1 christos 46 1.1 christos =item B<-help> 47 1.1 christos 48 1.1 christos Print out a usage message. 49 1.1 christos 50 1.1 christos {- $OpenSSL::safe::opt_engine_item -} 51 1.1 christos 52 1.1 christos {- $OpenSSL::safe::opt_provider_item -} 53 1.1 christos 54 1.1 christos =item B<-check> 55 1.1 christos 56 1.1 christos This option checks the consistency of a key pair for both public and private 57 1.1 christos components. 58 1.1 christos 59 1.1 christos =item B<-pubcheck> 60 1.1 christos 61 1.1 christos This option checks the correctness of either a public key 62 1.1 christos or the public component of a key pair. 63 1.1 christos 64 1.1 christos =back 65 1.1 christos 66 1.1 christos =head2 Input options 67 1.1 christos 68 1.1 christos =over 4 69 1.1 christos 70 1.1 christos =item B<-in> I<filename>|I<uri> 71 1.1 christos 72 1.1 christos This specifies the input file to read a key from 73 1.1 christos or standard input if this option is not specified. 74 1.1 christos 75 1.1 christos If the key input is encrypted and B<-passin> is not given 76 1.1 christos a pass phrase will be prompted for. 77 1.1 christos 78 1.1 christos =item B<-inform> B<DER>|B<PEM>|B<P12>|B<ENGINE> 79 1.1 christos 80 1.1 christos The key input format; unspecified by default. 81 1.1 christos See L<openssl-format-options(1)> for details. 82 1.1 christos 83 1.1 christos =item B<-passin> I<arg> 84 1.1 christos 85 1.1 christos The password source for the key input. 86 1.1 christos 87 1.1 christos For more information about the format of B<arg> 88 1.1 christos see L<openssl-passphrase-options(1)>. 89 1.1 christos 90 1.1 christos =item B<-pubin> 91 1.1 christos 92 1.1 christos By default a private key is read from the input. 93 1.1 christos With this option a public key is read instead. 94 1.1 christos If the input contains no public key but a private key, its public part is used. 95 1.1 christos 96 1.1 christos =back 97 1.1 christos 98 1.1 christos =head2 Output options 99 1.1 christos 100 1.1 christos =over 4 101 1.1 christos 102 1.1 christos =item B<-out> I<filename> 103 1.1 christos 104 1.1 christos This specifies the output file to save the encoded and/or text output of key 105 1.1 christos or standard output if this option is not specified. 106 1.1 christos The output filename can be the same as the input filename, 107 1.1 christos which leads to replacing the file contents. 108 1.1 christos Note that file I/O is not atomic. The output file is truncated and then written. 109 1.1 christos 110 1.1 christos If any cipher option is set but no B<-passout> is given 111 1.1 christos then a pass phrase will be prompted for. 112 1.1 christos When password input is interrupted, the output file is not touched. 113 1.1 christos 114 1.1 christos =item B<-outform> B<DER>|B<PEM> 115 1.1 christos 116 1.1 christos The key output format; the default is B<PEM>. 117 1.1 christos See L<openssl-format-options(1)> for details. 118 1.1 christos 119 1.1 christos =item B<-I<cipher>> 120 1.1 christos 121 1.1 christos Encrypt the PEM encoded private key with the supplied cipher. Any algorithm 122 1.1 christos name accepted by EVP_get_cipherbyname() is acceptable such as B<aes128>. 123 1.1 christos Encryption is not supported for DER output. 124 1.1 christos 125 1.1 christos =item B<-passout> I<arg> 126 1.1 christos 127 1.1 christos The password source for the output file. 128 1.1 christos 129 1.1 christos For more information about the format of B<arg> 130 1.1 christos see L<openssl-passphrase-options(1)>. 131 1.1 christos 132 1.1 christos =item B<-traditional> 133 1.1 christos 134 1.1 christos Normally a private key is written using standard format: this is PKCS#8 form 135 1.1 christos with the appropriate encryption algorithm (if any). If the B<-traditional> 136 1.1 christos option is specified then the older "traditional" format is used instead. 137 1.1 christos 138 1.1 christos =item B<-pubout> 139 1.1 christos 140 1.1 christos By default the private and public key is output; 141 1.1 christos this option restricts the output to the public components. 142 1.1 christos This option is automatically set if the input is a public key. 143 1.1 christos 144 1.1 christos When combined with B<-text>, this is equivalent to B<-text_pub>. 145 1.1 christos 146 1.1 christos =item B<-noout> 147 1.1 christos 148 1.1 christos Do not output the key in encoded form. 149 1.1 christos 150 1.1 christos =item B<-text> 151 1.1 christos 152 1.1 christos Output the various key components in plain text 153 1.1 christos (possibly in addition to the PEM encoded form). 154 1.1 christos This cannot be combined with encoded output in DER format. 155 1.1 christos 156 1.1 christos =item B<-text_pub> 157 1.1 christos 158 1.1 christos Output in text form only the public key components (also for private keys). 159 1.1 christos This cannot be combined with encoded output in DER format. 160 1.1 christos 161 1.1 christos =item B<-ec_conv_form> I<arg> 162 1.1 christos 163 1.1 christos This option only applies to elliptic-curve based keys. 164 1.1 christos 165 1.1 christos This specifies how the points on the elliptic curve are converted 166 1.1 christos into octet strings. Possible values are: B<compressed> (the default 167 1.1 christos value), B<uncompressed> and B<hybrid>. For more information regarding 168 1.1 christos the point conversion forms please read the X9.62 standard. 169 1.1 christos B<Note> Due to patent issues the B<compressed> option is disabled 170 1.1 christos by default for binary curves and can be enabled by defining 171 1.1 christos the preprocessor macro B<OPENSSL_EC_BIN_PT_COMP> at compile time. 172 1.1 christos 173 1.1 christos =item B<-ec_param_enc> I<arg> 174 1.1 christos 175 1.1 christos This option only applies to elliptic curve based public and private keys. 176 1.1 christos 177 1.1 christos This specifies how the elliptic curve parameters are encoded. 178 1.1 christos Possible value are: B<named_curve>, i.e. the ec parameters are 179 1.1 christos specified by an OID, or B<explicit> where the ec parameters are 180 1.1 christos explicitly given (see RFC 3279 for the definition of the 181 1.1 christos EC parameters structures). The default value is B<named_curve>. 182 1.1 christos B<Note> the B<implicitlyCA> alternative, as specified in RFC 3279, 183 1.1 christos is currently not implemented in OpenSSL. 184 1.1 christos 185 1.1 christos =back 186 1.1 christos 187 1.1 christos =head1 EXAMPLES 188 1.1 christos 189 1.1 christos To remove the pass phrase on a private key: 190 1.1 christos 191 1.1 christos openssl pkey -in key.pem -out keyout.pem 192 1.1 christos 193 1.1 christos To encrypt a private key using triple DES: 194 1.1 christos 195 1.1 christos openssl pkey -in key.pem -des3 -out keyout.pem 196 1.1 christos 197 1.1 christos To convert a private key from PEM to DER format: 198 1.1 christos 199 1.1 christos openssl pkey -in key.pem -outform DER -out keyout.der 200 1.1 christos 201 1.1 christos To print out the components of a private key to standard output: 202 1.1 christos 203 1.1 christos openssl pkey -in key.pem -text -noout 204 1.1 christos 205 1.1 christos To print out the public components of a private key to standard output: 206 1.1 christos 207 1.1 christos openssl pkey -in key.pem -text_pub -noout 208 1.1 christos 209 1.1 christos To just output the public part of a private key: 210 1.1 christos 211 1.1 christos openssl pkey -in key.pem -pubout -out pubkey.pem 212 1.1 christos 213 1.1 christos To change the EC parameters encoding to B<explicit>: 214 1.1 christos 215 1.1 christos openssl pkey -in key.pem -ec_param_enc explicit -out keyout.pem 216 1.1 christos 217 1.1 christos To change the EC point conversion form to B<compressed>: 218 1.1 christos 219 1.1 christos openssl pkey -in key.pem -ec_conv_form compressed -out keyout.pem 220 1.1 christos 221 1.1 christos =head1 SEE ALSO 222 1.1 christos 223 1.1 christos L<openssl(1)>, 224 1.1 christos L<openssl-genpkey(1)>, 225 1.1 christos L<openssl-rsa(1)>, 226 1.1 christos L<openssl-pkcs8(1)>, 227 1.1 christos L<openssl-dsa(1)>, 228 1.1 christos L<openssl-genrsa(1)>, 229 1.1 christos L<openssl-gendsa(1)> 230 1.1 christos 231 1.1 christos =head1 HISTORY 232 1.1 christos 233 1.1 christos The B<-engine> option was deprecated in OpenSSL 3.0. 234 1.1 christos 235 1.1 christos =head1 COPYRIGHT 236 1.1 christos 237 1.1 christos Copyright 2006-2023 The OpenSSL Project Authors. All Rights Reserved. 238 1.1 christos 239 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 240 1.1 christos this file except in compliance with the License. You can obtain a copy 241 1.1 christos in the file LICENSE in the source distribution or at 242 1.1 christos L<https://www.openssl.org/source/license.html>. 243 1.1 christos 244 1.1 christos =cut 245