diff --git a/.gitignore b/.gitignore index 55728e49..2705565e 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ .DS_Store *.swp +/Output diff --git a/cores/nRF5/rtos.h b/cores/nRF5/rtos.h index 03bd4479..0badd2ba 100644 --- a/cores/nRF5/rtos.h +++ b/cores/nRF5/rtos.h @@ -41,7 +41,6 @@ #include #include #include -#include #include "common_func.h" diff --git a/libraries/BLEHomekit/src/crypto/srp/config.h b/libraries/BLEHomekit/src/crypto/srp/config.h index eede0c3a..247a8b9e 100644 --- a/libraries/BLEHomekit/src/crypto/srp/config.h +++ b/libraries/BLEHomekit/src/crypto/srp/config.h @@ -163,7 +163,7 @@ * Uncomment to prevent default assignment of standard functions in the * platform layer. */ -//#define POLARSSL_PLATFORM_NO_STD_FUNCTIONS +#define POLARSSL_PLATFORM_NO_STD_FUNCTIONS /** * \def POLARSSL_PLATFORM_XXX_ALT @@ -2305,9 +2305,9 @@ //#define POLARSSL_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */ /* Platform options */ -//#define POLARSSL_PLATFORM_STD_MEM_HDR /**< Header to include if POLARSSL_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */ -//#define POLARSSL_PLATFORM_STD_MALLOC malloc /**< Default allocator to use, can be undefined */ -//#define POLARSSL_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */ +#define POLARSSL_PLATFORM_STD_MEM_HDR "rtos.h"/**< Header to include if POLARSSL_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */ +#define POLARSSL_PLATFORM_STD_MALLOC rtos_malloc /**< Default allocator to use, can be undefined */ +#define POLARSSL_PLATFORM_STD_FREE rtos_free /**< Default free to use, can be undefined */ //#define POLARSSL_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */ //#define POLARSSL_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */ //#define POLARSSL_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */ diff --git a/libraries/BLEHomekit/src/crypto/srp/srp.c b/libraries/BLEHomekit/src/crypto/srp/srp.c index 2b87f355..ffeee9ad 100644 --- a/libraries/BLEHomekit/src/crypto/srp/srp.c +++ b/libraries/BLEHomekit/src/crypto/srp/srp.c @@ -25,7 +25,7 @@ //#include "homekit/pairing.h" #include "common_inc.h" -#include "rtos.h" +#include "nrf_error.h" #define E(V) (((V) << 24) | ((V) >> 24) | (((V) >> 8) & 0x0000FF00) | (((V) << 8) & 0x00FF0000)) static const uint32_t srp_N[] = @@ -80,7 +80,9 @@ srp_keys_t srp; #define MPI_ERROR_CHECK(_code) VERIFY_STATUS(_code, ) - +/** + * Adafruit: re-calculate x if p changes (setup code) + */ void srp_init(void) { int err_code; @@ -88,10 +90,10 @@ void srp_init(void) // The MPI library uses a ridiculous amount of memory. We use the stack allocator // so we don't tie this memory up except when we absolutely need to. // uint8_t memory[11 * 1024]; - uint8_t* memory = (uint8_t*) rtos_malloc(11*1024); - VERIFY(memory, ); - - memory_buffer_alloc_init(memory, sizeof(memory)); +// uint8_t* memory = (uint8_t*) rtos_malloc(11*1024); +// VERIFY(memory, ); +// +// memory_buffer_alloc_init(memory, sizeof(memory)); // Generate salt random_create(srp.salt, sizeof(srp.salt)); @@ -166,8 +168,8 @@ void srp_init(void) mpi_free(&g); mpi_free(&x); - memory_buffer_alloc_free(); - rtos_free(memory); +// memory_buffer_alloc_free(); +// rtos_free(memory); } void srp_start(void) @@ -183,10 +185,10 @@ uint8_t srp_setA(uint8_t* abuf, uint16_t length, moretime_t moretime) // The MPI library uses a ridiculous amount of memory. We use the stack allocator // so we don't tie this memory up except when we absolutely need to. // uint8_t memory[11 * 1024]; - uint8_t* memory = (uint8_t*) rtos_malloc(11*1024); - VERIFY(memory, NRF_ERROR_NO_MEM); - - memory_buffer_alloc_init(memory, sizeof(memory)); +// uint8_t* memory = (uint8_t*) rtos_malloc(11*1024); +// VERIFY(memory, NRF_ERROR_NO_MEM); +// +// memory_buffer_alloc_init(memory, sizeof(memory)); // getK { @@ -261,8 +263,8 @@ uint8_t srp_setA(uint8_t* abuf, uint16_t length, moretime_t moretime) crypto_hash_sha512(srp.K, sbuf, sizeof(sbuf)); } - memory_buffer_alloc_free(); - rtos_free(memory); +// memory_buffer_alloc_free(); +// rtos_free(memory); // getM1 - username s abuf srp.B K {