OPENSSL-MAC(1ossl)
π openssl-mac β the OpenSSL manual, but make it make sense
okay so bestie, this is openssl-mac from the OpenSSL manual set (1ossl section, iykyk) β the page that teaches you how to do Message Authentication Code stuff from the command line. grab a strawberry π, we're gonna get into it.
β¨ NAME β¨
openssl-mac β perform Message Authentication Code operations
like, literally, it makes MACs. no cap. π
π¦ 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
okay the way this is just the whole vibe in one line π every flag gets its own little moment below, don't worry.
πΈ DESCRIPTION πΈ
The message authentication code functions output the MAC of a supplied input file.
that's it. that's the whole thing. you give it input, it gives you a MAC. iconic behaviour honestly. π
π₯ OPTIONS π₯
-helpβ Print a usage message. your little "wait how does this work again" safety net π«Ά-in filenameβ Input filename to calculate a MAC for, or standard input by default. Standard input is used if the filename is-. Files and standard input are expected to be in binary format. so like, binary in, bestie β no fancy text parsing here, fr fr.-out filenameβ Filename to output to, or standard output by default. yes,-outmeans output. groundbreaking, i know. π-binaryβ Output the MAC in binary form. Uses hexadecimal text format if not specified. so if you don't pass this, you get cute lil hex text. if you do, it's raw bytes. choose wisely π-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. match the mode to the MAC, don't do it wrong π-digest nameβ Used by HMAC as an alphanumeric string (use if the key contains printable characters only). The string length must conform to any restrictions of the MAC algorithm. To see the list of supported digests, useopenssl list -digest-commands. lowkey this one's for when your key is all nice printable characters β¨-macopt nm:vβ Passes options to the MAC algorithm. A comprehensive list of controls can be found in theEVP_MACimplementation 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. yes, every one. mandatory. no key, no MAC, periodt. π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. A key must be specified for every MAC algorithm. same rule, hex edition π§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 are32or64bytes respectively. so yeah, those are the defaults, don't @ me π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. literally the same thing, just living over here π¦cipher:stringβ This option is identical to the-cipheroption. also the same thing. twins fr fr.
-provider nameβ provider time! π-provider-path pathβ path for that provider π-provparam [name:]key=valueβ provider params, key=value style π-propquery propqβ property query, as one does β¨
all four of these: See "Provider Options" in openssl(1), provider(7), and property(7). that's where the lore lives, go read it π
mac_nameβ Specifies the name of a supported MAC algorithm which will be used. To see the list of supported MAC's use the commandopenssl list -mac-algorithms. this is the argument at the end, the main character of the whole command honestly π
π EXAMPLES π
bestie these are the good part, let's go π
one: 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
two: 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
see the -binary there? that's the raw-bytes vibe check π
three: 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
four: 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
look at that custom:Tag β personalized MAC, we love to see it π
five: 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. Use openssl list -mac-algorithms to list them.
so like, your build might not have everything. it's giving "depends on how she was compiled" π go check with that command before you get confused.
π 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, all tagged π
π«Ά 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>.
like yeah, legal stuff, but read it β it's the rules, bestie π
and that's the page!! this version is 3.5.0, dated 2026-09-25 β from the OPENSSL-MAC(1ossl) crew, OpenSSL edition. slay, go MAC something, ily π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- opensuse-leap 16.0: openssl-3 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms