Skip to content

Commit e9ae351

Browse files
Rename aes_encrypt to lmic_aes_encrypt
Apparently the ESP core already has a function named aes_encrypt, so this helps to compile this library on that platform.
1 parent 57b5dc6 commit e9ae351

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/aes/ideetron/AES-128_V10.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
// This file was taken from
3636
// https://github.com/Ideetron/RFM95W_Nexus/tree/master/LoRaWAN_V31 for
3737
// use with LMIC. It was only cosmetically modified:
38-
// - AES_Encrypt was renamed to aes_encrypt.
38+
// - AES_Encrypt was renamed to lmic_aes_encrypt.
3939
// - All other functions and variables were made static
4040
// - Tabs were converted to 2 spaces
4141
// - An #include and #if guard was added
@@ -72,7 +72,7 @@ static CONST_TABLE(unsigned char, S_Table)[16][16] = {
7272
{0x8C,0xA1,0x89,0x0D,0xBF,0xE6,0x42,0x68,0x41,0x99,0x2D,0x0F,0xB0,0x54,0xBB,0x16}
7373
};
7474

75-
extern "C" void aes_encrypt(unsigned char *Data, unsigned char *Key);
75+
extern "C" void lmic_aes_encrypt(unsigned char *Data, unsigned char *Key);
7676
static void AES_Add_Round_Key(unsigned char *Round_Key);
7777
static unsigned char AES_Sub_Byte(unsigned char Byte);
7878
static void AES_Shift_Rows();
@@ -88,7 +88,7 @@ static void Send_State();
8888
* *Key Key to encrypt data with is a 16 byte long arry
8989
*****************************************************************************************
9090
*/
91-
void aes_encrypt(unsigned char *Data, unsigned char *Key)
91+
void lmic_aes_encrypt(unsigned char *Data, unsigned char *Key)
9292
{
9393
unsigned char i;
9494
unsigned char Row,Collum;

src/aes/other.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* implementation. This file assumes that there is an encryption
2222
* function available with this signature:
2323
*
24-
* extern "C" void aes_encrypt(u1_t *data, u1_t *key);
24+
* extern "C" void lmic_aes_encrypt(u1_t *data, u1_t *key);
2525
*
2626
* That takes a single 16-byte buffer and encrypts it wit the given
2727
* 16-byte key.
@@ -32,7 +32,7 @@
3232
#if !defined(USE_ORIGINAL_AES)
3333

3434
// This should be defined elsewhere
35-
void aes_encrypt(u1_t *data, u1_t *key);
35+
void lmic_aes_encrypt(u1_t *data, u1_t *key);
3636

3737
// global area for passing parameters (aux, key) and for storing round keys
3838
u4_t AESAUX[16/sizeof(u4_t)];
@@ -55,7 +55,7 @@ static void shift_left(xref2u1_t buf, u1_t len) {
5555
// in any case. The CMAC result is returned in AESAUX as well.
5656
static void os_aes_cmac(xref2u1_t buf, u2_t len, u1_t prepend_aux) {
5757
if (prepend_aux)
58-
aes_encrypt(AESaux, AESkey);
58+
lmic_aes_encrypt(AESaux, AESkey);
5959
else
6060
memset (AESaux, 0, 16);
6161

@@ -79,7 +79,7 @@ static void os_aes_cmac(xref2u1_t buf, u2_t len, u1_t prepend_aux) {
7979
// shifts and xor on that.
8080
u1_t final_key[16];
8181
memset(final_key, 0, sizeof(final_key));
82-
aes_encrypt(final_key, AESkey);
82+
lmic_aes_encrypt(final_key, AESkey);
8383

8484
// Calculate K1
8585
u1_t msb = final_key[0] & 0x80;
@@ -100,7 +100,7 @@ static void os_aes_cmac(xref2u1_t buf, u2_t len, u1_t prepend_aux) {
100100
AESaux[i] ^= final_key[i];
101101
}
102102

103-
aes_encrypt(AESaux, AESkey);
103+
lmic_aes_encrypt(AESaux, AESkey);
104104
}
105105
}
106106

@@ -112,7 +112,7 @@ static void os_aes_ctr (xref2u1_t buf, u2_t len) {
112112
while (len) {
113113
// Encrypt the counter block with the selected key
114114
memcpy(ctr, AESaux, sizeof(ctr));
115-
aes_encrypt(ctr, AESkey);
115+
lmic_aes_encrypt(ctr, AESkey);
116116

117117
// Xor the payload with the resulting ciphertext
118118
for (u1_t i = 0; i < 16 && len > 0; i++, len--, buf++)
@@ -132,7 +132,7 @@ u4_t os_aes (u1_t mode, xref2u1_t buf, u2_t len) {
132132
case AES_ENC:
133133
// TODO: Check / handle when len is not a multiple of 16
134134
for (u1_t i = 0; i < len; i += 16)
135-
aes_encrypt(buf+i, AESkey);
135+
lmic_aes_encrypt(buf+i, AESkey);
136136
break;
137137

138138
case AES_CTR:

0 commit comments

Comments
 (0)