openssl-mac.pod.in 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. =pod
  2. {- OpenSSL::safe::output_do_not_edit_headers(); -}
  3. =head1 NAME
  4. openssl-mac - perform Message Authentication Code operations
  5. =head1 SYNOPSIS
  6. B<openssl mac>
  7. [B<-help>]
  8. [B<-cipher>]
  9. [B<-digest>]
  10. [B<-macopt>]
  11. [B<-in> I<filename>]
  12. [B<-out> I<filename>]
  13. [B<-binary>]
  14. {- $OpenSSL::safe::opt_provider_synopsis -}
  15. I<mac_name>
  16. =head1 DESCRIPTION
  17. The message authentication code functions output the MAC of a supplied input
  18. file.
  19. =head1 OPTIONS
  20. =over 4
  21. =item B<-help>
  22. Print a usage message.
  23. =item B<-in> I<filename>
  24. Input filename to calculate a MAC for, or standard input by default.
  25. Standard input is used if the filename is '-'.
  26. Files and standard input are expected to be in binary format.
  27. =item B<-out> I<filename>
  28. Filename to output to, or standard output by default.
  29. =item B<-binary>
  30. Output the MAC in binary form. Uses hexadecimal text format if not specified.
  31. =item B<-cipher> I<name>
  32. Used by CMAC and GMAC to specify the cipher algorithm.
  33. For CMAC it should be a CBC mode cipher e.g. AES-128-CBC.
  34. For GMAC it should be a GCM mode cipher e.g. AES-128-GCM.
  35. =item B<-digest> I<name>
  36. Used by HMAC as an alphanumeric string (use if the key contains printable
  37. characters only).
  38. The string length must conform to any restrictions of the MAC algorithm.
  39. To see the list of supported digests, use C<openssl list -digest-commands>.
  40. =item B<-macopt> I<nm>:I<v>
  41. Passes options to the MAC algorithm.
  42. A comprehensive list of controls can be found in the EVP_MAC implementation
  43. documentation.
  44. Common parameter names used by EVP_MAC_CTX_get_params() are:
  45. =over 4
  46. =item B<key:>I<string>
  47. Specifies the MAC key as an alphanumeric string (use if the key contains
  48. printable characters only).
  49. The string length must conform to any restrictions of the MAC algorithm.
  50. A key must be specified for every MAC algorithm.
  51. =item B<hexkey:>I<string>
  52. Specifies the MAC key in hexadecimal form (two hex digits per byte).
  53. The key length must conform to any restrictions of the MAC algorithm.
  54. A key must be specified for every MAC algorithm.
  55. =item B<iv:>I<string>
  56. Used by GMAC to specify an IV as an alphanumeric string (use if the IV contains
  57. printable characters only).
  58. =item B<hexiv:>I<string>
  59. Used by GMAC to specify an IV in hexadecimal form (two hex digits per byte).
  60. =item B<size:>I<int>
  61. Used by KMAC128 or KMAC256 to specify an output length.
  62. The default sizes are 32 or 64 bytes respectively.
  63. =item B<custom:>I<string>
  64. Used by KMAC128 or KMAC256 to specify a customization string.
  65. The default is the empty string "".
  66. =item B<digest:>I<string>
  67. This option is identical to the B<-digest> option.
  68. =item B<cipher:>I<string>
  69. This option is identical to the B<-cipher> option.
  70. =back
  71. {- $OpenSSL::safe::opt_provider_item -}
  72. =item I<mac_name>
  73. Specifies the name of a supported MAC algorithm which will be used.
  74. To see the list of supported MAC's use the command C<openssl list
  75. -mac-algorithms>.
  76. =back
  77. =head1 EXAMPLES
  78. To create a hex-encoded HMAC-SHA1 MAC of a file and write to stdout:
  79. openssl mac -digest SHA1 \
  80. -macopt hexkey:000102030405060708090A0B0C0D0E0F10111213 \
  81. -in msg.bin HMAC
  82. To create a SipHash MAC from a file with a binary file output:
  83. openssl mac -macopt hexkey:000102030405060708090A0B0C0D0E0F \
  84. -in msg.bin -out out.bin -binary SipHash
  85. To create a hex-encoded CMAC-AES-128-CBC MAC from a file:
  86. openssl mac -cipher AES-128-CBC \
  87. -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B \
  88. -in msg.bin CMAC
  89. To create a hex-encoded KMAC128 MAC from a file with a Customisation String
  90. 'Tag' and output length of 16:
  91. openssl mac -macopt custom:Tag -macopt hexkey:40414243444546 \
  92. -macopt size:16 -in msg.bin KMAC128
  93. To create a hex-encoded GMAC-AES-128-GCM with a IV from a file:
  94. openssl mac -cipher AES-128-GCM -macopt hexiv:E0E00F19FED7BA0136A797F3 \
  95. -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B -in msg.bin GMAC
  96. =head1 NOTES
  97. The MAC mechanisms that are available will depend on the options
  98. used when building OpenSSL.
  99. Use C<openssl list -mac-algorithms> to list them.
  100. =head1 SEE ALSO
  101. L<openssl(1)>,
  102. L<EVP_MAC(3)>,
  103. L<EVP_MAC-CMAC(7)>,
  104. L<EVP_MAC-GMAC(7)>,
  105. L<EVP_MAC-HMAC(7)>,
  106. L<EVP_MAC-KMAC(7)>,
  107. L<EVP_MAC-Siphash(7)>,
  108. L<EVP_MAC-Poly1305(7)>
  109. =head1 COPYRIGHT
  110. Copyright 2018-2024 The OpenSSL Project Authors. All Rights Reserved.
  111. Licensed under the Apache License 2.0 (the "License"). You may not use
  112. this file except in compliance with the License. You can obtain a copy
  113. in the file LICENSE in the source distribution or at
  114. L<https://www.openssl.org/source/license.html>.
  115. =cut