-
Notifications
You must be signed in to change notification settings - Fork 0
/
lorawan_aes.c
47 lines (44 loc) · 1.98 KB
/
lorawan_aes.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/********************************************************************
* Copyright (C) 2016 Microchip Technology Inc. and its subsidiaries
* (Microchip). All rights reserved.
*
* You are permitted to use the software and its derivatives with Microchip
* products. See the license agreement accompanying this software, if any, for
* more info about your rights and obligations.
*
* SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
* MERCHANTABILITY, TITLE, NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR
* PURPOSE. IN NO EVENT SHALL MICROCHIP, SMSC, OR ITS LICENSORS BE LIABLE OR
* OBLIGATED UNDER CONTRACT, NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH
* OF WARRANTY, OR OTHER LEGAL EQUITABLE THEORY FOR ANY DIRECT OR INDIRECT
* DAMAGES OR EXPENSES INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES, OR OTHER SIMILAR COSTS. To the fullest
* extend allowed by law, Microchip and its licensors liability will not exceed
* the amount of fees, if any, that you paid directly to Microchip to use this
* software.
*************************************************************************
*
* lorawan_aes.c
*
* LoRaWAN AES wrapper file
*
******************************************************************************/
/****************************** INCLUDES **************************************/
#include <stdint.h>
#include <string.h>
#include "AES.h"
/****************************** FUNCTIONS *************************************/
void AESEncodeLoRa(unsigned char* block, unsigned char* key)
{
uint8_t useKey[16];
memcpy(useKey, key, sizeof(useKey));
AESEncode(block, useKey);
}
void AESDecodeLoRa(unsigned char* block, unsigned char* key)
{
uint8_t useKey[16];
memcpy(useKey, key, sizeof(useKey));
AESCalcDecodeKey(useKey);
AESDecode(block, useKey);
}