openssl-prebuild/linux_amd64/ssl/share/man/man3/EVP_MAC.3
2020-03-02 16:50:34 +00:00

514 lines
19 KiB
Groff
Executable File

.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings. \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote. \*(C+ will
.\" give a nicer C++. Capital omega is used to do unbreakable dashes and
.\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
. ds -- \(*W-
. ds PI pi
. if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
. if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch
. ds L" ""
. ds R" ""
. ds C` ""
. ds C' ""
'br\}
.el\{\
. ds -- \|\(em\|
. ds PI \(*p
. ds L" ``
. ds R" ''
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD. Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.ie \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. nr % 0
. rr F
.\}
.el \{\
. de IX
..
.\}
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear. Run. Save yourself. No user-serviceable parts.
. \" fudge factors for nroff and troff
.if n \{\
. ds #H 0
. ds #V .8m
. ds #F .3m
. ds #[ \f1
. ds #] \fP
.\}
.if t \{\
. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
. ds #V .6m
. ds #F 0
. ds #[ \&
. ds #] \&
.\}
. \" simple accents for nroff and troff
.if n \{\
. ds ' \&
. ds ` \&
. ds ^ \&
. ds , \&
. ds ~ ~
. ds /
.\}
.if t \{\
. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
. \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
. \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
. \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
. ds : e
. ds 8 ss
. ds o a
. ds d- d\h'-1'\(ga
. ds D- D\h'-1'\(hy
. ds th \o'bp'
. ds Th \o'LP'
. ds ae ae
. ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "EVP_MAC 3"
.TH EVP_MAC 3 "2020-03-02" "3.0.0-dev" "OpenSSL"
.\" For nroff, turn off justification. Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
EVP_MAC, EVP_MAC_fetch, EVP_MAC_up_ref, EVP_MAC_free,
EVP_MAC_is_a, EVP_MAC_number, EVP_MAC_names_do_all,
EVP_MAC_provider, EVP_MAC_get_params, EVP_MAC_gettable_params,
EVP_MAC_CTX, EVP_MAC_CTX_new, EVP_MAC_CTX_free, EVP_MAC_CTX_dup,
EVP_MAC_CTX_mac, EVP_MAC_CTX_get_params, EVP_MAC_CTX_set_params,
EVP_MAC_size, EVP_MAC_init, EVP_MAC_update, EVP_MAC_final,
EVP_MAC_gettable_ctx_params, EVP_MAC_settable_ctx_params,
EVP_MAC_do_all_provided \- EVP MAC routines
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\& #include <openssl/evp.h>
\&
\& typedef struct evp_mac_st EVP_MAC;
\& typedef struct evp_mac_ctx_st EVP_MAC_CTX;
\&
\& EVP_MAC *EVP_MAC_fetch(OPENSSL_CTX *libctx, const char *algorithm,
\& const char *properties);
\& int EVP_MAC_up_ref(EVP_MAC *mac);
\& void EVP_MAC_free(EVP_MAC *mac);
\& int EVP_MAC_is_a(const EVP_MAC *mac, const char *name);
\& int EVP_MAC_number(const EVP_MAC *mac);
\& void EVP_MAC_names_do_all(const EVP_MAC *mac,
\& void (*fn)(const char *name, void *data),
\& void *data);
\& const OSSL_PROVIDER *EVP_MAC_provider(const EVP_MAC *mac);
\& int EVP_MAC_get_params(EVP_MAC *mac, OSSL_PARAM params[]);
\&
\& EVP_MAC_CTX *EVP_MAC_CTX_new(EVP_MAC *mac);
\& void EVP_MAC_CTX_free(EVP_MAC_CTX *ctx);
\& EVP_MAC_CTX *EVP_MAC_CTX_dup(const EVP_MAC_CTX *src);
\& EVP_MAC *EVP_MAC_CTX_mac(EVP_MAC_CTX *ctx);
\& int EVP_MAC_CTX_get_params(EVP_MAC_CTX *ctx, OSSL_PARAM params[]);
\& int EVP_MAC_CTX_set_params(EVP_MAC_CTX *ctx, const OSSL_PARAM params[]);
\&
\& size_t EVP_MAC_size(EVP_MAC_CTX *ctx);
\& int EVP_MAC_init(EVP_MAC_CTX *ctx);
\& int EVP_MAC_update(EVP_MAC_CTX *ctx, const unsigned char *data, size_t datalen);
\& int EVP_MAC_final(EVP_MAC_CTX *ctx,
\& unsigned char *out, size_t *outl, size_t outsize);
\&
\& const OSSL_PARAM *EVP_MAC_gettable_params(const EVP_MAC *mac);
\& const OSSL_PARAM *EVP_MAC_gettable_ctx_params(const EVP_MAC *mac);
\& const OSSL_PARAM *EVP_MAC_settable_ctx_params(const EVP_MAC *mac);
\&
\& void EVP_MAC_do_all_provided(OPENSSL_CTX *libctx,
\& void (*fn)(EVP_MAC *mac, void *arg),
\& void *arg);
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
These types and functions help the application to calculate MACs of
different types and with different underlying algorithms if there are
any.
.PP
MACs are a bit complex insofar that some of them use other algorithms
for actual computation. \s-1HMAC\s0 uses a digest, and \s-1CMAC\s0 uses a cipher.
Therefore, there are sometimes two contexts to keep track of, one for
the \s-1MAC\s0 algorithm itself and one for the underlying computation
algorithm if there is one.
.PP
To make things less ambiguous, this manual talks about a \*(L"context\*(R" or
\&\*(L"\s-1MAC\s0 context\*(R", which is to denote the \s-1MAC\s0 level context, and about a
\&\*(L"underlying context\*(R", or \*(L"computation context\*(R", which is to denote the
context for the underlying computation algorithm if there is one.
.SS "Types"
.IX Subsection "Types"
\&\fB\s-1EVP_MAC\s0\fR is a type that holds the implementation of a \s-1MAC\s0.
.PP
\&\fB\s-1EVP_MAC_CTX\s0\fR is a context type that holds internal \s-1MAC\s0 information
as well as a reference to a computation context, for those MACs that
rely on an underlying computation algorithm.
.SS "Algorithm implementation fetching"
.IX Subsection "Algorithm implementation fetching"
\&\fIEVP_MAC_fetch()\fR fetches an implementation of a \s-1MAC\s0 \fIalgorithm\fR, given
a library context \fIlibctx\fR and a set of \fIproperties\fR.
See \*(L"Fetching algorithms\*(R" in \fIprovider\fR\|(7) for further information.
.PP
The returned value must eventually be freed with
\&\fIEVP_MAC_free\fR\|(3).
.PP
\&\fIEVP_MAC_up_ref()\fR increments the reference count of an already fetched
\&\s-1MAC\s0.
.PP
\&\fIEVP_MAC_free()\fR frees a fetched algorithm.
\&\s-1NULL\s0 is a valid parameter, for which this function is a no-op.
.SS "Context manipulation functions"
.IX Subsection "Context manipulation functions"
\&\fIEVP_MAC_CTX_new()\fR creates a new context for the \s-1MAC\s0 type \fImac\fR.
The created context can then be used with most other functions
described here.
.PP
\&\fIEVP_MAC_CTX_free()\fR frees the contents of the context, including an
underlying context if there is one, as well as the context itself.
\&\s-1NULL\s0 is a valid parameter, for which this function is a no-op.
.PP
\&\fIEVP_MAC_CTX_dup()\fR duplicates the \fIsrc\fR context and returns a newly allocated
context.
.PP
\&\fIEVP_MAC_CTX_mac()\fR returns the \fB\s-1EVP_MAC\s0\fR associated with the context
\&\fIctx\fR.
.SS "Computing functions"
.IX Subsection "Computing functions"
\&\fIEVP_MAC_init()\fR sets up the underlying context with information given
through diverse controls.
This should be called before calling \fIEVP_MAC_update()\fR and
\&\fIEVP_MAC_final()\fR.
.PP
\&\fIEVP_MAC_update()\fR adds \fIdatalen\fR bytes from \fIdata\fR to the \s-1MAC\s0 input.
.PP
\&\fIEVP_MAC_final()\fR does the final computation and stores the result in
the memory pointed at by \fIout\fR of size \fIoutsize\fR, and sets the number
of bytes written in \fI*outl\fR at.
If \fIout\fR is \s-1NULL\s0 or \fIoutsize\fR is too small, then no computation
is made.
To figure out what the output length will be and allocate space for it
dynamically, simply call with \fIout\fR being \s-1NULL\s0 and \fIoutl\fR
pointing at a valid location, then allocate space and make a second
call with \fIout\fR pointing at the allocated space.
.PP
\&\fIEVP_MAC_get_params()\fR retrieves details about the implementation
\&\fImac\fR.
The set of parameters given with \fIparams\fR determine exactly what
parameters should be retrieved.
Note that a parameter that is unknown in the underlying context is
simply ignored.
.PP
\&\fIEVP_MAC_CTX_get_params()\fR retrieves chosen parameters, given the
context \fIctx\fR and its underlying context.
The set of parameters given with \fIparams\fR determine exactly what
parameters should be retrieved.
Note that a parameter that is unknown in the underlying context is
simply ignored.
.PP
\&\fIEVP_MAC_CTX_set_params()\fR passes chosen parameters to the underlying
context, given a context \fIctx\fR.
The set of parameters given with \fIparams\fR determine exactly what
parameters are passed down.
Note that a parameter that is unknown in the underlying context is
simply ignored.
Also, what happens when a needed parameter isn't passed down is
defined by the implementation.
.PP
\&\fIEVP_MAC_gettable_params()\fR, \fIEVP_MAC_gettable_ctx_params()\fR and
\&\fIEVP_MAC_settable_ctx_params()\fR get a constant \fB\s-1OSSL_PARAM\s0\fR array that
describes the retrievable and settable parameters, i.e. parameters that
can be used with \fIEVP_MAC_get_params()\fR, \fIEVP_MAC_CTX_get_params()\fR
and \fIEVP_MAC_CTX_set_params()\fR, respectively.
See \s-1\fIOSSL_PARAM\s0\fR\|(3) for the use of \fB\s-1OSSL_PARAM\s0\fR as parameter descriptor.
.SS "Information functions"
.IX Subsection "Information functions"
\&\fIEVP_MAC_size()\fR returns the \s-1MAC\s0 output size for the given context.
.PP
\&\fIEVP_MAC_is_a()\fR checks if the given \fImac\fR is an implementation of an
algorithm that's identifiable with \fIname\fR.
.PP
\&\fIEVP_MAC_provider()\fR returns the provider that holds the implementation
of the given \fImac\fR.
.PP
\&\fIEVP_MAC_do_all_provided()\fR traverses all \s-1MAC\s0 implemented by all activated
providers in the given library context \fIlibctx\fR, and for each of the
implementations, calls the given function \fIfn\fR with the implementation method
and the given \fIarg\fR as argument.
.PP
\&\fIEVP_MAC_number()\fR returns the internal dynamic number assigned to
\&\fImac\fR.
.PP
\&\fIEVP_MAC_names_do_all()\fR traverses all names for \fImac\fR, and calls
\&\fIfn\fR with each name and \fIdata\fR.
.SH "PARAMETERS"
.IX Header "PARAMETERS"
Parameters are identified by name as strings, and have an expected
data type and maximum size.
OpenSSL has a set of macros for parameter names it expects to see in
its own \s-1MAC\s0 implementations.
Here, we show all three, the OpenSSL macro for the parameter name, the
name in string form, and a type description.
.PP
The standard parameter names are:
.ie n .IP """key"" (\fB\s-1OSSL_MAC_PARAM_KEY\s0\fR) <octet string>" 4
.el .IP "``key'' (\fB\s-1OSSL_MAC_PARAM_KEY\s0\fR) <octet string>" 4
.IX Item "key (OSSL_MAC_PARAM_KEY) <octet string>"
Its value is the \s-1MAC\s0 key as an array of bytes.
.Sp
For MACs that use an underlying computation algorithm, the algorithm
must be set first, see parameter names \*(L"algorithm\*(R" below.
.ie n .IP """iv"" (\fB\s-1OSSL_MAC_PARAM_IV\s0\fR) <octet string>" 4
.el .IP "``iv'' (\fB\s-1OSSL_MAC_PARAM_IV\s0\fR) <octet string>" 4
.IX Item "iv (OSSL_MAC_PARAM_IV) <octet string>"
Some \s-1MAC\s0 implementations require an \s-1IV\s0, this parameter sets the \s-1IV\s0.
.ie n .IP """custom"" (\fB\s-1OSSL_MAC_PARAM_CUSTOM\s0\fR) <octet string>" 4
.el .IP "``custom'' (\fB\s-1OSSL_MAC_PARAM_CUSTOM\s0\fR) <octet string>" 4
.IX Item "custom (OSSL_MAC_PARAM_CUSTOM) <octet string>"
Some \s-1MAC\s0 implementations (\s-1KMAC\s0, \s-1BLAKE2\s0) accept a Customization String,
this parameter sets the Customization String. The default value is the
empty string.
.ie n .IP """salt"" (\fB\s-1OSSL_MAC_PARAM_SALT\s0\fR) <octet string>" 4
.el .IP "``salt'' (\fB\s-1OSSL_MAC_PARAM_SALT\s0\fR) <octet string>" 4
.IX Item "salt (OSSL_MAC_PARAM_SALT) <octet string>"
This option is used by \s-1BLAKE2\s0 \s-1MAC\s0.
.ie n .IP """xof"" (\fB\s-1OSSL_MAC_PARAM_XOF\s0\fR) <integer>" 4
.el .IP "``xof'' (\fB\s-1OSSL_MAC_PARAM_XOF\s0\fR) <integer>" 4
.IX Item "xof (OSSL_MAC_PARAM_XOF) <integer>"
It's a simple flag, the value 0 or 1 are expected.
.Sp
This option is used by \s-1KMAC\s0.
.ie n .IP """flags"" (\fB\s-1OSSL_MAC_PARAM_FLAGS\s0\fR) <integer>" 4
.el .IP "``flags'' (\fB\s-1OSSL_MAC_PARAM_FLAGS\s0\fR) <integer>" 4
.IX Item "flags (OSSL_MAC_PARAM_FLAGS) <integer>"
These will set the \s-1MAC\s0 flags to the given numbers.
Some MACs do not support this option.
.ie n .IP """properties"" (\fB\s-1OSSL_MAC_PARAM_PROPERTIES\s0\fR) <\s-1UTF8\s0 string>" 4
.el .IP "``properties'' (\fB\s-1OSSL_MAC_PARAM_PROPERTIES\s0\fR) <\s-1UTF8\s0 string>" 4
.IX Item "properties (OSSL_MAC_PARAM_PROPERTIES) <UTF8 string>"
.PD 0
.ie n .IP """digest"" (\fB\s-1OSSL_MAC_PARAM_DIGEST\s0\fR) <\s-1UTF8\s0 string>" 4
.el .IP "``digest'' (\fB\s-1OSSL_MAC_PARAM_DIGEST\s0\fR) <\s-1UTF8\s0 string>" 4
.IX Item "digest (OSSL_MAC_PARAM_DIGEST) <UTF8 string>"
.ie n .IP """cipher"" (\fB\s-1OSSL_MAC_PARAM_CIPHER\s0\fR) <\s-1UTF8\s0 string>" 4
.el .IP "``cipher'' (\fB\s-1OSSL_MAC_PARAM_CIPHER\s0\fR) <\s-1UTF8\s0 string>" 4
.IX Item "cipher (OSSL_MAC_PARAM_CIPHER) <UTF8 string>"
.PD
For \s-1MAC\s0 implementations that use an underlying computation cipher or
digest, these parameters set what the algorithm should be.
.Sp
The value is always the name of the intended algorithm,
or the properties.
.Sp
Note that not all algorithms may support all digests.
\&\s-1HMAC\s0 does not support variable output length digests such as \s-1SHAKE128\s0
or \s-1SHAKE256\s0.
.ie n .IP """size"" (\fB\s-1OSSL_MAC_PARAM_SIZE\s0\fR) <unsigned integer>" 4
.el .IP "``size'' (\fB\s-1OSSL_MAC_PARAM_SIZE\s0\fR) <unsigned integer>" 4
.IX Item "size (OSSL_MAC_PARAM_SIZE) <unsigned integer>"
For \s-1MAC\s0 implementations that support it, set the output size that
\&\fIEVP_MAC_final()\fR should produce.
The allowed sizes vary between \s-1MAC\s0 implementations, but must never exceed
what can be given with a \fBsize_t\fR.
.PP
All these parameters should be used before the calls to any of
\&\fIEVP_MAC_init()\fR, \fIEVP_MAC_update()\fR and \fIEVP_MAC_final()\fR for a full
computation.
Anything else may give undefined results.
.SH "RETURN VALUES"
.IX Header "RETURN VALUES"
\&\fIEVP_MAC_fetch()\fR returns a pointer to a newly fetched \s-1EVP_MAC\s0, or
\&\s-1NULL\s0 if allocation failed.
.PP
\&\fIEVP_MAC_up_ref()\fR returns 1 on success, 0 on error.
.PP
\&\fIEVP_MAC_free()\fR returns nothing at all.
.PP
\&\fIEVP_MAC_is_a()\fR returns 1 if the given method can be identified with
the given name, otherwise 0.
.PP
\&\fIEVP_MAC_provider()\fR returns a pointer to the provider for the \s-1MAC\s0, or
\&\s-1NULL\s0 on error.
.PP
\&\fIEVP_MAC_CTX_new()\fR and \fIEVP_MAC_CTX_dup()\fR return a pointer to a newly
created \s-1EVP_MAC_CTX\s0, or \s-1NULL\s0 if allocation failed.
.PP
\&\fIEVP_MAC_CTX_free()\fR returns nothing at all.
.PP
\&\fIEVP_MAC_CTX_get_params()\fR and \fIEVP_MAC_CTX_set_params()\fR return 1 on
success, 0 on error.
.PP
\&\fIEVP_MAC_init()\fR, \fIEVP_MAC_update()\fR, and \fIEVP_MAC_final()\fR return 1 on success, 0
on error.
.PP
\&\fIEVP_MAC_size()\fR returns the expected output size, or 0 if it isn't
set.
If it isn't set, a call to \fIEVP_MAC_init()\fR should get it set.
.PP
\&\fIEVP_MAC_do_all_provided()\fR returns nothing at all.
.SH "EXAMPLES"
.IX Header "EXAMPLES"
.Vb 5
\& #include <stdlib.h>
\& #include <stdio.h>
\& #include <string.h>
\& #include <stdarg.h>
\& #include <unistd.h>
\&
\& #include <openssl/evp.h>
\& #include <openssl/err.h>
\& #include <openssl/params.h>
\&
\& int main() {
\& EVP_MAC *mac = EVP_MAC_fetch(NULL, getenv("MY_MAC"), NULL);
\& const char *cipher = getenv("MY_MAC_CIPHER");
\& const char *digest = getenv("MY_MAC_DIGEST");
\& const char *key = getenv("MY_KEY");
\& EVP_MAC_CTX *ctx = NULL;
\&
\& unsigned char buf[4096];
\& ssize_t read_l;
\& size_t final_l;
\&
\& size_t i;
\&
\& OSSL_PARAM params[4];
\& size_t params_n = 0;
\&
\& if (cipher != NULL)
\& params[params_n++] =
\& OSSL_PARAM_construct_utf8_string("cipher", cipher, 0, NULL);
\& if (digest != NULL)
\& params[params_n++] =
\& OSSL_PARAM_construct_utf8_string("digest", digest, 0, NULL);
\& params[params_n++] =
\& OSSL_PARAM_construct_octet_string("key", key, strlen(key), NULL);
\& params[params_n] = OSSL_PARAM_construct_end();
\&
\& if (mac == NULL
\& || key == NULL
\& || (ctx = EVP_MAC_CTX_new(mac)) == NULL
\& || EVP_MAC_CTX_set_params(ctx, params) <= 0)
\& goto err;
\&
\& if (!EVP_MAC_init(ctx))
\& goto err;
\&
\& while ( (read_l = read(STDIN_FILENO, buf, sizeof(buf))) > 0) {
\& if (!EVP_MAC_update(ctx, buf, read_l))
\& goto err;
\& }
\&
\& if (!EVP_MAC_final(ctx, buf, &final_l))
\& goto err;
\&
\& printf("Result: ");
\& for (i = 0; i < final_l; i++)
\& printf("%02X", buf[i]);
\& printf("\en");
\&
\& EVP_MAC_CTX_free(ctx);
\& EVP_MAC_free(mac);
\& exit(0);
\&
\& err:
\& EVP_MAC_CTX_free(ctx);
\& EVP_MAC_free(mac);
\& fprintf(stderr, "Something went wrong\en");
\& ERR_print_errors_fp(stderr);
\& exit (1);
\& }
.Ve
.PP
A run of this program, called with correct environment variables, can
look like this:
.PP
.Vb 3
\& $ MY_MAC=cmac MY_KEY=secret0123456789 MY_MAC_CIPHER=aes\-128\-cbc \e
\& LD_LIBRARY_PATH=. ./foo < foo.c
\& Result: C5C06683CD9DDEF904D754505C560A4E
.Ve
.PP
(in this example, that program was stored in \fIfoo.c\fR and compiled to
\&\fI./foo\fR)
.SH "SEE ALSO"
.IX Header "SEE ALSO"
\&\fIproperty\fR\|(7)
\&\s-1\fIOSSL_PARAM\s0\fR\|(3),
\&\s-1\fIEVP_MAC\-BLAKE2\s0\fR\|(7),
\&\s-1\fIEVP_MAC\-CMAC\s0\fR\|(7),
\&\s-1\fIEVP_MAC\-GMAC\s0\fR\|(7),
\&\s-1\fIEVP_MAC\-HMAC\s0\fR\|(7),
\&\s-1\fIEVP_MAC\-KMAC\s0\fR\|(7),
\&\fIEVP_MAC\-Siphash\fR\|(7),
\&\fIEVP_MAC\-Poly1305\fR\|(7)
.SH "HISTORY"
.IX Header "HISTORY"
These functions were added in OpenSSL 3.0.
.SH "COPYRIGHT"
.IX Header "COPYRIGHT"
Copyright 2018\-2019 The OpenSSL Project Authors. All Rights Reserved.
.PP
Licensed under the Apache License 2.0 (the \*(L"License\*(R"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file \s-1LICENSE\s0 in the source distribution or at
<https://www.openssl.org/source/license.html>.