]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/cmac/cm_ameth.c
Prepare EVP_MAC infrastructure for moving all MACs to providers
[thirdparty/openssl.git] / crypto / cmac / cm_ameth.c
CommitLineData
0f113f3e 1/*
b8d77c9b 2 * Copyright 2010-2018 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
10#include <stdio.h>
b39fc560 11#include "internal/cryptlib.h"
c8ef656d 12#include <openssl/evp.h>
5fe736e5 13#include "internal/asn1_int.h"
c8ef656d 14
0f113f3e
MC
15/*
16 * CMAC "ASN1" method. This is just here to indicate the maximum CMAC output
17 * length and to free up a CMAC key.
c8ef656d
DSH
18 */
19
20static int cmac_size(const EVP_PKEY *pkey)
0f113f3e
MC
21{
22 return EVP_MAX_BLOCK_LENGTH;
23}
c8ef656d
DSH
24
25static void cmac_key_free(EVP_PKEY *pkey)
0f113f3e 26{
b8d77c9b 27 EVP_MAC_CTX *cmctx = EVP_PKEY_get0(pkey);
e74bd290
RL
28 EVP_MAC *mac = cmctx == NULL ? NULL : EVP_MAC_CTX_mac(cmctx);
29
b8d77c9b 30 EVP_MAC_CTX_free(cmctx);
e74bd290 31 EVP_MAC_free(mac);
0f113f3e 32}
c8ef656d 33
0f113f3e
MC
34const EVP_PKEY_ASN1_METHOD cmac_asn1_meth = {
35 EVP_PKEY_CMAC,
36 EVP_PKEY_CMAC,
37 0,
c8ef656d 38
0f113f3e
MC
39 "CMAC",
40 "OpenSSL CMAC method",
c8ef656d 41
0f113f3e 42 0, 0, 0, 0,
c8ef656d 43
0f113f3e 44 0, 0, 0,
c8ef656d 45
0f113f3e
MC
46 cmac_size,
47 0, 0,
48 0, 0, 0, 0, 0, 0, 0,
c8ef656d 49
0f113f3e
MC
50 cmac_key_free,
51 0,
52 0, 0
53};