openssl-mac.1ossl 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. .\" -*- mode: troff; coding: utf-8 -*-
  2. .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43)
  3. .\"
  4. .\" Standard preamble:
  5. .\" ========================================================================
  6. .de Sp \" Vertical space (when we can't use .PP)
  7. .if t .sp .5v
  8. .if n .sp
  9. ..
  10. .de Vb \" Begin verbatim text
  11. .ft CW
  12. .nf
  13. .ne \\$1
  14. ..
  15. .de Ve \" End verbatim text
  16. .ft R
  17. .fi
  18. ..
  19. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
  20. .ie n \{\
  21. . ds C` ""
  22. . ds C' ""
  23. 'br\}
  24. .el\{\
  25. . ds C`
  26. . ds C'
  27. 'br\}
  28. .\"
  29. .\" Escape single quotes in literal strings from groff's Unicode transform.
  30. .ie \n(.g .ds Aq \(aq
  31. .el .ds Aq '
  32. .\"
  33. .\" If the F register is >0, we'll generate index entries on stderr for
  34. .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
  35. .\" entries marked with X<> in POD. Of course, you'll have to process the
  36. .\" output yourself in some meaningful fashion.
  37. .\"
  38. .\" Avoid warning from groff about undefined register 'F'.
  39. .de IX
  40. ..
  41. .nr rF 0
  42. .if \n(.g .if rF .nr rF 1
  43. .if (\n(rF:(\n(.g==0)) \{\
  44. . if \nF \{\
  45. . de IX
  46. . tm Index:\\$1\t\\n%\t"\\$2"
  47. ..
  48. . if !\nF==2 \{\
  49. . nr % 0
  50. . nr F 2
  51. . \}
  52. . \}
  53. .\}
  54. .rr rF
  55. .\" ========================================================================
  56. .\"
  57. .IX Title "OPENSSL-MAC 1ossl"
  58. .TH OPENSSL-MAC 1ossl 2025-01-17 3.4.0 OpenSSL
  59. .\" For nroff, turn off justification. Always turn off hyphenation; it makes
  60. .\" way too many mistakes in technical documents.
  61. .if n .ad l
  62. .nh
  63. .SH NAME
  64. openssl\-mac \- perform Message Authentication Code operations
  65. .SH SYNOPSIS
  66. .IX Header "SYNOPSIS"
  67. \&\fBopenssl mac\fR
  68. [\fB\-help\fR]
  69. [\fB\-cipher\fR]
  70. [\fB\-digest\fR]
  71. [\fB\-macopt\fR]
  72. [\fB\-in\fR \fIfilename\fR]
  73. [\fB\-out\fR \fIfilename\fR]
  74. [\fB\-binary\fR]
  75. [\fB\-provider\fR \fIname\fR]
  76. [\fB\-provider\-path\fR \fIpath\fR]
  77. [\fB\-propquery\fR \fIpropq\fR]
  78. \&\fImac_name\fR
  79. .SH DESCRIPTION
  80. .IX Header "DESCRIPTION"
  81. The message authentication code functions output the MAC of a supplied input
  82. file.
  83. .SH OPTIONS
  84. .IX Header "OPTIONS"
  85. .IP \fB\-help\fR 4
  86. .IX Item "-help"
  87. Print a usage message.
  88. .IP "\fB\-in\fR \fIfilename\fR" 4
  89. .IX Item "-in filename"
  90. Input filename to calculate a MAC for, or standard input by default.
  91. Standard input is used if the filename is '\-'.
  92. Files and standard input are expected to be in binary format.
  93. .IP "\fB\-out\fR \fIfilename\fR" 4
  94. .IX Item "-out filename"
  95. Filename to output to, or standard output by default.
  96. .IP \fB\-binary\fR 4
  97. .IX Item "-binary"
  98. Output the MAC in binary form. Uses hexadecimal text format if not specified.
  99. .IP "\fB\-cipher\fR \fIname\fR" 4
  100. .IX Item "-cipher name"
  101. Used by CMAC and GMAC to specify the cipher algorithm.
  102. For CMAC it should be a CBC mode cipher e.g. AES\-128\-CBC.
  103. For GMAC it should be a GCM mode cipher e.g. AES\-128\-GCM.
  104. .IP "\fB\-digest\fR \fIname\fR" 4
  105. .IX Item "-digest name"
  106. Used by HMAC as an alphanumeric string (use if the key contains printable
  107. characters only).
  108. The string length must conform to any restrictions of the MAC algorithm.
  109. To see the list of supported digests, use \f(CW\*(C`openssl list \-digest\-commands\*(C'\fR.
  110. .IP "\fB\-macopt\fR \fInm\fR:\fIv\fR" 4
  111. .IX Item "-macopt nm:v"
  112. Passes options to the MAC algorithm.
  113. A comprehensive list of controls can be found in the EVP_MAC implementation
  114. documentation.
  115. Common parameter names used by \fBEVP_MAC_CTX_get_params()\fR are:
  116. .RS 4
  117. .IP \fBkey:\fR\fIstring\fR 4
  118. .IX Item "key:string"
  119. Specifies the MAC key as an alphanumeric string (use if the key contains
  120. printable characters only).
  121. The string length must conform to any restrictions of the MAC algorithm.
  122. A key must be specified for every MAC algorithm.
  123. .IP \fBhexkey:\fR\fIstring\fR 4
  124. .IX Item "hexkey:string"
  125. Specifies the MAC key in hexadecimal form (two hex digits per byte).
  126. The key length must conform to any restrictions of the MAC algorithm.
  127. A key must be specified for every MAC algorithm.
  128. .IP \fBiv:\fR\fIstring\fR 4
  129. .IX Item "iv:string"
  130. Used by GMAC to specify an IV as an alphanumeric string (use if the IV contains
  131. printable characters only).
  132. .IP \fBhexiv:\fR\fIstring\fR 4
  133. .IX Item "hexiv:string"
  134. Used by GMAC to specify an IV in hexadecimal form (two hex digits per byte).
  135. .IP \fBsize:\fR\fIint\fR 4
  136. .IX Item "size:int"
  137. Used by KMAC128 or KMAC256 to specify an output length.
  138. The default sizes are 32 or 64 bytes respectively.
  139. .IP \fBcustom:\fR\fIstring\fR 4
  140. .IX Item "custom:string"
  141. Used by KMAC128 or KMAC256 to specify a customization string.
  142. The default is the empty string "".
  143. .IP \fBdigest:\fR\fIstring\fR 4
  144. .IX Item "digest:string"
  145. This option is identical to the \fB\-digest\fR option.
  146. .IP \fBcipher:\fR\fIstring\fR 4
  147. .IX Item "cipher:string"
  148. This option is identical to the \fB\-cipher\fR option.
  149. .RE
  150. .RS 4
  151. .RE
  152. .IP "\fB\-provider\fR \fIname\fR" 4
  153. .IX Item "-provider name"
  154. .PD 0
  155. .IP "\fB\-provider\-path\fR \fIpath\fR" 4
  156. .IX Item "-provider-path path"
  157. .IP "\fB\-propquery\fR \fIpropq\fR" 4
  158. .IX Item "-propquery propq"
  159. .PD
  160. See "Provider Options" in \fBopenssl\fR\|(1), \fBprovider\fR\|(7), and \fBproperty\fR\|(7).
  161. .IP \fImac_name\fR 4
  162. .IX Item "mac_name"
  163. Specifies the name of a supported MAC algorithm which will be used.
  164. To see the list of supported MAC's use the command \f(CW\*(C`openssl list
  165. \&\-mac\-algorithms\*(C'\fR.
  166. .SH EXAMPLES
  167. .IX Header "EXAMPLES"
  168. To create a hex-encoded HMAC\-SHA1 MAC of a file and write to stdout:
  169. .PP
  170. .Vb 3
  171. \& openssl mac \-digest SHA1 \e
  172. \& \-macopt hexkey:000102030405060708090A0B0C0D0E0F10111213 \e
  173. \& \-in msg.bin HMAC
  174. .Ve
  175. .PP
  176. To create a SipHash MAC from a file with a binary file output:
  177. .PP
  178. .Vb 2
  179. \& openssl mac \-macopt hexkey:000102030405060708090A0B0C0D0E0F \e
  180. \& \-in msg.bin \-out out.bin \-binary SipHash
  181. .Ve
  182. .PP
  183. To create a hex-encoded CMAC\-AES\-128\-CBC MAC from a file:
  184. .PP
  185. .Vb 3
  186. \& openssl mac \-cipher AES\-128\-CBC \e
  187. \& \-macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B \e
  188. \& \-in msg.bin CMAC
  189. .Ve
  190. .PP
  191. To create a hex-encoded KMAC128 MAC from a file with a Customisation String
  192. \&'Tag' and output length of 16:
  193. .PP
  194. .Vb 2
  195. \& openssl mac \-macopt custom:Tag \-macopt hexkey:40414243444546 \e
  196. \& \-macopt size:16 \-in msg.bin KMAC128
  197. .Ve
  198. .PP
  199. To create a hex-encoded GMAC\-AES\-128\-GCM with a IV from a file:
  200. .PP
  201. .Vb 2
  202. \& openssl mac \-cipher AES\-128\-GCM \-macopt hexiv:E0E00F19FED7BA0136A797F3 \e
  203. \& \-macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B \-in msg.bin GMAC
  204. .Ve
  205. .SH NOTES
  206. .IX Header "NOTES"
  207. The MAC mechanisms that are available will depend on the options
  208. used when building OpenSSL.
  209. Use \f(CW\*(C`openssl list \-mac\-algorithms\*(C'\fR to list them.
  210. .SH "SEE ALSO"
  211. .IX Header "SEE ALSO"
  212. \&\fBopenssl\fR\|(1),
  213. \&\fBEVP_MAC\fR\|(3),
  214. \&\fBEVP_MAC\-CMAC\fR\|(7),
  215. \&\fBEVP_MAC\-GMAC\fR\|(7),
  216. \&\fBEVP_MAC\-HMAC\fR\|(7),
  217. \&\fBEVP_MAC\-KMAC\fR\|(7),
  218. \&\fBEVP_MAC\-Siphash\fR\|(7),
  219. \&\fBEVP_MAC\-Poly1305\fR\|(7)
  220. .SH COPYRIGHT
  221. .IX Header "COPYRIGHT"
  222. Copyright 2018\-2024 The OpenSSL Project Authors. All Rights Reserved.
  223. .PP
  224. Licensed under the Apache License 2.0 (the "License"). You may not use
  225. this file except in compliance with the License. You can obtain a copy
  226. in the file LICENSE in the source distribution or at
  227. <https://www.openssl.org/source/license.html>.