inital draft

Dependencies:   mbed LoRaWAN-lib SX1272Liby

Fork of LoRaWAN-demo-72_tjm by Timothy Mulrooney

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 "aes.h" 
00040   
00041 #define AES_CMAC_KEY_LENGTH     16
00042 #define AES_CMAC_DIGEST_LENGTH  16
00043  
00044 typedef struct _AES_CMAC_CTX {
00045             aes_context    rijndael;
00046             uint8_t        X[16];
00047             uint8_t        M_last[16];
00048             uint32_t       M_n;
00049     } AES_CMAC_CTX;
00050    
00051 //#include <sys/cdefs.h>
00052     
00053 //__BEGIN_DECLS
00054 void     AES_CMAC_Init(AES_CMAC_CTX * ctx);
00055 void     AES_CMAC_SetKey(AES_CMAC_CTX * ctx, const uint8_t key[AES_CMAC_KEY_LENGTH]);
00056 void     AES_CMAC_Update(AES_CMAC_CTX * ctx, const uint8_t * data, uint32_t len);
00057           //          __attribute__((__bounded__(__string__,2,3)));
00058 void     AES_CMAC_Final(uint8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX  * ctx);
00059             //     __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH)));
00060 //__END_DECLS
00061 
00062 #endif /* _CMAC_H_ */
00063