fota lib for mdot

Dependents:   UQ_LoraWAN

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cmac.h Source File

cmac.h

00001 /**************************************************************************
00002 Copyright (C) 2009 Lander Casado, Philippas Tsigas
00003 
00004 All rights reserved.
00005 
00006 Permission is hereby granted, free of charge, to any person obtaining
00007 a copy of this software and associated documentation files 
00008 (the "Software"), to deal with the Software without restriction, including
00009 without limitation the rights to use, copy, modify, merge, publish, 
00010 distribute, sublicense, and/or sell copies of the Software, and to
00011 permit persons to whom the Software is furnished to do so, subject to
00012 the following conditions: 
00013 
00014 Redistributions of source code must retain the above copyright notice, 
00015 this list of conditions and the following disclaimers. Redistributions in
00016 binary form must reproduce the above copyright notice, this list of
00017 conditions and the following disclaimers in the documentation and/or 
00018 other materials provided with the distribution.
00019 
00020 In no event shall the authors or copyright holders be liable for any special,
00021 incidental, indirect or consequential damages of any kind, or any damages 
00022 whatsoever resulting from loss of use, data or profits, whether or not 
00023 advised of the possibility of damage, and on any theory of liability, 
00024 arising out of or in connection with the use or performance of this software.
00025  
00026 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00027 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00028 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00029 CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00030 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
00031 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
00032 DEALINGS WITH THE SOFTWARE
00033 
00034 *****************************************************************************/
00035 
00036 #ifndef _CMAC_H_
00037 #define _CMAC_H_
00038 
00039 #include "casado/aes.h"
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044   
00045 #define AES_CMAC_KEY_LENGTH     16
00046 #define AES_CMAC_DIGEST_LENGTH  16
00047  
00048 
00049 typedef unsigned char  u_int8_t;
00050 typedef unsigned int u_int;
00051 typedef struct _AES_CMAC_CTX {
00052             aes_context    rijndael;
00053             u_int8_t        X[16];
00054             u_int8_t        M_last[16];
00055             u_int           M_n;
00056     } AES_CMAC_CTX;
00057    
00058 //#include <sys/cdefs.h>
00059     
00060 //__BEGIN_DECLS
00061 void     AES_CMAC_Init(AES_CMAC_CTX * ctx);
00062 void     AES_CMAC_SetKey(AES_CMAC_CTX * ctx, const u_int8_t key[AES_CMAC_KEY_LENGTH]);
00063 void     AES_CMAC_Update(AES_CMAC_CTX * ctx, const u_int8_t * data, u_int len);
00064           //          __attribute__((__bounded__(__string__,2,3)));
00065 void     AES_CMAC_Final(u_int8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX  * ctx);
00066             //     __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH)));
00067 //__END_DECLS
00068 
00069 #ifdef __cplusplus
00070 }
00071 #endif
00072 
00073 #endif /* _CMAC_H_ */
00074 
00075