[Cryptech-Commits] [sw/stm32] branch ksng updated: Add locking around keystore operations.

git at cryptech.is git at cryptech.is
Thu Feb 2 19:07:14 UTC 2017


This is an automated email from the git hooks/post-receive script.

sra at hactrn.net pushed a commit to branch ksng
in repository sw/stm32.

The following commit(s) were added to refs/heads/ksng by this push:
     new 0345b66  Add locking around keystore operations.
0345b66 is described below

commit 0345b661c6de52013788972b817320ad30b279ba
Author: Rob Austein <sra at hactrn.net>
AuthorDate: Thu Feb 2 14:04:21 2017 -0500

    Add locking around keystore operations.
---
 Makefile           |  1 +
 projects/hsm/hsm.c | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/Makefile b/Makefile
index 12ae4ef..2944aa9 100644
--- a/Makefile
+++ b/Makefile
@@ -102,6 +102,7 @@ CFLAGS += -mcpu=cortex-m4 -mthumb -mlittle-endian -mthumb-interwork
 CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
 CFLAGS += -DUSE_STDPERIPH_DRIVER -DSTM32F4XX -DSTM32F429xx
 CFLAGS += -D__CORTEX_M4 -DTARGET_STM -DTARGET_STM32F4 -DTARGET_STM32F429ZI -DTOOLCHAIN_GCC -D__FPU_PRESENT=1 -D$(BOARD)
+CFLAGS += -DENABLE_WEAK_FUNCTIONS
 CFLAGS += -ffunction-sections -fdata-sections -Wl,--gc-sections
 CFLAGS += -std=c99
 CFLAGS += -I$(TOPLEVEL)
diff --git a/projects/hsm/hsm.c b/projects/hsm/hsm.c
index 971d460..c2f6e0e 100644
--- a/projects/hsm/hsm.c
+++ b/projects/hsm/hsm.c
@@ -103,6 +103,15 @@ osMutexId  uart_mutex;
 osMutexDef(uart_mutex);
 #endif
 
+#if NUM_RPC_TASK > 1
+/* A mutex to arbitrate concurrent access to the keystore.
+ */
+osMutexId  ks_mutex;
+osMutexDef(ks_mutex);
+void hal_ks_lock(void)   { osMutexWait(ks_mutex, osWaitForever); }
+void hal_ks_unlock(void) { osMutexRelease(ks_mutex); }
+#endif
+
 static uint8_t uart_rx[2];	/* current character received from UART */
 
 /* Callback for HAL_UART_Receive_DMA().
@@ -261,6 +270,8 @@ int main()
 #if NUM_RPC_TASK > 1
     if ((uart_mutex = osMutexCreate(osMutex(uart_mutex))) == NULL)
 	Error_Handler();
+    if ((ks_mutex = osMutexCreate(osMutex(ks_mutex))) == NULL)
+	Error_Handler();
 #endif
 
     if (hal_rpc_server_init() != LIBHAL_OK)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Commits mailing list