]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/cmac/cm_ameth.c
Revert "The EVP_MAC functions have been renamed for consistency. The EVP_MAC_CTX_*"
[thirdparty/openssl.git] / crypto / cmac / cm_ameth.c
CommitLineData
0f113f3e 1/*
33388b44 2 * Copyright 2010-2020 The OpenSSL Project Authors. All Rights Reserved.
c8ef656d 3 *
8de396f8 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
4f22f405
RS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
c8ef656d
DSH
8 */
9
a6d572e6
P
10/*
11 * CMAC low level APIs are deprecated for public use, but still ok for internal
12 * use.
13 */
14#include "internal/deprecated.h"
15
c8ef656d 16#include <stdio.h>
b39fc560 17#include "internal/cryptlib.h"
c8ef656d 18#include <openssl/evp.h>
25f2138b 19#include "crypto/asn1.h"
c8ef656d 20
0f113f3e
MC
21/*
22 * CMAC "ASN1" method. This is just here to indicate the maximum CMAC output
23 * length and to free up a CMAC key.
c8ef656d
DSH
24 */
25
26static int cmac_size(const EVP_PKEY *pkey)
0f113f3e
MC
27{
28 return EVP_MAX_BLOCK_LENGTH;
29}
c8ef656d
DSH
30
31static void cmac_key_free(EVP_PKEY *pkey)
0f113f3e 32{
b8d77c9b 33 EVP_MAC_CTX *cmctx = EVP_PKEY_get0(pkey);
865adf97 34 EVP_MAC *mac = cmctx == NULL ? NULL : EVP_MAC_CTX_mac(cmctx);
e74bd290 35
865adf97 36 EVP_MAC_CTX_free(cmctx);
e74bd290 37 EVP_MAC_free(mac);
0f113f3e 38}
c8ef656d 39
0f113f3e
MC
40const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = {
41 EVP_PKEY_CMAC,
42 EVP_PKEY_CMAC,
43 0,
c8ef656d 44
0f113f3e
MC
45 "CMAC",
46 "OpenSSL CMAC method",
c8ef656d 47
0f113f3e 48 0, 0, 0, 0,
c8ef656d 49
0f113f3e 50 0, 0, 0,
c8ef656d 51
0f113f3e
MC
52 cmac_size,
53 0, 0,
54 0, 0, 0, 0, 0, 0, 0,
c8ef656d 55
0f113f3e
MC
56 cmac_key_free,
57 0,
58 0, 0
59};