2018-12-16 23:36:17 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*******************************************************************************/
|
|
|
|
|
2019-05-25 16:32:57 +02:00
|
|
|
#ifdef USE_MBEDTLS_AES
|
2018-12-16 23:36:17 +01:00
|
|
|
|
2019-05-25 16:32:57 +02:00
|
|
|
#include "mbedtls/aes.h"
|
|
|
|
#include "../../lmic/oslmic.h"
|
2018-12-16 23:36:17 +01:00
|
|
|
|
|
|
|
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
|