1 /**************************************************************************
2 Copyright (C) 2009 Lander Casado, Philippas Tsigas
3 
4 All rights reserved.
5 
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal with the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
13 
14 Redistributions of source code must retain the above copyright notice,
15 this list of conditions and the following disclaimers. Redistributions in
16 binary form must reproduce the above copyright notice, this list of
17 conditions and the following disclaimers in the documentation and/or
18 other materials provided with the distribution.
19 
20 In no event shall the authors or copyright holders be liable for any special,
21 incidental, indirect or consequential damages of any kind, or any damages
22 whatsoever resulting from loss of use, data or profits, whether or not
23 advised of the possibility of damage, and on any theory of liability,
24 arising out of or in connection with the use or performance of this software.
25 
26 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
27 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29 CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
31 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
32 DEALINGS WITH THE SOFTWARE
33 
34 *****************************************************************************/
35 
36 #ifndef _CMAC_H_
37 #define _CMAC_H_
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 #include "aes.h"
44 
45 #define AES_CMAC_KEY_LENGTH     16
46 #define AES_CMAC_DIGEST_LENGTH  16
47 
48 typedef struct _AES_CMAC_CTX {
49             aes_context    rijndael;
50             uint8_t        X[16];
51             uint8_t        M_last[16];
52             uint32_t       M_n;
53     } AES_CMAC_CTX;
54 
55 //#include <sys/cdefs.h>
56 
57 //__BEGIN_DECLS
58 void     AES_CMAC_Init(AES_CMAC_CTX * ctx);
59 void     AES_CMAC_SetKey(AES_CMAC_CTX * ctx, const uint8_t key[AES_CMAC_KEY_LENGTH]);
60 void     AES_CMAC_Update(AES_CMAC_CTX * ctx, const uint8_t * data, uint32_t len);
61           //          __attribute__((__bounded__(__string__,2,3)));
62 void     AES_CMAC_Final(uint8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX  * ctx);
63             //     __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH)));
64 //__END_DECLS
65 
66 #ifdef __cplusplus
67 }
68 #endif
69 
70 #endif /* _CMAC_H_ */
71 
72