5 pkeyutl - public key algorithm utility
16 [B<-peerform PEM|DER>]
26 [B<-pkeyopt opt:value>]
32 The B<pkeyutl> command can be used to perform public key operations using
33 any supported algorithm.
35 =head1 COMMAND OPTIONS
41 This specifies the input filename to read data from or standard input
42 if this option is not specified.
44 =item B<-out filename>
46 specifies the output filename to write to or standard output by
51 the input key file, by default it should be a private key.
53 =item B<-keyform PEM|DER>
55 the key format PEM or DER.
57 =item B<-peerkey file>
59 the peer key file, used by key derivation (agreement) operations.
61 =item B<-peerform PEM|DER>
63 the peer key format PEM or DER.
67 the input file is a public key.
71 the input is a certificate containing a public key.
75 reverse the order of the input buffer. This is useful for some libraries
76 (such as CryptoAPI) which represent the buffer in little endian format.
80 sign the input data and output the signed result. This requires
85 verify the input data against the signature file and indicate if the
86 verification succeeded or failed.
88 =item B<-verifyrecover>
90 verify the input data and output the recovered data.
94 encrypt the input data using a public key.
98 decrypt the input data using a private key.
102 derive a shared secret using the peer key.
106 hex dump the output data.
110 asn1parse the output data, this is useful when combined with the
111 B<-verifyrecover> option when an ASN1 structure is signed.
117 The operations and options supported vary according to the key algorithm
118 and its implementation. The OpenSSL operations and options are indicated below.
120 Unless otherwise mentioned all algorithms support the B<digest:alg> option
121 which specifies the digest in use for sign, verify and verifyrecover operations.
122 The value B<alg> should represent a digest name as used in the
123 EVP_get_digestbyname() function for example B<sha1>.
127 The RSA algorithm supports encrypt, decrypt, sign, verify and verifyrecover
128 operations in general. Some padding modes only support some of these
133 =item -B<rsa_padding_mode:mode>
135 This sets the RSA padding mode. Acceptable values for B<mode> are B<pkcs1> for
136 PKCS#1 padding, B<sslv23> for SSLv23 padding, B<none> for no padding, B<oaep>
137 for B<OAEP> mode, B<x931> for X9.31 mode and B<pss> for PSS.
139 In PKCS#1 padding if the message digest is not set then the supplied data is
140 signed or verified directly instead of using a B<DigestInfo> structure. If a
141 digest is set then the a B<DigestInfo> structure is used and its the length
142 must correspond to the digest type.
144 For B<oeap> mode only encryption and decryption is supported.
146 For B<x931> if the digest type is set it is used to format the block data
147 otherwise the first byte is used to specify the X9.31 digest ID. Sign,
148 verify and verifyrecover are can be performed in this mode.
150 For B<pss> mode only sign and verify are supported and the digest type must be
153 =item B<rsa_pss_saltlen:len>
155 For B<pss> mode only this option specifies the salt length. Two special values
156 are supported: -1 sets the salt length to the digest length. When signing -2
157 sets the salt length to the maximum permissible value. When verifying -2 causes
158 the salt length to be automatically determined based on the B<PSS> block
165 The DSA algorithm supports signing and verification operations only. Currently
166 there are no additional options other than B<digest>. Only the SHA1
167 digest can be used and this digest is assumed by default.
171 The DH algorithm only supports the derivation operation and no additional
176 The EC algorithm supports sign, verify and derive operations. The sign and
177 verify operations use ECDSA and derive uses ECDH. Currently there are no
178 additional options other than B<digest>. Only the SHA1 digest can be used and
179 this digest is assumed by default.
183 Sign some data using a private key:
185 openssl pkeyutl -sign -in file -inkey key.pem -out sig
187 Recover the signed data (e.g. if an RSA key is used):
189 openssl pkeyutl -verifyrecover -in sig -inkey key.pem
191 Verify the signature (e.g. a DSA key):
193 openssl pkeyutl -verify -in file -sigfile sig -inkey key.pem
195 Sign data using a message digest value (this is currently only valid for RSA):
197 openssl pkeyutl -sign -in file -inkey key.pem -out sig -pkeyopt digest:sha256
199 Derive a shared secret value:
201 openssl pkeyutl -derive -inkey key.pem -peerkey pubkey.pem -out secret
205 L<genpkey(1)|genpkey(1)>, L<pkey(1)|pkey(1)>, L<rsautl(1)|rsautl(1)>
206 L<dgst(1)|dgst(1)>, L<rsa(1)|rsa(1)>, L<genrsa(1)|genrsa(1)>