]> cvs.zerfleddert.de Git - proxmark3-svn/blob - common/polarssl/aes_cmac128.h
b792755fc41c4329738410633e0a6cb5b2067ac9
[proxmark3-svn] / common / polarssl / aes_cmac128.h
1 /*
2 * AES-CMAC from NIST Special Publication 800-38B \97 Recommendation for block cipher modes of operation: The CMAC mode for authentication.
3 *
4 * Copyright (C) 2006-2014, Brainspark B.V.
5 * Copyright (C) 2014, Anargyros Plemenos
6 * Tests added Merkok, 2018
7 *
8 * This file is part of PolarSSL (http://www.polarssl.org)
9 * Lead Maintainer: Paul Bakker <polarssl_maintainer at polarssl.org>
10 *
11 * All rights reserved.
12 *
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 2 of the License, or
16 * (at your option) any later version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
26 *
27 * Reference : https://polarssl.org/discussions/generic/authentication-token
28 * NIST Special Publication 800-38B \97 Recommendation for block cipher modes of operation: The CMAC mode for authentication.
29 * Tests here:
30 * https://csrc.nist.gov/CSRC/media/Projects/Cryptographic-Standards-and-Guidelines/documents/examples/AES_CMAC.pdf
31 */
32
33 #include <stdint.h>
34 #include <stddef.h>
35 #include "aes.h"
36
37 typedef struct aes_cmac_128_context {
38 aes_context aes_key;
39
40 uint8_t K1[16];
41 uint8_t K2[16];
42
43 uint8_t X[16];
44
45 uint8_t last[16];
46 size_t last_len;
47 }
48 aes_cmac128_context;
49
50 /*
51 * \brief AES-CMAC-128 context setup
52 *
53 * \param ctx context to be initialized
54 * \param key secret key for AES-128
55 */
56 void aes_cmac128_starts(aes_cmac128_context *ctx, const uint8_t K[16]);
57
58 /*
59 * \brief AES-CMAC-128 process message
60 *
61 * \param ctx context to be initialized
62 * \param _msg the given message
63 * \param _msg_len the length of message
64 */
65 void aes_cmac128_update(aes_cmac128_context *ctx, const uint8_t *_msg, size_t _msg_len);
66
67 /*
68 * \brief AES-CMAC-128 compute T
69 *
70 * \param ctx context to be initialized
71 * \param T the generated MAC which is used to validate the message
72 */
73 void aes_cmac128_final(aes_cmac128_context *ctx, uint8_t T[16]);
74
75 /**
76 * \brief Checkup routine
77 *
78 * \return 0 if successful, or 1 if the test failed
79 */
80 int aes_cmac_self_test( int verbose );
81
Impressum, Datenschutz