ot;, buf[i]);
    printf(&quot;\n&quot;);

    EVP_MAC_CTX_free(ctx);
    EVP_MAC_free(mac);
    exit(0);

 err:
    EVP_MAC_CTX_free(ctx);
    EVP_MAC_free(mac);
    fprintf(stderr, &quot;Something went wrong\n&quot;);
    ERR_print_errors_fp(stderr);
    exit (1);
}</code></pre>

<p>A run of this program, called with correct environment variables, can look like this:</p>

<pre><code>$ MY_MAC=cmac MY_KEY=secret0123456789 MY_MAC_CIPHER=aes-128-cbc \
  LD_LIBRARY_PATH=. ./foo &lt; foo.c
Result: C5C06683CD9DD