1PKEYUTL(1)                          OpenSSL                         PKEYUTL(1)
2
3
4

NAME

6       pkeyutl - public key algorithm utility
7

SYNOPSIS

9       openssl pkeyutl [-in file] [-out file] [-sigfile file] [-inkey file]
10       [-keyform PEM|DER] [-passin arg] [-peerkey file] [-peerform PEM|DER]
11       [-pubin] [-certin] [-rev] [-sign] [-verify] [-verifyrecover] [-encrypt]
12       [-decrypt] [-derive] [-pkeyopt opt:value] [-hexdump] [-asn1parse]
13       [-engine id]
14

DESCRIPTION

16       The pkeyutl command can be used to perform public key operations using
17       any supported algorithm.
18

COMMAND OPTIONS

20       -in filename
21           This specifies the input filename to read data from or standard
22           input if this option is not specified.
23
24       -out filename
25           specifies the output filename to write to or standard output by
26           default.
27
28       -inkey file
29           the input key file, by default it should be a private key.
30
31       -keyform PEM|DER
32           the key format PEM, DER or ENGINE.
33
34       -passin arg
35           the input key password source. For more information about the
36           format of arg see the PASS PHRASE ARGUMENTS section in openssl(1).
37
38       -peerkey file
39           the peer key file, used by key derivation (agreement) operations.
40
41       -peerform PEM|DER
42           the peer key format PEM, DER or ENGINE.
43
44       -engine id
45           specifying an engine (by its unique id string) will cause pkeyutl
46           to attempt to obtain a functional reference to the specified
47           engine, thus initialising it if needed. The engine will then be set
48           as the default for all available algorithms.
49
50       -pubin
51           the input file is a public key.
52
53       -certin
54           the input is a certificate containing a public key.
55
56       -rev
57           reverse the order of the input buffer. This is useful for some
58           libraries (such as CryptoAPI) which represent the buffer in little
59           endian format.
60
61       -sign
62           sign the input data and output the signed result. This requires a
63           private key.
64
65       -verify
66           verify the input data against the signature file and indicate if
67           the verification succeeded or failed.
68
69       -verifyrecover
70           verify the input data and output the recovered data.
71
72       -encrypt
73           encrypt the input data using a public key.
74
75       -decrypt
76           decrypt the input data using a private key.
77
78       -derive
79           derive a shared secret using the peer key.
80
81       -hexdump
82           hex dump the output data.
83
84       -asn1parse
85           asn1parse the output data, this is useful when combined with the
86           -verifyrecover option when an ASN1 structure is signed.
87

NOTES

89       The operations and options supported vary according to the key
90       algorithm and its implementation. The OpenSSL operations and options
91       are indicated below.
92
93       Unless otherwise mentioned all algorithms support the digest:alg option
94       which specifies the digest in use for sign, verify and verifyrecover
95       operations.  The value alg should represent a digest name as used in
96       the EVP_get_digestbyname() function for example sha1.  This value is
97       used only for sanity-checking the lengths of data passed in to the
98       pkeyutl and for creating the structures that make up the signature
99       (e.g. DigestInfo in RSASSA PKCS#1 v1.5 signatures).  In case of RSA,
100       ECDSA and DSA signatures, this utility will not perform hashing on
101       input data but rather use the data directly as input of signature
102       algorithm. Depending on key type, signature type and mode of padding,
103       the maximum acceptable lengths of input data differ. In general, with
104       RSA the signed data can't be longer than the key modulus, in case of
105       ECDSA and DSA the data shouldn't be longer than field size, otherwise
106       it will be silently truncated to field size.
107
108       In other words, if the value of digest is sha1 the input should be 20
109       bytes long binary encoding of SHA-1 hash function output.
110

RSA ALGORITHM

112       The RSA algorithm supports encrypt, decrypt, sign, verify and
113       verifyrecover operations in general. Some padding modes only support
114       some of these operations however.
115
116       -rsa_padding_mode:mode
117           This sets the RSA padding mode. Acceptable values for mode are
118           pkcs1 for PKCS#1 padding, sslv23 for SSLv23 padding, none for no
119           padding, oaep for OAEP mode, x931 for X9.31 mode and pss for PSS.
120
121           In PKCS#1 padding if the message digest is not set then the
122           supplied data is signed or verified directly instead of using a
123           DigestInfo structure. If a digest is set then the a DigestInfo
124           structure is used and its the length must correspond to the digest
125           type.
126
127           For oeap mode only encryption and decryption is supported.
128
129           For x931 if the digest type is set it is used to format the block
130           data otherwise the first byte is used to specify the X9.31 digest
131           ID. Sign, verify and verifyrecover are can be performed in this
132           mode.
133
134           For pss mode only sign and verify are supported and the digest type
135           must be specified.
136
137       rsa_pss_saltlen:len
138           For pss mode only this option specifies the salt length. Two
139           special values are supported: -1 sets the salt length to the digest
140           length. When signing -2 sets the salt length to the maximum
141           permissible value. When verifying -2 causes the salt length to be
142           automatically determined based on the PSS block structure.
143

DSA ALGORITHM

145       The DSA algorithm supports signing and verification operations only.
146       Currently there are no additional options other than digest. Only the
147       SHA1 digest can be used and this digest is assumed by default.
148

DH ALGORITHM

150       The DH algorithm only supports the derivation operation and no
151       additional options.
152

EC ALGORITHM

154       The EC algorithm supports sign, verify and derive operations. The sign
155       and verify operations use ECDSA and derive uses ECDH. Currently there
156       are no additional options other than digest. Only the SHA1 digest can
157       be used and this digest is assumed by default.
158

EXAMPLES

160       Sign some data using a private key:
161
162        openssl pkeyutl -sign -in file -inkey key.pem -out sig
163
164       Recover the signed data (e.g. if an RSA key is used):
165
166        openssl pkeyutl -verifyrecover -in sig -inkey key.pem
167
168       Verify the signature (e.g. a DSA key):
169
170        openssl pkeyutl -verify -in file -sigfile sig -inkey key.pem
171
172       Sign data using a message digest value (this is currently only valid
173       for RSA):
174
175        openssl pkeyutl -sign -in file -inkey key.pem -out sig -pkeyopt digest:sha256
176
177       Derive a shared secret value:
178
179        openssl pkeyutl -derive -inkey key.pem -peerkey pubkey.pem -out secret
180

SEE ALSO

182       genpkey(1), pkey(1), rsautl(1) dgst(1), rsa(1), genrsa(1)
183
184
185
1861.0.2k                            2017-01-26                        PKEYUTL(1)
Impressum