pkeyutl.1 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  1. .\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
  2. .\"
  3. .\" Standard preamble:
  4. .\" ========================================================================
  5. .de Sp \" Vertical space (when we can't use .PP)
  6. .if t .sp .5v
  7. .if n .sp
  8. ..
  9. .de Vb \" Begin verbatim text
  10. .ft CW
  11. .nf
  12. .ne \\$1
  13. ..
  14. .de Ve \" End verbatim text
  15. .ft R
  16. .fi
  17. ..
  18. .\" Set up some character translations and predefined strings. \*(-- will
  19. .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
  20. .\" double quote, and \*(R" will give a right double quote. \*(C+ will
  21. .\" give a nicer C++. Capital omega is used to do unbreakable dashes and
  22. .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
  23. .\" nothing in troff, for use with C<>.
  24. .tr \(*W-
  25. .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
  26. .ie n \{\
  27. . ds -- \(*W-
  28. . ds PI pi
  29. . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
  30. . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
  31. . ds L" ""
  32. . ds R" ""
  33. . ds C` ""
  34. . ds C' ""
  35. 'br\}
  36. .el\{\
  37. . ds -- \|\(em\|
  38. . ds PI \(*p
  39. . ds L" ``
  40. . ds R" ''
  41. . ds C`
  42. . ds C'
  43. 'br\}
  44. .\"
  45. .\" Escape single quotes in literal strings from groff's Unicode transform.
  46. .ie \n(.g .ds Aq \(aq
  47. .el .ds Aq '
  48. .\"
  49. .\" If the F register is >0, we'll generate index entries on stderr for
  50. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  51. .\" entries marked with X<> in POD. Of course, you'll have to process the
  52. .\" output yourself in some meaningful fashion.
  53. .\"
  54. .\" Avoid warning from groff about undefined register 'F'.
  55. .de IX
  56. ..
  57. .if !\nF .nr F 0
  58. .if \nF>0 \{\
  59. . de IX
  60. . tm Index:\\$1\t\\n%\t"\\$2"
  61. ..
  62. . if !\nF==2 \{\
  63. . nr % 0
  64. . nr F 2
  65. . \}
  66. .\}
  67. .\"
  68. .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
  69. .\" Fear. Run. Save yourself. No user-serviceable parts.
  70. . \" fudge factors for nroff and troff
  71. .if n \{\
  72. . ds #H 0
  73. . ds #V .8m
  74. . ds #F .3m
  75. . ds #[ \f1
  76. . ds #] \fP
  77. .\}
  78. .if t \{\
  79. . ds #H ((1u-(\\\\n(.fu%2u))*.13m)
  80. . ds #V .6m
  81. . ds #F 0
  82. . ds #[ \&
  83. . ds #] \&
  84. .\}
  85. . \" simple accents for nroff and troff
  86. .if n \{\
  87. . ds ' \&
  88. . ds ` \&
  89. . ds ^ \&
  90. . ds , \&
  91. . ds ~ ~
  92. . ds /
  93. .\}
  94. .if t \{\
  95. . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
  96. . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
  97. . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
  98. . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
  99. . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
  100. . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
  101. .\}
  102. . \" troff and (daisy-wheel) nroff accents
  103. .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
  104. .ds 8 \h'\*(#H'\(*b\h'-\*(#H'
  105. .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
  106. .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
  107. .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
  108. .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
  109. .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
  110. .ds ae a\h'-(\w'a'u*4/10)'e
  111. .ds Ae A\h'-(\w'A'u*4/10)'E
  112. . \" corrections for vroff
  113. .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
  114. .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
  115. . \" for low resolution devices (crt and lpr)
  116. .if \n(.H>23 .if \n(.V>19 \
  117. \{\
  118. . ds : e
  119. . ds 8 ss
  120. . ds o a
  121. . ds d- d\h'-1'\(ga
  122. . ds D- D\h'-1'\(hy
  123. . ds th \o'bp'
  124. . ds Th \o'LP'
  125. . ds ae ae
  126. . ds Ae AE
  127. .\}
  128. .rm #[ #] #H #V #F C
  129. .\" ========================================================================
  130. .\"
  131. .IX Title "PKEYUTL 1"
  132. .TH PKEYUTL 1 "2019-09-12" "1.0.2g" "OpenSSL"
  133. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  134. .\" way too many mistakes in technical documents.
  135. .if n .ad l
  136. .nh
  137. .SH "NAME"
  138. pkeyutl \- public key algorithm utility
  139. .SH "SYNOPSIS"
  140. .IX Header "SYNOPSIS"
  141. \&\fBopenssl\fR \fBpkeyutl\fR
  142. [\fB\-in file\fR]
  143. [\fB\-out file\fR]
  144. [\fB\-sigfile file\fR]
  145. [\fB\-inkey file\fR]
  146. [\fB\-keyform PEM|DER\fR]
  147. [\fB\-passin arg\fR]
  148. [\fB\-peerkey file\fR]
  149. [\fB\-peerform PEM|DER\fR]
  150. [\fB\-pubin\fR]
  151. [\fB\-certin\fR]
  152. [\fB\-rev\fR]
  153. [\fB\-sign\fR]
  154. [\fB\-verify\fR]
  155. [\fB\-verifyrecover\fR]
  156. [\fB\-encrypt\fR]
  157. [\fB\-decrypt\fR]
  158. [\fB\-derive\fR]
  159. [\fB\-pkeyopt opt:value\fR]
  160. [\fB\-hexdump\fR]
  161. [\fB\-asn1parse\fR]
  162. [\fB\-engine id\fR]
  163. .SH "DESCRIPTION"
  164. .IX Header "DESCRIPTION"
  165. The \fBpkeyutl\fR command can be used to perform public key operations using
  166. any supported algorithm.
  167. .SH "COMMAND OPTIONS"
  168. .IX Header "COMMAND OPTIONS"
  169. .IP "\fB\-in filename\fR" 4
  170. .IX Item "-in filename"
  171. This specifies the input filename to read data from or standard input
  172. if this option is not specified.
  173. .IP "\fB\-out filename\fR" 4
  174. .IX Item "-out filename"
  175. specifies the output filename to write to or standard output by
  176. default.
  177. .IP "\fB\-inkey file\fR" 4
  178. .IX Item "-inkey file"
  179. the input key file, by default it should be a private key.
  180. .IP "\fB\-keyform PEM|DER\fR" 4
  181. .IX Item "-keyform PEM|DER"
  182. the key format \s-1PEM, DER\s0 or \s-1ENGINE.\s0
  183. .IP "\fB\-passin arg\fR" 4
  184. .IX Item "-passin arg"
  185. the input key password source. For more information about the format of \fBarg\fR
  186. see the \fB\s-1PASS PHRASE ARGUMENTS\s0\fR section in \fIopenssl\fR\|(1).
  187. .IP "\fB\-peerkey file\fR" 4
  188. .IX Item "-peerkey file"
  189. the peer key file, used by key derivation (agreement) operations.
  190. .IP "\fB\-peerform PEM|DER\fR" 4
  191. .IX Item "-peerform PEM|DER"
  192. the peer key format \s-1PEM, DER\s0 or \s-1ENGINE.\s0
  193. .IP "\fB\-engine id\fR" 4
  194. .IX Item "-engine id"
  195. specifying an engine (by its unique \fBid\fR string) will cause \fBpkeyutl\fR
  196. to attempt to obtain a functional reference to the specified engine,
  197. thus initialising it if needed. The engine will then be set as the default
  198. for all available algorithms.
  199. .IP "\fB\-pubin\fR" 4
  200. .IX Item "-pubin"
  201. the input file is a public key.
  202. .IP "\fB\-certin\fR" 4
  203. .IX Item "-certin"
  204. the input is a certificate containing a public key.
  205. .IP "\fB\-rev\fR" 4
  206. .IX Item "-rev"
  207. reverse the order of the input buffer. This is useful for some libraries
  208. (such as CryptoAPI) which represent the buffer in little endian format.
  209. .IP "\fB\-sign\fR" 4
  210. .IX Item "-sign"
  211. sign the input data and output the signed result. This requires
  212. a private key.
  213. .IP "\fB\-verify\fR" 4
  214. .IX Item "-verify"
  215. verify the input data against the signature file and indicate if the
  216. verification succeeded or failed.
  217. .IP "\fB\-verifyrecover\fR" 4
  218. .IX Item "-verifyrecover"
  219. verify the input data and output the recovered data.
  220. .IP "\fB\-encrypt\fR" 4
  221. .IX Item "-encrypt"
  222. encrypt the input data using a public key.
  223. .IP "\fB\-decrypt\fR" 4
  224. .IX Item "-decrypt"
  225. decrypt the input data using a private key.
  226. .IP "\fB\-derive\fR" 4
  227. .IX Item "-derive"
  228. derive a shared secret using the peer key.
  229. .IP "\fB\-hexdump\fR" 4
  230. .IX Item "-hexdump"
  231. hex dump the output data.
  232. .IP "\fB\-asn1parse\fR" 4
  233. .IX Item "-asn1parse"
  234. asn1parse the output data, this is useful when combined with the
  235. \&\fB\-verifyrecover\fR option when an \s-1ASN1\s0 structure is signed.
  236. .SH "NOTES"
  237. .IX Header "NOTES"
  238. The operations and options supported vary according to the key algorithm
  239. and its implementation. The OpenSSL operations and options are indicated below.
  240. .PP
  241. Unless otherwise mentioned all algorithms support the \fBdigest:alg\fR option
  242. which specifies the digest in use for sign, verify and verifyrecover operations.
  243. The value \fBalg\fR should represent a digest name as used in the
  244. \&\fIEVP_get_digestbyname()\fR function for example \fBsha1\fR.
  245. This value is used only for sanity-checking the lengths of data passed in to
  246. the \fBpkeyutl\fR and for creating the structures that make up the signature
  247. (e.g. \fBDigestInfo\fR in \s-1RSASSA\s0 PKCS#1 v1.5 signatures).
  248. In case of \s-1RSA, ECDSA\s0 and \s-1DSA\s0 signatures, this utility
  249. will not perform hashing on input data but rather use the data directly as
  250. input of signature algorithm. Depending on key type, signature type and mode
  251. of padding, the maximum acceptable lengths of input data differ. In general,
  252. with \s-1RSA\s0 the signed data can't be longer than the key modulus, in case of \s-1ECDSA\s0
  253. and \s-1DSA\s0 the data shouldn't be longer than field size, otherwise it will be
  254. silently truncated to field size.
  255. .PP
  256. In other words, if the value of digest is \fBsha1\fR the input should be 20 bytes
  257. long binary encoding of \s-1SHA\-1\s0 hash function output.
  258. .SH "RSA ALGORITHM"
  259. .IX Header "RSA ALGORITHM"
  260. The \s-1RSA\s0 algorithm supports encrypt, decrypt, sign, verify and verifyrecover
  261. operations in general. Some padding modes only support some of these
  262. operations however.
  263. .IP "\-\fBrsa_padding_mode:mode\fR" 4
  264. .IX Item "-rsa_padding_mode:mode"
  265. This sets the \s-1RSA\s0 padding mode. Acceptable values for \fBmode\fR are \fBpkcs1\fR for
  266. PKCS#1 padding, \fBsslv23\fR for SSLv23 padding, \fBnone\fR for no padding, \fBoaep\fR
  267. for \fB\s-1OAEP\s0\fR mode, \fBx931\fR for X9.31 mode and \fBpss\fR for \s-1PSS.\s0
  268. .Sp
  269. In PKCS#1 padding if the message digest is not set then the supplied data is
  270. signed or verified directly instead of using a \fBDigestInfo\fR structure. If a
  271. digest is set then the a \fBDigestInfo\fR structure is used and its the length
  272. must correspond to the digest type.
  273. .Sp
  274. For \fBoeap\fR mode only encryption and decryption is supported.
  275. .Sp
  276. For \fBx931\fR if the digest type is set it is used to format the block data
  277. otherwise the first byte is used to specify the X9.31 digest \s-1ID.\s0 Sign,
  278. verify and verifyrecover are can be performed in this mode.
  279. .Sp
  280. For \fBpss\fR mode only sign and verify are supported and the digest type must be
  281. specified.
  282. .IP "\fBrsa_pss_saltlen:len\fR" 4
  283. .IX Item "rsa_pss_saltlen:len"
  284. For \fBpss\fR mode only this option specifies the salt length. Two special values
  285. are supported: \-1 sets the salt length to the digest length. When signing \-2
  286. sets the salt length to the maximum permissible value. When verifying \-2 causes
  287. the salt length to be automatically determined based on the \fB\s-1PSS\s0\fR block
  288. structure.
  289. .SH "DSA ALGORITHM"
  290. .IX Header "DSA ALGORITHM"
  291. The \s-1DSA\s0 algorithm supports signing and verification operations only. Currently
  292. there are no additional options other than \fBdigest\fR. Only the \s-1SHA1\s0
  293. digest can be used and this digest is assumed by default.
  294. .SH "DH ALGORITHM"
  295. .IX Header "DH ALGORITHM"
  296. The \s-1DH\s0 algorithm only supports the derivation operation and no additional
  297. options.
  298. .SH "EC ALGORITHM"
  299. .IX Header "EC ALGORITHM"
  300. The \s-1EC\s0 algorithm supports sign, verify and derive operations. The sign and
  301. verify operations use \s-1ECDSA\s0 and derive uses \s-1ECDH.\s0 Currently there are no
  302. additional options other than \fBdigest\fR. Only the \s-1SHA1\s0 digest can be used and
  303. this digest is assumed by default.
  304. .SH "EXAMPLES"
  305. .IX Header "EXAMPLES"
  306. Sign some data using a private key:
  307. .PP
  308. .Vb 1
  309. \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig
  310. .Ve
  311. .PP
  312. Recover the signed data (e.g. if an \s-1RSA\s0 key is used):
  313. .PP
  314. .Vb 1
  315. \& openssl pkeyutl \-verifyrecover \-in sig \-inkey key.pem
  316. .Ve
  317. .PP
  318. Verify the signature (e.g. a \s-1DSA\s0 key):
  319. .PP
  320. .Vb 1
  321. \& openssl pkeyutl \-verify \-in file \-sigfile sig \-inkey key.pem
  322. .Ve
  323. .PP
  324. Sign data using a message digest value (this is currently only valid for \s-1RSA\s0):
  325. .PP
  326. .Vb 1
  327. \& openssl pkeyutl \-sign \-in file \-inkey key.pem \-out sig \-pkeyopt digest:sha256
  328. .Ve
  329. .PP
  330. Derive a shared secret value:
  331. .PP
  332. .Vb 1
  333. \& openssl pkeyutl \-derive \-inkey key.pem \-peerkey pubkey.pem \-out secret
  334. .Ve
  335. .SH "SEE ALSO"
  336. .IX Header "SEE ALSO"
  337. \&\fIgenpkey\fR\|(1), \fIpkey\fR\|(1), \fIrsautl\fR\|(1)
  338. \&\fIdgst\fR\|(1), \fIrsa\fR\|(1), \fIgenrsa\fR\|(1)