Lmic AES changed to MbedTLS hw AES (experimental)
This commit is contained in:
parent
ad33f8fc76
commit
39204ef7fc
@ -89,10 +89,12 @@
|
||||
// implementation is optimized for speed on 32-bit processors using
|
||||
// fairly big lookup tables, but it takes up big amounts of flash on the
|
||||
// AVR architecture.
|
||||
#define USE_ORIGINAL_AES
|
||||
//#define USE_ORIGINAL_AES
|
||||
//
|
||||
// This selects the AES implementation written by Ideetroon for their
|
||||
// own LoRaWAN library. It also uses lookup tables, but smaller
|
||||
// byte-oriented ones, making it use a lot less flash space (but it is
|
||||
// also about twice as slow as the original).
|
||||
// #define USE_IDEETRON_AES
|
||||
//
|
||||
#define USE_MBEDTLS_AES
|
||||
|
28
src/mbedtls_aes.c
Normal file
28
src/mbedtls_aes.c
Normal file
@ -0,0 +1,28 @@
|
||||
/*******************************************************************************
|
||||
*
|
||||
* ttn-esp32 - The Things Network device library for ESP-IDF / SX127x
|
||||
*
|
||||
* Copyright (c) 2018 Manuel Bleichenbacher
|
||||
*
|
||||
* Licensed under MIT License
|
||||
* https://opensource.org/licenses/MIT
|
||||
*
|
||||
* AES encryption using ESP32's hardware AES unit.
|
||||
*******************************************************************************/
|
||||
|
||||
#include "mbedtls/aes.h"
|
||||
#include "lmic/oslmic.h"
|
||||
|
||||
#if defined(USE_MBEDTLS_AES)
|
||||
|
||||
void lmic_aes_encrypt(u1_t *data, u1_t *key)
|
||||
{
|
||||
mbedtls_aes_context ctx;
|
||||
mbedtls_aes_init(&ctx);
|
||||
mbedtls_aes_setkey_enc(&ctx, key, 128);
|
||||
mbedtls_aes_crypt_ecb(&ctx, MBEDTLS_AES_ENCRYPT, data, data);
|
||||
mbedtls_aes_free(&ctx);
|
||||
}
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user