5 pkeyutl - public key algorithm utility
17 [B<-peerform PEM|DER>]
27 [B<-pkeyopt opt:value>]
34 The B<pkeyutl> command can be used to perform public key operations using
35 any supported algorithm.
37 =head1 COMMAND OPTIONS
43 This specifies the input filename to read data from or standard input
44 if this option is not specified.
46 =item B<-out filename>
48 specifies the output filename to write to or standard output by
53 the input key file, by default it should be a private key.
55 =item B<-keyform PEM|DER>
57 the key format PEM, DER or ENGINE.
61 the input key password source. For more information about the format of B<arg>
62 see the B<PASS PHRASE ARGUMENTS> section in L<openssl(1)|openssl(1)>.
65 =item B<-peerkey file>
67 the peer key file, used by key derivation (agreement) operations.
69 =item B<-peerform PEM|DER>
71 the peer key format PEM, DER or ENGINE.
75 specifying an engine (by its unique B<id> string) will cause B<pkeyutl>
76 to attempt to obtain a functional reference to the specified engine,
77 thus initialising it if needed. The engine will then be set as the default
78 for all available algorithms.
83 the input file is a public key.
87 the input is a certificate containing a public key.
91 reverse the order of the input buffer. This is useful for some libraries
92 (such as CryptoAPI) which represent the buffer in little endian format.
96 sign the input data and output the signed result. This requires
101 verify the input data against the signature file and indicate if the
102 verification succeeded or failed.
104 =item B<-verifyrecover>
106 verify the input data and output the recovered data.
110 encrypt the input data using a public key.
114 decrypt the input data using a private key.
118 derive a shared secret using the peer key.
122 hex dump the output data.
126 asn1parse the output data, this is useful when combined with the
127 B<-verifyrecover> option when an ASN1 structure is signed.
133 The operations and options supported vary according to the key algorithm
134 and its implementation. The OpenSSL operations and options are indicated below.
136 Unless otherwise mentioned all algorithms support the B<digest:alg> option
137 which specifies the digest in use for sign, verify and verifyrecover operations.
138 The value B<alg> should represent a digest name as used in the
139 EVP_get_digestbyname() function for example B<sha1>.
140 This value is used only for sanity-checking the lengths of data passed in to
141 the B<pkeyutl> and for creating the structures that make up the signature
142 (e.g. B<DigestInfo> in RSASSA PKCS#1 v1.5 signatures).
143 In case of RSA, ECDSA and DSA signatures, this utility
144 will not perform hashing on input data but rather use the data directly as
145 input of signature algorithm. Depending on key type, signature type and mode
146 of padding, the maximum acceptable lengths of input data differ. In general,
147 with RSA the signed data can't be longer than the key modulus, in case of ECDSA
148 and DSA the data shouldn't be longer than field size, otherwise it will be
149 silently truncated to field size.
151 In other words, if the value of digest is B<sha1> the input should be 20 bytes
152 long binary encoding of SHA-1 hash function output.
156 The RSA algorithm supports encrypt, decrypt, sign, verify and verifyrecover
157 operations in general. Some padding modes only support some of these
162 =item -B<rsa_padding_mode:mode>
164 This sets the RSA padding mode. Acceptable values for B<mode> are B<pkcs1> for
165 PKCS#1 padding, B<sslv23> for SSLv23 padding, B<none> for no padding, B<oaep>
166 for B<OAEP> mode, B<x931> for X9.31 mode and B<pss> for PSS.
168 In PKCS#1 padding if the message digest is not set then the supplied data is
169 signed or verified directly instead of using a B<DigestInfo> structure. If a
170 digest is set then the a B<DigestInfo> structure is used and its the length
171 must correspond to the digest type.
173 For B<oeap> mode only encryption and decryption is supported.
175 For B<x931> if the digest type is set it is used to format the block data
176 otherwise the first byte is used to specify the X9.31 digest ID. Sign,
177 verify and verifyrecover are can be performed in this mode.
179 For B<pss> mode only sign and verify are supported and the digest type must be
182 =item B<rsa_pss_saltlen:len>
184 For B<pss> mode only this option specifies the salt length. Two special values
185 are supported: -1 sets the salt length to the digest length. When signing -2
186 sets the salt length to the maximum permissible value. When verifying -2 causes
187 the salt length to be automatically determined based on the B<PSS> block
194 The DSA algorithm supports signing and verification operations only. Currently
195 there are no additional options other than B<digest>. Only the SHA1
196 digest can be used and this digest is assumed by default.
200 The DH algorithm only supports the derivation operation and no additional
205 The EC algorithm supports sign, verify and derive operations. The sign and
206 verify operations use ECDSA and derive uses ECDH. Currently there are no
207 additional options other than B<digest>. Only the SHA1 digest can be used and
208 this digest is assumed by default.
212 Sign some data using a private key:
214 openssl pkeyutl -sign -in file -inkey key.pem -out sig
216 Recover the signed data (e.g. if an RSA key is used):
218 openssl pkeyutl -verifyrecover -in sig -inkey key.pem
220 Verify the signature (e.g. a DSA key):
222 openssl pkeyutl -verify -in file -sigfile sig -inkey key.pem
224 Sign data using a message digest value (this is currently only valid for RSA):
226 openssl pkeyutl -sign -in file -inkey key.pem -out sig -pkeyopt digest:sha256
228 Derive a shared secret value:
230 openssl pkeyutl -derive -inkey key.pem -peerkey pubkey.pem -out secret
234 L<genpkey(1)|genpkey(1)>, L<pkey(1)|pkey(1)>, L<rsautl(1)|rsautl(1)>
235 L<dgst(1)|dgst(1)>, L<rsa(1)|rsa(1)>, L<genrsa(1)|genrsa(1)>