SX126x-Arduino  2.0.1
cmac.h
Go to the documentation of this file.
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 #include "aes.h"
40 
41 extern "C"
42 {
43 #define AES_CMAC_KEY_LENGTH 16
44 #define AES_CMAC_DIGEST_LENGTH 16
45 
46  typedef struct _AES_CMAC_CTX
47  {
49  uint8_t X[16];
50  uint8_t M_last[16];
51  uint32_t M_n;
53 
54  //#include <sys/cdefs.h>
55 
56  //__BEGIN_DECLS
57  void AES_CMAC_Init(AES_CMAC_CTX *ctx);
58  void AES_CMAC_SetKey(AES_CMAC_CTX *ctx, const uint8_t key[AES_CMAC_KEY_LENGTH]);
59  void AES_CMAC_Update(AES_CMAC_CTX *ctx, const uint8_t *data, uint32_t len);
60  // __attribute__((__bounded__(__string__,2,3)));
61  void AES_CMAC_Final(uint8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX *ctx);
62  // __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH)));
63  //__END_DECLS
64 };
65 #endif /* _CMAC_H_ */
AES_CMAC_DIGEST_LENGTH
#define AES_CMAC_DIGEST_LENGTH
Definition: cmac.h:44
_AES_CMAC_CTX::rijndael
lora_aes_context rijndael
Definition: cmac.h:48
AES_CMAC_SetKey
void AES_CMAC_SetKey(AES_CMAC_CTX *ctx, const uint8_t key[AES_CMAC_KEY_LENGTH])
Definition: cmac.cpp:72
AES_CMAC_Final
void AES_CMAC_Final(uint8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX *ctx)
Definition: cmac.cpp:114
aes.h
AES_CMAC_KEY_LENGTH
#define AES_CMAC_KEY_LENGTH
Definition: cmac.h:43
AES_CMAC_Update
void AES_CMAC_Update(AES_CMAC_CTX *ctx, const uint8_t *data, uint32_t len)
Definition: cmac.cpp:78
_AES_CMAC_CTX::X
uint8_t X[16]
Definition: cmac.h:49
_AES_CMAC_CTX::M_n
uint32_t M_n
Definition: cmac.h:51
lora_aes_context
Definition: aes.h:69
_AES_CMAC_CTX
Definition: cmac.h:47
AES_CMAC_CTX
struct _AES_CMAC_CTX AES_CMAC_CTX
_AES_CMAC_CTX::M_last
uint8_t M_last[16]
Definition: cmac.h:50
AES_CMAC_Init
void AES_CMAC_Init(AES_CMAC_CTX *ctx)
Definition: cmac.cpp:65