OPENSSL-MAC(1ossl)
π 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? Runopenssl list -digest-commandsand 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 byEVP_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-digestoption πcipher:stringβ this option is identical to the-cipheroption π
-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" inopenssl(1),provider(7), andproperty(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 commandopenssl list -mac-algorithmsand 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 π
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
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms