openssl-mac.pod.in 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  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 must be one of AES-128-CBC, AES-192-CBC, AES-256-CBC or
  34. DES-EDE3-CBC.
  35. For GMAC it should be a GCM mode cipher e.g. AES-128-GCM.
  36. =item B<-digest> I<name>
  37. Used by HMAC as an alphanumeric string (use if the key contains printable
  38. characters only).
  39. The string length must conform to any restrictions of the MAC algorithm.
  40. To see the list of supported digests, use C<openssl list -digest-commands>.
  41. =item B<-macopt> I<nm>:I<v>
  42. Passes options to the MAC algorithm.
  43. A comprehensive list of controls can be found in the EVP_MAC implementation
  44. documentation.
  45. Common parameter names used by EVP_MAC_CTX_get_params() are:
  46. =over 4
  47. =item B<key:>I<string>
  48. Specifies the MAC key as an alphanumeric string (use if the key contains
  49. printable characters only).
  50. The string length must conform to any restrictions of the MAC algorithm.
  51. A key must be specified for every MAC algorithm.
  52. =item B<hexkey:>I<string>
  53. Specifies the MAC key in hexadecimal form (two hex digits per byte).
  54. The key length must conform to any restrictions of the MAC algorithm.
  55. A key must be specified for every MAC algorithm.
  56. =item B<iv:>I<string>
  57. Used by GMAC to specify an IV as an alphanumeric string (use if the IV contains
  58. printable characters only).
  59. =item B<hexiv:>I<string>
  60. Used by GMAC to specify an IV in hexadecimal form (two hex digits per byte).
  61. =item B<size:>I<int>
  62. Used by KMAC128 or KMAC256 to specify an output length.
  63. The default sizes are 32 or 64 bytes respectively.
  64. =item B<custom:>I<string>
  65. Used by KMAC128 or KMAC256 to specify a customization string.
  66. The default is the empty string "".
  67. =item B<digest:>I<string>
  68. This option is identical to the B<-digest> option.
  69. =item B<cipher:>I<string>
  70. This option is identical to the B<-cipher> option.
  71. =back
  72. {- $OpenSSL::safe::opt_provider_item -}
  73. =item I<mac_name>
  74. Specifies the name of a supported MAC algorithm which will be used.
  75. To see the list of supported MAC's use the command C<openssl list
  76. -mac-algorithms>.
  77. =back
  78. =head1 EXAMPLES
  79. To create a hex-encoded HMAC-SHA1 MAC of a file and write to stdout: \
  80. openssl mac -digest SHA1 \
  81. -macopt hexkey:000102030405060708090A0B0C0D0E0F10111213 \
  82. -in msg.bin HMAC
  83. To create a SipHash MAC from a file with a binary file output: \
  84. openssl mac -macopt hexkey:000102030405060708090A0B0C0D0E0F \
  85. -in msg.bin -out out.bin -binary SipHash
  86. To create a hex-encoded CMAC-AES-128-CBC MAC from a file:\
  87. openssl mac -cipher AES-128-CBC \
  88. -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B \
  89. -in msg.bin CMAC
  90. To create a hex-encoded KMAC128 MAC from a file with a Customisation String
  91. 'Tag' and output length of 16: \
  92. openssl mac -macopt custom:Tag -macopt hexkey:40414243444546 \
  93. -macopt size:16 -in msg.bin KMAC128
  94. To create a hex-encoded GMAC-AES-128-GCM with a IV from a file: \
  95. openssl mac -cipher AES-128-GCM -macopt hexiv:E0E00F19FED7BA0136A797F3 \
  96. -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B -in msg.bin GMAC
  97. =head1 NOTES
  98. The MAC mechanisms that are available will depend on the options
  99. used when building OpenSSL.
  100. Use C<openssl list -mac-algorithms> to list them.
  101. =head1 SEE ALSO
  102. L<openssl(1)>,
  103. L<EVP_MAC(3)>,
  104. L<EVP_MAC-CMAC(7)>,
  105. L<EVP_MAC-GMAC(7)>,
  106. L<EVP_MAC-HMAC(7)>,
  107. L<EVP_MAC-KMAC(7)>,
  108. L<EVP_MAC-Siphash(7)>,
  109. L<EVP_MAC-Poly1305(7)>
  110. =head1 COPYRIGHT
  111. Copyright 2018-2021 The OpenSSL Project Authors. All Rights Reserved.
  112. Licensed under the Apache License 2.0 (the "License"). You may not use
  113. this file except in compliance with the License. You can obtain a copy
  114. in the file LICENSE in the source distribution or at
  115. L<https://www.openssl.org/source/license.html>.
  116. =cut