1b077aed3SPierre Pronchery=pod 2b077aed3SPierre Pronchery{- OpenSSL::safe::output_do_not_edit_headers(); -} 3b077aed3SPierre Pronchery 4b077aed3SPierre Pronchery=head1 NAME 5b077aed3SPierre Pronchery 6b077aed3SPierre Proncheryopenssl-pkeyutl - public key algorithm command 7b077aed3SPierre Pronchery 8b077aed3SPierre Pronchery=head1 SYNOPSIS 9b077aed3SPierre Pronchery 10b077aed3SPierre ProncheryB<openssl> B<pkeyutl> 11b077aed3SPierre Pronchery[B<-help>] 12b077aed3SPierre Pronchery[B<-in> I<file>] 13b077aed3SPierre Pronchery[B<-rawin>] 14b077aed3SPierre Pronchery[B<-digest> I<algorithm>] 15b077aed3SPierre Pronchery[B<-out> I<file>] 16b077aed3SPierre Pronchery[B<-sigfile> I<file>] 17b077aed3SPierre Pronchery[B<-inkey> I<filename>|I<uri>] 18b077aed3SPierre Pronchery[B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE>] 19b077aed3SPierre Pronchery[B<-passin> I<arg>] 20b077aed3SPierre Pronchery[B<-peerkey> I<file>] 21b077aed3SPierre Pronchery[B<-peerform> B<DER>|B<PEM>|B<P12>|B<ENGINE>] 22b077aed3SPierre Pronchery[B<-pubin>] 23b077aed3SPierre Pronchery[B<-certin>] 24b077aed3SPierre Pronchery[B<-rev>] 25b077aed3SPierre Pronchery[B<-sign>] 26b077aed3SPierre Pronchery[B<-verify>] 27b077aed3SPierre Pronchery[B<-verifyrecover>] 28b077aed3SPierre Pronchery[B<-encrypt>] 29b077aed3SPierre Pronchery[B<-decrypt>] 30b077aed3SPierre Pronchery[B<-derive>] 31b077aed3SPierre Pronchery[B<-kdf> I<algorithm>] 32b077aed3SPierre Pronchery[B<-kdflen> I<length>] 33b077aed3SPierre Pronchery[B<-pkeyopt> I<opt>:I<value>] 34b077aed3SPierre Pronchery[B<-pkeyopt_passin> I<opt>[:I<passarg>]] 35b077aed3SPierre Pronchery[B<-hexdump>] 36b077aed3SPierre Pronchery[B<-asn1parse>] 37b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_engine_synopsis -}[B<-engine_impl>] 38b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_r_synopsis -} 39b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_provider_synopsis -} 40b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_config_synopsis -} 41b077aed3SPierre Pronchery 42b077aed3SPierre Pronchery=head1 DESCRIPTION 43b077aed3SPierre Pronchery 44b077aed3SPierre ProncheryThis command can be used to perform low-level public key 45b077aed3SPierre Proncheryoperations using any supported algorithm. 46b077aed3SPierre Pronchery 47b077aed3SPierre Pronchery=head1 OPTIONS 48b077aed3SPierre Pronchery 49b077aed3SPierre Pronchery=over 4 50b077aed3SPierre Pronchery 51b077aed3SPierre Pronchery=item B<-help> 52b077aed3SPierre Pronchery 53b077aed3SPierre ProncheryPrint out a usage message. 54b077aed3SPierre Pronchery 55b077aed3SPierre Pronchery=item B<-in> I<filename> 56b077aed3SPierre Pronchery 57b077aed3SPierre ProncheryThis specifies the input filename to read data from or standard input 58b077aed3SPierre Proncheryif this option is not specified. 59b077aed3SPierre Pronchery 60b077aed3SPierre Pronchery=item B<-rawin> 61b077aed3SPierre Pronchery 62b077aed3SPierre ProncheryThis indicates that the input data is raw data, which is not hashed by any 63b077aed3SPierre Proncherymessage digest algorithm. The user can specify a digest algorithm by using 64b077aed3SPierre Proncherythe B<-digest> option. This option can only be used with B<-sign> and 65b077aed3SPierre ProncheryB<-verify> and must be used with the Ed25519 and Ed448 algorithms. 66b077aed3SPierre Pronchery 67b077aed3SPierre Pronchery=item B<-digest> I<algorithm> 68b077aed3SPierre Pronchery 69b077aed3SPierre ProncheryThis specifies the digest algorithm which is used to hash the input data before 70b077aed3SPierre Proncherysigning or verifying it with the input key. This option could be omitted if the 71b077aed3SPierre Proncherysignature algorithm does not require one (for instance, EdDSA). If this option 72b077aed3SPierre Proncheryis omitted but the signature algorithm requires one, a default value will be 73b077aed3SPierre Proncheryused. For signature algorithms like RSA, DSA and ECDSA, SHA-256 will be the 74b077aed3SPierre Proncherydefault digest algorithm. For SM2, it will be SM3. If this option is present, 75b077aed3SPierre Proncherythen the B<-rawin> option must be also specified. 76b077aed3SPierre Pronchery 77b077aed3SPierre Pronchery=item B<-out> I<filename> 78b077aed3SPierre Pronchery 79b077aed3SPierre ProncherySpecifies the output filename to write to or standard output by 80b077aed3SPierre Proncherydefault. 81b077aed3SPierre Pronchery 82b077aed3SPierre Pronchery=item B<-sigfile> I<file> 83b077aed3SPierre Pronchery 84b077aed3SPierre ProncherySignature file, required for B<-verify> operations only 85b077aed3SPierre Pronchery 86b077aed3SPierre Pronchery=item B<-inkey> I<filename>|I<uri> 87b077aed3SPierre Pronchery 88b077aed3SPierre ProncheryThe input key, by default it should be a private key. 89b077aed3SPierre Pronchery 90b077aed3SPierre Pronchery=item B<-keyform> B<DER>|B<PEM>|B<P12>|B<ENGINE> 91b077aed3SPierre Pronchery 92b077aed3SPierre ProncheryThe key format; unspecified by default. 93b077aed3SPierre ProncherySee L<openssl-format-options(1)> for details. 94b077aed3SPierre Pronchery 95b077aed3SPierre Pronchery=item B<-passin> I<arg> 96b077aed3SPierre Pronchery 97b077aed3SPierre ProncheryThe input key password source. For more information about the format of I<arg> 98b077aed3SPierre Proncherysee L<openssl-passphrase-options(1)>. 99b077aed3SPierre Pronchery 100b077aed3SPierre Pronchery=item B<-peerkey> I<file> 101b077aed3SPierre Pronchery 102b077aed3SPierre ProncheryThe peer key file, used by key derivation (agreement) operations. 103b077aed3SPierre Pronchery 104b077aed3SPierre Pronchery=item B<-peerform> B<DER>|B<PEM>|B<P12>|B<ENGINE> 105b077aed3SPierre Pronchery 106b077aed3SPierre ProncheryThe peer key format; unspecified by default. 107b077aed3SPierre ProncherySee L<openssl-format-options(1)> for details. 108b077aed3SPierre Pronchery 109b077aed3SPierre Pronchery=item B<-pubin> 110b077aed3SPierre Pronchery 111b077aed3SPierre ProncheryThe input file is a public key. 112b077aed3SPierre Pronchery 113b077aed3SPierre Pronchery=item B<-certin> 114b077aed3SPierre Pronchery 115b077aed3SPierre ProncheryThe input is a certificate containing a public key. 116b077aed3SPierre Pronchery 117b077aed3SPierre Pronchery=item B<-rev> 118b077aed3SPierre Pronchery 119b077aed3SPierre ProncheryReverse the order of the input buffer. This is useful for some libraries 120b077aed3SPierre Pronchery(such as CryptoAPI) which represent the buffer in little endian format. 121b077aed3SPierre Pronchery 122b077aed3SPierre Pronchery=item B<-sign> 123b077aed3SPierre Pronchery 124b077aed3SPierre ProncherySign the input data (which must be a hash) and output the signed result. This 125b077aed3SPierre Proncheryrequires a private key. 126b077aed3SPierre Pronchery 127b077aed3SPierre Pronchery=item B<-verify> 128b077aed3SPierre Pronchery 129b077aed3SPierre ProncheryVerify the input data (which must be a hash) against the signature file and 130b077aed3SPierre Proncheryindicate if the verification succeeded or failed. 131b077aed3SPierre Pronchery 132b077aed3SPierre Pronchery=item B<-verifyrecover> 133b077aed3SPierre Pronchery 134b077aed3SPierre ProncheryVerify the input data (which must be a hash) and output the recovered data. 135b077aed3SPierre Pronchery 136b077aed3SPierre Pronchery=item B<-encrypt> 137b077aed3SPierre Pronchery 138b077aed3SPierre ProncheryEncrypt the input data using a public key. 139b077aed3SPierre Pronchery 140b077aed3SPierre Pronchery=item B<-decrypt> 141b077aed3SPierre Pronchery 142b077aed3SPierre ProncheryDecrypt the input data using a private key. 143b077aed3SPierre Pronchery 144b077aed3SPierre Pronchery=item B<-derive> 145b077aed3SPierre Pronchery 146b077aed3SPierre ProncheryDerive a shared secret using the peer key. 147b077aed3SPierre Pronchery 148b077aed3SPierre Pronchery=item B<-kdf> I<algorithm> 149b077aed3SPierre Pronchery 150b077aed3SPierre ProncheryUse key derivation function I<algorithm>. The supported algorithms are 151b077aed3SPierre Proncheryat present B<TLS1-PRF> and B<HKDF>. 152b077aed3SPierre ProncheryNote: additional parameters and the KDF output length will normally have to be 153b077aed3SPierre Proncheryset for this to work. 154b077aed3SPierre ProncherySee L<EVP_PKEY_CTX_set_hkdf_md(3)> and L<EVP_PKEY_CTX_set_tls1_prf_md(3)> 155b077aed3SPierre Proncheryfor the supported string parameters of each algorithm. 156b077aed3SPierre Pronchery 157b077aed3SPierre Pronchery=item B<-kdflen> I<length> 158b077aed3SPierre Pronchery 159b077aed3SPierre ProncherySet the output length for KDF. 160b077aed3SPierre Pronchery 161b077aed3SPierre Pronchery=item B<-pkeyopt> I<opt>:I<value> 162b077aed3SPierre Pronchery 163b077aed3SPierre ProncheryPublic key options specified as opt:value. See NOTES below for more details. 164b077aed3SPierre Pronchery 165b077aed3SPierre Pronchery=item B<-pkeyopt_passin> I<opt>[:I<passarg>] 166b077aed3SPierre Pronchery 167b077aed3SPierre ProncheryAllows reading a public key option I<opt> from stdin or a password source. 168b077aed3SPierre ProncheryIf only I<opt> is specified, the user will be prompted to enter a password on 169b077aed3SPierre Proncherystdin. Alternatively, I<passarg> can be specified which can be any value 170b077aed3SPierre Proncherysupported by L<openssl-passphrase-options(1)>. 171b077aed3SPierre Pronchery 172b077aed3SPierre Pronchery=item B<-hexdump> 173b077aed3SPierre Pronchery 174b077aed3SPierre Proncheryhex dump the output data. 175b077aed3SPierre Pronchery 176b077aed3SPierre Pronchery=item B<-asn1parse> 177b077aed3SPierre Pronchery 178b077aed3SPierre ProncheryParse the ASN.1 output data, this is useful when combined with the 179b077aed3SPierre ProncheryB<-verifyrecover> option when an ASN1 structure is signed. 180b077aed3SPierre Pronchery 181b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_engine_item -} 182b077aed3SPierre Pronchery 183b077aed3SPierre Pronchery{- output_off() if $disabled{"deprecated-3.0"}; "" -} 184b077aed3SPierre Pronchery=item B<-engine_impl> 185b077aed3SPierre Pronchery 186b077aed3SPierre ProncheryWhen used with the B<-engine> option, it specifies to also use 187b077aed3SPierre Proncheryengine I<id> for crypto operations. 188b077aed3SPierre Pronchery{- output_on() if $disabled{"deprecated-3.0"}; "" -} 189b077aed3SPierre Pronchery 190b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_r_item -} 191b077aed3SPierre Pronchery 192b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_provider_item -} 193b077aed3SPierre Pronchery 194b077aed3SPierre Pronchery{- $OpenSSL::safe::opt_config_item -} 195b077aed3SPierre Pronchery 196b077aed3SPierre Pronchery=back 197b077aed3SPierre Pronchery 198b077aed3SPierre Pronchery=head1 NOTES 199b077aed3SPierre Pronchery 200b077aed3SPierre ProncheryThe operations and options supported vary according to the key algorithm 201b077aed3SPierre Proncheryand its implementation. The OpenSSL operations and options are indicated below. 202b077aed3SPierre Pronchery 203b077aed3SPierre ProncheryUnless otherwise mentioned all algorithms support the B<digest:>I<alg> option 204b077aed3SPierre Proncherywhich specifies the digest in use for sign, verify and verifyrecover operations. 205b077aed3SPierre ProncheryThe value I<alg> should represent a digest name as used in the 206b077aed3SPierre ProncheryEVP_get_digestbyname() function for example B<sha1>. This value is not used to 207b077aed3SPierre Proncheryhash the input data. It is used (by some algorithms) for sanity-checking the 208b077aed3SPierre Proncherylengths of data passed in and for creating the structures that make up the 209b077aed3SPierre Proncherysignature (e.g. B<DigestInfo> in RSASSA PKCS#1 v1.5 signatures). 210b077aed3SPierre Pronchery 211b077aed3SPierre ProncheryThis command does not hash the input data (except where -rawin is used) but 212b077aed3SPierre Proncheryrather it will use the data directly as input to the signature algorithm. 213b077aed3SPierre ProncheryDepending on the key type, signature type, and mode of padding, the maximum 214b077aed3SPierre Proncheryacceptable lengths of input data differ. The signed data can't be longer than 215b077aed3SPierre Proncherythe key modulus with RSA. In case of ECDSA and DSA the data shouldn't be longer 216b077aed3SPierre Proncherythan the field size, otherwise it will be silently truncated to the field size. 217b077aed3SPierre ProncheryIn any event the input size must not be larger than the largest supported digest 218b077aed3SPierre Proncherysize. 219b077aed3SPierre Pronchery 220b077aed3SPierre ProncheryIn other words, if the value of digest is B<sha1> the input should be the 20 221b077aed3SPierre Proncherybytes long binary encoding of the SHA-1 hash function output. 222b077aed3SPierre Pronchery 223b077aed3SPierre Pronchery=head1 RSA ALGORITHM 224b077aed3SPierre Pronchery 225b077aed3SPierre ProncheryThe RSA algorithm generally supports the encrypt, decrypt, sign, 226b077aed3SPierre Proncheryverify and verifyrecover operations. However, some padding modes 227b077aed3SPierre Proncherysupport only a subset of these operations. The following additional 228b077aed3SPierre ProncheryB<pkeyopt> values are supported: 229b077aed3SPierre Pronchery 230b077aed3SPierre Pronchery=over 4 231b077aed3SPierre Pronchery 232b077aed3SPierre Pronchery=item B<rsa_padding_mode:>I<mode> 233b077aed3SPierre Pronchery 234b077aed3SPierre ProncheryThis sets the RSA padding mode. Acceptable values for I<mode> are B<pkcs1> for 235b077aed3SPierre ProncheryPKCS#1 padding, B<none> for no padding, B<oaep> 236b077aed3SPierre Proncheryfor B<OAEP> mode, B<x931> for X9.31 mode and B<pss> for PSS. 237b077aed3SPierre Pronchery 238*e0c4386eSCy SchubertIn PKCS#1 padding, if the message digest is not set, then the supplied data is 239b077aed3SPierre Proncherysigned or verified directly instead of using a B<DigestInfo> structure. If a 240*e0c4386eSCy Schubertdigest is set, then the B<DigestInfo> structure is used and its length 241b077aed3SPierre Proncherymust correspond to the digest type. 242b077aed3SPierre Pronchery 243b077aed3SPierre ProncheryFor B<oaep> mode only encryption and decryption is supported. 244b077aed3SPierre Pronchery 245b077aed3SPierre ProncheryFor B<x931> if the digest type is set it is used to format the block data 246b077aed3SPierre Proncheryotherwise the first byte is used to specify the X9.31 digest ID. Sign, 247b077aed3SPierre Proncheryverify and verifyrecover are can be performed in this mode. 248b077aed3SPierre Pronchery 249b077aed3SPierre ProncheryFor B<pss> mode only sign and verify are supported and the digest type must be 250b077aed3SPierre Proncheryspecified. 251b077aed3SPierre Pronchery 252b077aed3SPierre Pronchery=item B<rsa_pss_saltlen:>I<len> 253b077aed3SPierre Pronchery 254b077aed3SPierre ProncheryFor B<pss> mode only this option specifies the salt length. Three special 255b077aed3SPierre Proncheryvalues are supported: B<digest> sets the salt length to the digest length, 256b077aed3SPierre ProncheryB<max> sets the salt length to the maximum permissible value. When verifying 257b077aed3SPierre ProncheryB<auto> causes the salt length to be automatically determined based on the 258b077aed3SPierre ProncheryB<PSS> block structure. 259b077aed3SPierre Pronchery 260b077aed3SPierre Pronchery=item B<rsa_mgf1_md:>I<digest> 261b077aed3SPierre Pronchery 262b077aed3SPierre ProncheryFor PSS and OAEP padding sets the MGF1 digest. If the MGF1 digest is not 263b077aed3SPierre Proncheryexplicitly set in PSS mode then the signing digest is used. 264b077aed3SPierre Pronchery 265b077aed3SPierre Pronchery=item B<rsa_oaep_md:>I<digest> 266b077aed3SPierre Pronchery 267b077aed3SPierre ProncherySets the digest used for the OAEP hash function. If not explicitly set then 268b077aed3SPierre ProncherySHA1 is used. 269b077aed3SPierre Pronchery 270b077aed3SPierre Pronchery=back 271b077aed3SPierre Pronchery 272b077aed3SPierre Pronchery=head1 RSA-PSS ALGORITHM 273b077aed3SPierre Pronchery 274b077aed3SPierre ProncheryThe RSA-PSS algorithm is a restricted version of the RSA algorithm which only 275b077aed3SPierre Proncherysupports the sign and verify operations with PSS padding. The following 276b077aed3SPierre Proncheryadditional B<-pkeyopt> values are supported: 277b077aed3SPierre Pronchery 278b077aed3SPierre Pronchery=over 4 279b077aed3SPierre Pronchery 280b077aed3SPierre Pronchery=item B<rsa_padding_mode:>I<mode>, B<rsa_pss_saltlen:>I<len>, 281b077aed3SPierre ProncheryB<rsa_mgf1_md:>I<digest> 282b077aed3SPierre Pronchery 283b077aed3SPierre ProncheryThese have the same meaning as the B<RSA> algorithm with some additional 284b077aed3SPierre Proncheryrestrictions. The padding mode can only be set to B<pss> which is the 285b077aed3SPierre Proncherydefault value. 286b077aed3SPierre Pronchery 287b077aed3SPierre ProncheryIf the key has parameter restrictions than the digest, MGF1 288b077aed3SPierre Proncherydigest and salt length are set to the values specified in the parameters. 289b077aed3SPierre ProncheryThe digest and MG cannot be changed and the salt length cannot be set to a 290b077aed3SPierre Proncheryvalue less than the minimum restriction. 291b077aed3SPierre Pronchery 292b077aed3SPierre Pronchery=back 293b077aed3SPierre Pronchery 294b077aed3SPierre Pronchery=head1 DSA ALGORITHM 295b077aed3SPierre Pronchery 296b077aed3SPierre ProncheryThe DSA algorithm supports signing and verification operations only. Currently 297b077aed3SPierre Proncherythere are no additional B<-pkeyopt> options other than B<digest>. The SHA1 298b077aed3SPierre Proncherydigest is assumed by default. 299b077aed3SPierre Pronchery 300b077aed3SPierre Pronchery=head1 DH ALGORITHM 301b077aed3SPierre Pronchery 302b077aed3SPierre ProncheryThe DH algorithm only supports the derivation operation and no additional 303b077aed3SPierre ProncheryB<-pkeyopt> options. 304b077aed3SPierre Pronchery 305b077aed3SPierre Pronchery=head1 EC ALGORITHM 306b077aed3SPierre Pronchery 307b077aed3SPierre ProncheryThe EC algorithm supports sign, verify and derive operations. The sign and 308b077aed3SPierre Proncheryverify operations use ECDSA and derive uses ECDH. SHA1 is assumed by default for 309b077aed3SPierre Proncherythe B<-pkeyopt> B<digest> option. 310b077aed3SPierre Pronchery 311b077aed3SPierre Pronchery=head1 X25519 AND X448 ALGORITHMS 312b077aed3SPierre Pronchery 313b077aed3SPierre ProncheryThe X25519 and X448 algorithms support key derivation only. Currently there are 314b077aed3SPierre Proncheryno additional options. 315b077aed3SPierre Pronchery 316b077aed3SPierre Pronchery=head1 ED25519 AND ED448 ALGORITHMS 317b077aed3SPierre Pronchery 318b077aed3SPierre ProncheryThese algorithms only support signing and verifying. OpenSSL only implements the 319b077aed3SPierre Pronchery"pure" variants of these algorithms so raw data can be passed directly to them 320b077aed3SPierre Proncherywithout hashing them first. The option B<-rawin> must be used with these 321b077aed3SPierre Proncheryalgorithms with no B<-digest> specified. Additionally OpenSSL only supports 322b077aed3SPierre Pronchery"oneshot" operation with these algorithms. This means that the entire file to 323b077aed3SPierre Proncherybe signed/verified must be read into memory before processing it. Signing or 324b077aed3SPierre ProncheryVerifying very large files should be avoided. Additionally the size of the file 325b077aed3SPierre Proncherymust be known for this to work. If the size of the file cannot be determined 326b077aed3SPierre Pronchery(for example if the input is stdin) then the sign or verify operation will fail. 327b077aed3SPierre Pronchery 328b077aed3SPierre Pronchery=head1 SM2 329b077aed3SPierre Pronchery 330b077aed3SPierre ProncheryThe SM2 algorithm supports sign, verify, encrypt and decrypt operations. For 331b077aed3SPierre Proncherythe sign and verify operations, SM2 requires an Distinguishing ID string to 332b077aed3SPierre Proncherybe passed in. The following B<-pkeyopt> value is supported: 333b077aed3SPierre Pronchery 334b077aed3SPierre Pronchery=over 4 335b077aed3SPierre Pronchery 336b077aed3SPierre Pronchery=item B<distid:>I<string> 337b077aed3SPierre Pronchery 338b077aed3SPierre ProncheryThis sets the ID string used in SM2 sign or verify operations. While verifying 339b077aed3SPierre Proncheryan SM2 signature, the ID string must be the same one used when signing the data. 340b077aed3SPierre ProncheryOtherwise the verification will fail. 341b077aed3SPierre Pronchery 342b077aed3SPierre Pronchery=item B<hexdistid:>I<hex_string> 343b077aed3SPierre Pronchery 344b077aed3SPierre ProncheryThis sets the ID string used in SM2 sign or verify operations. While verifying 345b077aed3SPierre Proncheryan SM2 signature, the ID string must be the same one used when signing the data. 346b077aed3SPierre ProncheryOtherwise the verification will fail. The ID string provided with this option 347b077aed3SPierre Proncheryshould be a valid hexadecimal value. 348b077aed3SPierre Pronchery 349b077aed3SPierre Pronchery=back 350b077aed3SPierre Pronchery 351b077aed3SPierre Pronchery=head1 EXAMPLES 352b077aed3SPierre Pronchery 353b077aed3SPierre ProncherySign some data using a private key: 354b077aed3SPierre Pronchery 355b077aed3SPierre Pronchery openssl pkeyutl -sign -in file -inkey key.pem -out sig 356b077aed3SPierre Pronchery 357b077aed3SPierre ProncheryRecover the signed data (e.g. if an RSA key is used): 358b077aed3SPierre Pronchery 359b077aed3SPierre Pronchery openssl pkeyutl -verifyrecover -in sig -inkey key.pem 360b077aed3SPierre Pronchery 361b077aed3SPierre ProncheryVerify the signature (e.g. a DSA key): 362b077aed3SPierre Pronchery 363b077aed3SPierre Pronchery openssl pkeyutl -verify -in file -sigfile sig -inkey key.pem 364b077aed3SPierre Pronchery 365b077aed3SPierre ProncherySign data using a message digest value (this is currently only valid for RSA): 366b077aed3SPierre Pronchery 367b077aed3SPierre Pronchery openssl pkeyutl -sign -in file -inkey key.pem -out sig -pkeyopt digest:sha256 368b077aed3SPierre Pronchery 369b077aed3SPierre ProncheryDerive a shared secret value: 370b077aed3SPierre Pronchery 371b077aed3SPierre Pronchery openssl pkeyutl -derive -inkey key.pem -peerkey pubkey.pem -out secret 372b077aed3SPierre Pronchery 373b077aed3SPierre ProncheryHexdump 48 bytes of TLS1 PRF using digest B<SHA256> and shared secret and 374b077aed3SPierre Proncheryseed consisting of the single byte 0xFF: 375b077aed3SPierre Pronchery 376b077aed3SPierre Pronchery openssl pkeyutl -kdf TLS1-PRF -kdflen 48 -pkeyopt md:SHA256 \ 377b077aed3SPierre Pronchery -pkeyopt hexsecret:ff -pkeyopt hexseed:ff -hexdump 378b077aed3SPierre Pronchery 379b077aed3SPierre ProncheryDerive a key using B<scrypt> where the password is read from command line: 380b077aed3SPierre Pronchery 381b077aed3SPierre Pronchery openssl pkeyutl -kdf scrypt -kdflen 16 -pkeyopt_passin pass \ 382b077aed3SPierre Pronchery -pkeyopt hexsalt:aabbcc -pkeyopt N:16384 -pkeyopt r:8 -pkeyopt p:1 383b077aed3SPierre Pronchery 384b077aed3SPierre ProncheryDerive using the same algorithm, but read key from environment variable MYPASS: 385b077aed3SPierre Pronchery 386b077aed3SPierre Pronchery openssl pkeyutl -kdf scrypt -kdflen 16 -pkeyopt_passin pass:env:MYPASS \ 387b077aed3SPierre Pronchery -pkeyopt hexsalt:aabbcc -pkeyopt N:16384 -pkeyopt r:8 -pkeyopt p:1 388b077aed3SPierre Pronchery 389b077aed3SPierre ProncherySign some data using an L<SM2(7)> private key and a specific ID: 390b077aed3SPierre Pronchery 391b077aed3SPierre Pronchery openssl pkeyutl -sign -in file -inkey sm2.key -out sig -rawin -digest sm3 \ 392b077aed3SPierre Pronchery -pkeyopt distid:someid 393b077aed3SPierre Pronchery 394b077aed3SPierre ProncheryVerify some data using an L<SM2(7)> certificate and a specific ID: 395b077aed3SPierre Pronchery 396b077aed3SPierre Pronchery openssl pkeyutl -verify -certin -in file -inkey sm2.cert -sigfile sig \ 397b077aed3SPierre Pronchery -rawin -digest sm3 -pkeyopt distid:someid 398b077aed3SPierre Pronchery 399b077aed3SPierre ProncheryDecrypt some data using a private key with OAEP padding using SHA256: 400b077aed3SPierre Pronchery 401b077aed3SPierre Pronchery openssl pkeyutl -decrypt -in file -inkey key.pem -out secret \ 402b077aed3SPierre Pronchery -pkeyopt rsa_padding_mode:oaep -pkeyopt rsa_oaep_md:sha256 403b077aed3SPierre Pronchery 404b077aed3SPierre Pronchery=head1 SEE ALSO 405b077aed3SPierre Pronchery 406b077aed3SPierre ProncheryL<openssl(1)>, 407b077aed3SPierre ProncheryL<openssl-genpkey(1)>, 408b077aed3SPierre ProncheryL<openssl-pkey(1)>, 409b077aed3SPierre ProncheryL<openssl-rsautl(1)> 410b077aed3SPierre ProncheryL<openssl-dgst(1)>, 411b077aed3SPierre ProncheryL<openssl-rsa(1)>, 412b077aed3SPierre ProncheryL<openssl-genrsa(1)>, 413b077aed3SPierre ProncheryL<openssl-kdf(1)> 414b077aed3SPierre ProncheryL<EVP_PKEY_CTX_set_hkdf_md(3)>, 415b077aed3SPierre ProncheryL<EVP_PKEY_CTX_set_tls1_prf_md(3)>, 416b077aed3SPierre Pronchery 417b077aed3SPierre Pronchery=head1 HISTORY 418b077aed3SPierre Pronchery 419b077aed3SPierre ProncheryThe B<-engine> option was deprecated in OpenSSL 3.0. 420b077aed3SPierre Pronchery 421b077aed3SPierre Pronchery=head1 COPYRIGHT 422b077aed3SPierre Pronchery 423b077aed3SPierre ProncheryCopyright 2006-2021 The OpenSSL Project Authors. All Rights Reserved. 424b077aed3SPierre Pronchery 425b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 426b077aed3SPierre Proncherythis file except in compliance with the License. You can obtain a copy 427b077aed3SPierre Proncheryin the file LICENSE in the source distribution or at 428b077aed3SPierre ProncheryL<https://www.openssl.org/source/license.html>. 429b077aed3SPierre Pronchery 430b077aed3SPierre Pronchery=cut 431