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