OPENSSL-MAC(1ossl)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

πŸ’– NAME πŸ’–

openssl-mac β€” bestie, this is the one that does Message Authentication Code operations ✨ (that's the manual page for the 1ossl section, iykyk πŸŽ€)


🌸 SYNOPSIS 🌸

openssl mac [-help] [-cipher] [-digest] [-macopt] [-in filename] [-out
filename] [-binary] [-provider name] [-provider-path path] [-provparam
[name:]key=value] [-propquery propq] mac_name

πŸ¦‹ DESCRIPTION πŸ¦‹

Okay so the message authentication code functions literally just spit out the MAC of an input file you hand them. That's the whole vibe. Input goes in, MAC comes out, slay πŸ’…


✨ OPTIONS ✨

  • -help β€” prints a usage message, the classic "help me help you" moment 🫢
  • -in filename β€” the input filename you want a MAC calculated for. If you don't give one, it takes standard input by default. And yeah, if the filename is literally -, that also means standard input. Files and standard input are expected to be in binary format btw, no cap.
  • -out filename β€” where the output goes, or standard output by default if you don't specify πŸ’«
  • -binary β€” outputs the MAC in binary form. If you don't pass this, it uses hexadecimal text format instead. Choose your fighter πŸŽ€
  • -cipher name β€” used by CMAC and GMAC to specify the cipher algorithm. For CMAC it should be a CBC mode cipher, e.g. AES-128-CBC. For GMAC it should be a GCM mode cipher, e.g. AES-128-GCM. Don't mix them up bestie, it's giving wrong-cipher-for-the-mode 😭
  • -digest name β€” used by HMAC as an alphanumeric string (use this if the key contains printable characters only, fr fr). The string length must conform to any restrictions of the MAC algorithm. Wanna see the list of supported digests? Run openssl list -digest-commands and thank me later ✨
  • -macopt nm:v β€” passes options to the MAC algorithm. A comprehensive list of controls lives in the EVP_MAC implementation documentation. Common parameter names used by EVP_MAC_CTX_get_params() are:
    • key:string β€” specifies the MAC key as an alphanumeric string (use if the key contains printable characters only). The string length must conform to any restrictions of the MAC algorithm. A key must be specified for every MAC algorithm, no exceptions babe πŸ‘‘
    • hexkey:string β€” specifies the MAC key in hexadecimal form (two hex digits per byte). The key length must conform to any restrictions of the MAC algorithm. Again: a key must be specified for every MAC algorithm πŸ’…
    • iv:string β€” used by GMAC to specify an IV as an alphanumeric string (use if the IV contains printable characters only).
    • hexiv:string β€” used by GMAC to specify an IV in hexadecimal form (two hex digits per byte).
    • size:int β€” used by KMAC128 or KMAC256 to specify an output length. The default sizes are 32 or 64 bytes respectively.
    • custom:string β€” used by KMAC128 or KMAC256 to specify a customization string. The default is the empty string "".
    • digest:string β€” this option is identical to the -digest option πŸ”
    • cipher:string β€” this option is identical to the -cipher option πŸ”
  • -provider name β€” provider stuff, see below ⬇️
  • -provider-path path β€” also provider stuff ⬇️
  • -provparam [name:]key=value β€” more provider stuff ⬇️
  • -propquery propq β€” still provider stuff, and for all four of these, see "Provider Options" in openssl(1), provider(7), and property(7). That's the whole assignment 🫑
  • mac_name β€” specifies the name of a supported MAC algorithm which will be used. Wanna see the list of supported MAC's? Use the command openssl list -mac-algorithms and go off πŸ‘‘

πŸ”₯ EXAMPLES πŸ”₯

To create a hex-encoded HMAC-SHA1 MAC of a file and write to stdout:

openssl mac -digest SHA1 \
        -macopt hexkey:000102030405060708090A0B0C0D0E0F10111213 \
        -in msg.bin HMAC

To create a SipHash MAC from a file with a binary file output:

openssl mac -macopt hexkey:000102030405060708090A0B0C0D0E0F \
        -in msg.bin -out out.bin -binary SipHash

To create a hex-encoded CMAC-AES-128-CBC MAC from a file:

openssl mac -cipher AES-128-CBC \
        -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B \
        -in msg.bin CMAC

To create a hex-encoded KMAC128 MAC from a file with a Customisation String 'Tag' and output length of 16:

openssl mac -macopt custom:Tag -macopt hexkey:40414243444546 \
        -macopt size:16 -in msg.bin KMAC128

To create a hex-encoded GMAC-AES-128-GCM with a IV from a file:

openssl mac -cipher AES-128-GCM -macopt hexiv:E0E00F19FED7BA0136A797F3 \
        -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B -in msg.bin GMAC

🧚 NOTES 🧚

The MAC mechanisms that are available will depend on the options used when building OpenSSL β€” so like, your build config is the main character here 🌈. Use openssl list -mac-algorithms to list them all.


πŸ’œ SEE ALSO πŸ’œ

openssl(1), EVP_MAC(3), EVP_MAC-CMAC(7), EVP_MAC-GMAC(7), EVP_MAC-HMAC(7), EVP_MAC-KMAC(7), EVP_MAC-Siphash(7), EVP_MAC-Poly1305(7) β€” the whole friend group 🫢


Copyright 2018-2024 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>. Read the license bestie, it's not a suggestion πŸ’€


okay that's the whole page, mwah πŸ’‹ β€” this was OpenSSL version 3.5.6, dated 2026-04-07, page OPENSSL-MAC(1ossl). Go forth and authenticate those messages, icon ✨

πŸ“¦ where this page comes from