In the following we will generate MACs for HMAC, GMAC, CMAC, Blake2bmac, Blake2smac, KMAC128 and KMAC256. Overall, we will use an encryption key defined as a hex value for GMAC and CMAC, and a pass phrase for the others. The message is "hello".
Message Authenication Codes (MACs) with OpenSSL |
Outline
The followng is an example of a GMAC (using with stream mode, such as with GCM):
openssl mac -cipher AES-128-GCM -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B -in 1.txt GMAC 740DDAFDB2008F4E3C7D10B9141A84DF
The followng is an example of a CMAC (used with block mode ciphers):
openssl mac -cipher AES-128-CBC -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B -in 1.txt CMAC 8CDBB6E42ED45C8A98328ADC739D3E41
For a 256-bit key with AES-256-CBC:
openssl mac -cipher AES-256-CBC -macopt hexkey:77A77FAF290C1FA30C683DF16BA7A77B77A77FAF290C1FA30C683DF16BA7A77B -in 1.txt CMAC 12F029BB51AC78D457DAF414A25A57EE