DeepCover Embedded Security in IoT: Public-key Secured Data Paths

Dependencies:   MaximInterface

The MAXREFDES155# is an internet-of-things (IoT) embedded-security reference design, built to authenticate and control a sensing node using elliptic-curve-based public-key cryptography with control and notification from a web server.

The hardware includes an ARM® mbed™ shield and attached sensor endpoint. The shield contains a DS2476 DeepCover® ECDSA/SHA-2 coprocessor, Wifi communication, LCD push-button controls, and status LEDs. The sensor endpoint is attached to the shield using a 300mm cable and contains a DS28C36 DeepCover ECDSA/SHA-2 authenticator, IR-thermal sensor, and aiming laser for the IR sensor. The MAXREFDES155# is equipped with a standard Arduino® form-factor shield connector for immediate testing using an mbed board such as the MAX32600MBED#. The combination of these two devices represent an IoT device. Communication to the web server is accomplished with the shield Wifi circuitry. Communication from the shield to the attached sensor module is accomplished over I2C . The sensor module represents an IoT endpoint that generates small data with a requirement for message authenticity/integrity and secure on/off operational control.

The design is hierarchical with each mbed platform and shield communicating data from the sensor node to a web server that maintains a centralized log and dispatches notifications as necessary. The simplicity of this design enables rapid integration into any star-topology IoT network to provide security with the low overhead and cost provided by the ECDSA-P256 asymmetric-key and SHA-256 symmetric-key algorithms.

More information about the MAXREFDES155# is available on the Maxim Integrated website.

Committer:
IanBenzMaxim
Date:
Tue Dec 03 12:56:25 2019 -0600
Revision:
18:c2631e985780
Parent:
16:a004191a79ab
Updated MaximInterface to version 2.1.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IanBenzMaxim 0:33d4e66780c0 1 /*
IanBenzMaxim 0:33d4e66780c0 2 * spawn.c - CC31xx/CC32xx Host Driver Implementation
IanBenzMaxim 0:33d4e66780c0 3 *
IanBenzMaxim 0:33d4e66780c0 4 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
IanBenzMaxim 0:33d4e66780c0 5 *
IanBenzMaxim 0:33d4e66780c0 6 *
IanBenzMaxim 0:33d4e66780c0 7 * Redistribution and use in source and binary forms, with or without
IanBenzMaxim 0:33d4e66780c0 8 * modification, are permitted provided that the following conditions
IanBenzMaxim 0:33d4e66780c0 9 * are met:
IanBenzMaxim 0:33d4e66780c0 10 *
IanBenzMaxim 0:33d4e66780c0 11 * Redistributions of source code must retain the above copyright
IanBenzMaxim 0:33d4e66780c0 12 * notice, this list of conditions and the following disclaimer.
IanBenzMaxim 0:33d4e66780c0 13 *
IanBenzMaxim 0:33d4e66780c0 14 * Redistributions in binary form must reproduce the above copyright
IanBenzMaxim 0:33d4e66780c0 15 * notice, this list of conditions and the following disclaimer in the
IanBenzMaxim 0:33d4e66780c0 16 * documentation and/or other materials provided with the
IanBenzMaxim 0:33d4e66780c0 17 * distribution.
IanBenzMaxim 0:33d4e66780c0 18 *
IanBenzMaxim 0:33d4e66780c0 19 * Neither the name of Texas Instruments Incorporated nor the names of
IanBenzMaxim 0:33d4e66780c0 20 * its contributors may be used to endorse or promote products derived
IanBenzMaxim 0:33d4e66780c0 21 * from this software without specific prior written permission.
IanBenzMaxim 0:33d4e66780c0 22 *
IanBenzMaxim 0:33d4e66780c0 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
IanBenzMaxim 0:33d4e66780c0 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
IanBenzMaxim 0:33d4e66780c0 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
IanBenzMaxim 0:33d4e66780c0 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
IanBenzMaxim 0:33d4e66780c0 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
IanBenzMaxim 0:33d4e66780c0 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
IanBenzMaxim 0:33d4e66780c0 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
IanBenzMaxim 0:33d4e66780c0 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
IanBenzMaxim 0:33d4e66780c0 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
IanBenzMaxim 0:33d4e66780c0 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
IanBenzMaxim 0:33d4e66780c0 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IanBenzMaxim 0:33d4e66780c0 34 *
IanBenzMaxim 0:33d4e66780c0 35 */
IanBenzMaxim 0:33d4e66780c0 36
IanBenzMaxim 0:33d4e66780c0 37
IanBenzMaxim 0:33d4e66780c0 38
IanBenzMaxim 0:33d4e66780c0 39 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 40 /* Include files */
IanBenzMaxim 0:33d4e66780c0 41 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 42 #include "simplelink.h"
IanBenzMaxim 0:33d4e66780c0 43 #include "protocol.h"
IanBenzMaxim 0:33d4e66780c0 44 #include "driver.h"
IanBenzMaxim 0:33d4e66780c0 45
IanBenzMaxim 0:33d4e66780c0 46
IanBenzMaxim 0:33d4e66780c0 47 #if (defined (SL_PLATFORM_MULTI_THREADED)) && (!defined (SL_PLATFORM_EXTERNAL_SPAWN))
IanBenzMaxim 0:33d4e66780c0 48
IanBenzMaxim 0:33d4e66780c0 49 #define _SL_MAX_INTERNAL_SPAWN_ENTRIES 10
IanBenzMaxim 0:33d4e66780c0 50
IanBenzMaxim 0:33d4e66780c0 51 typedef struct _SlInternalSpawnEntry_t
IanBenzMaxim 0:33d4e66780c0 52 {
IanBenzMaxim 0:33d4e66780c0 53 _SlSpawnEntryFunc_t pEntry;
IanBenzMaxim 0:33d4e66780c0 54 void* pValue;
IanBenzMaxim 0:33d4e66780c0 55 struct _SlInternalSpawnEntry_t* pNext;
IanBenzMaxim 0:33d4e66780c0 56 }_SlInternalSpawnEntry_t;
IanBenzMaxim 0:33d4e66780c0 57
IanBenzMaxim 0:33d4e66780c0 58 typedef struct
IanBenzMaxim 0:33d4e66780c0 59 {
IanBenzMaxim 0:33d4e66780c0 60 _SlInternalSpawnEntry_t SpawnEntries[_SL_MAX_INTERNAL_SPAWN_ENTRIES];
IanBenzMaxim 0:33d4e66780c0 61 _SlInternalSpawnEntry_t* pFree;
IanBenzMaxim 0:33d4e66780c0 62 _SlInternalSpawnEntry_t* pWaitForExe;
IanBenzMaxim 0:33d4e66780c0 63 _SlInternalSpawnEntry_t* pLastInWaitList;
IanBenzMaxim 0:33d4e66780c0 64 _SlSyncObj_t SyncObj;
IanBenzMaxim 0:33d4e66780c0 65 _SlLockObj_t LockObj;
IanBenzMaxim 0:33d4e66780c0 66 _u8 IrqWriteCnt;
IanBenzMaxim 0:33d4e66780c0 67 _u8 IrqReadCnt;
IanBenzMaxim 0:33d4e66780c0 68 void* pIrqFuncValue;
IanBenzMaxim 0:33d4e66780c0 69 }_SlInternalSpawnCB_t;
IanBenzMaxim 0:33d4e66780c0 70
IanBenzMaxim 0:33d4e66780c0 71 _SlInternalSpawnCB_t g_SlInternalSpawnCB;
IanBenzMaxim 0:33d4e66780c0 72
IanBenzMaxim 0:33d4e66780c0 73
IanBenzMaxim 0:33d4e66780c0 74 void _SlInternalSpawnTaskEntry()
IanBenzMaxim 0:33d4e66780c0 75 {
IanBenzMaxim 0:33d4e66780c0 76 _i16 i;
IanBenzMaxim 0:33d4e66780c0 77 _SlInternalSpawnEntry_t* pEntry;
IanBenzMaxim 0:33d4e66780c0 78 _u8 LastEntry;
IanBenzMaxim 0:33d4e66780c0 79
IanBenzMaxim 0:33d4e66780c0 80 /* create and lock the locking object. lock in order to avoid race condition
IanBenzMaxim 0:33d4e66780c0 81 on the first creation */
IanBenzMaxim 0:33d4e66780c0 82 sl_LockObjCreate(&g_SlInternalSpawnCB.LockObj,"SlSpawnProtect");
IanBenzMaxim 0:33d4e66780c0 83 sl_LockObjLock(&g_SlInternalSpawnCB.LockObj,SL_OS_NO_WAIT);
IanBenzMaxim 0:33d4e66780c0 84
IanBenzMaxim 0:33d4e66780c0 85 /* create and clear the sync object */
IanBenzMaxim 0:33d4e66780c0 86 sl_SyncObjCreate(&g_SlInternalSpawnCB.SyncObj,"SlSpawnSync");
IanBenzMaxim 0:33d4e66780c0 87 sl_SyncObjWait(&g_SlInternalSpawnCB.SyncObj,SL_OS_NO_WAIT);
IanBenzMaxim 0:33d4e66780c0 88
IanBenzMaxim 0:33d4e66780c0 89 g_SlInternalSpawnCB.pFree = &g_SlInternalSpawnCB.SpawnEntries[0];
IanBenzMaxim 0:33d4e66780c0 90 g_SlInternalSpawnCB.pWaitForExe = NULL;
IanBenzMaxim 0:33d4e66780c0 91 g_SlInternalSpawnCB.pLastInWaitList = NULL;
IanBenzMaxim 0:33d4e66780c0 92
IanBenzMaxim 0:33d4e66780c0 93 /* create the link list between the entries */
IanBenzMaxim 0:33d4e66780c0 94 for (i=0 ; i<_SL_MAX_INTERNAL_SPAWN_ENTRIES - 1 ; i++)
IanBenzMaxim 0:33d4e66780c0 95 {
IanBenzMaxim 0:33d4e66780c0 96 g_SlInternalSpawnCB.SpawnEntries[i].pNext = &g_SlInternalSpawnCB.SpawnEntries[i+1];
IanBenzMaxim 0:33d4e66780c0 97 g_SlInternalSpawnCB.SpawnEntries[i].pEntry = NULL;
IanBenzMaxim 0:33d4e66780c0 98 }
IanBenzMaxim 0:33d4e66780c0 99 g_SlInternalSpawnCB.SpawnEntries[i].pNext = NULL;
IanBenzMaxim 0:33d4e66780c0 100
IanBenzMaxim 0:33d4e66780c0 101 g_SlInternalSpawnCB.IrqWriteCnt =0;
IanBenzMaxim 0:33d4e66780c0 102 g_SlInternalSpawnCB.IrqReadCnt = 0;
IanBenzMaxim 0:33d4e66780c0 103 g_SlInternalSpawnCB.pIrqFuncValue = NULL;
IanBenzMaxim 0:33d4e66780c0 104
IanBenzMaxim 0:33d4e66780c0 105 SL_DRV_OBJ_UNLOCK(&g_SlInternalSpawnCB.LockObj);
IanBenzMaxim 0:33d4e66780c0 106
IanBenzMaxim 0:33d4e66780c0 107 /* here we ready to execute entries */
IanBenzMaxim 0:33d4e66780c0 108
IanBenzMaxim 0:33d4e66780c0 109 while (TRUE)
IanBenzMaxim 0:33d4e66780c0 110 {
IanBenzMaxim 0:33d4e66780c0 111 sl_SyncObjWait(&g_SlInternalSpawnCB.SyncObj,SL_OS_WAIT_FOREVER);
IanBenzMaxim 0:33d4e66780c0 112
IanBenzMaxim 0:33d4e66780c0 113 /* handle IRQ requests */
IanBenzMaxim 0:33d4e66780c0 114 while (g_SlInternalSpawnCB.IrqWriteCnt != g_SlInternalSpawnCB.IrqReadCnt)
IanBenzMaxim 0:33d4e66780c0 115 {
IanBenzMaxim 0:33d4e66780c0 116 /* handle the ones that came from ISR context*/
IanBenzMaxim 0:33d4e66780c0 117 _SlDrvMsgReadSpawnCtx(g_SlInternalSpawnCB.pIrqFuncValue);
IanBenzMaxim 0:33d4e66780c0 118 g_SlInternalSpawnCB.IrqReadCnt++;
IanBenzMaxim 0:33d4e66780c0 119 }
IanBenzMaxim 0:33d4e66780c0 120
IanBenzMaxim 0:33d4e66780c0 121 /* go over all entries that already waiting for execution */
IanBenzMaxim 0:33d4e66780c0 122 LastEntry = FALSE;
IanBenzMaxim 0:33d4e66780c0 123
IanBenzMaxim 0:33d4e66780c0 124 do
IanBenzMaxim 0:33d4e66780c0 125 {
IanBenzMaxim 0:33d4e66780c0 126 /* get entry to execute */
IanBenzMaxim 0:33d4e66780c0 127 SL_DRV_OBJ_LOCK_FOREVER(&g_SlInternalSpawnCB.LockObj);
IanBenzMaxim 0:33d4e66780c0 128
IanBenzMaxim 0:33d4e66780c0 129 pEntry = g_SlInternalSpawnCB.pWaitForExe;
IanBenzMaxim 0:33d4e66780c0 130 if ( NULL == pEntry )
IanBenzMaxim 0:33d4e66780c0 131 {
IanBenzMaxim 0:33d4e66780c0 132 SL_DRV_OBJ_UNLOCK(&g_SlInternalSpawnCB.LockObj);
IanBenzMaxim 0:33d4e66780c0 133 break;
IanBenzMaxim 0:33d4e66780c0 134 }
IanBenzMaxim 0:33d4e66780c0 135 g_SlInternalSpawnCB.pWaitForExe = pEntry->pNext;
IanBenzMaxim 0:33d4e66780c0 136 if (pEntry == g_SlInternalSpawnCB.pLastInWaitList)
IanBenzMaxim 0:33d4e66780c0 137 {
IanBenzMaxim 0:33d4e66780c0 138 g_SlInternalSpawnCB.pLastInWaitList = NULL;
IanBenzMaxim 0:33d4e66780c0 139 LastEntry = TRUE;
IanBenzMaxim 0:33d4e66780c0 140 }
IanBenzMaxim 0:33d4e66780c0 141
IanBenzMaxim 0:33d4e66780c0 142 SL_DRV_OBJ_UNLOCK(&g_SlInternalSpawnCB.LockObj);
IanBenzMaxim 0:33d4e66780c0 143
IanBenzMaxim 0:33d4e66780c0 144 /* pEntry could be null in case that the sync was already set by some
IanBenzMaxim 0:33d4e66780c0 145 of the entries during execution of earlier entry */
IanBenzMaxim 0:33d4e66780c0 146 if (NULL != pEntry)
IanBenzMaxim 0:33d4e66780c0 147 {
IanBenzMaxim 0:33d4e66780c0 148 pEntry->pEntry(pEntry->pValue);
IanBenzMaxim 0:33d4e66780c0 149 /* free the entry */
IanBenzMaxim 0:33d4e66780c0 150
IanBenzMaxim 0:33d4e66780c0 151 SL_DRV_OBJ_LOCK_FOREVER(&g_SlInternalSpawnCB.LockObj);
IanBenzMaxim 0:33d4e66780c0 152
IanBenzMaxim 0:33d4e66780c0 153 pEntry->pNext = g_SlInternalSpawnCB.pFree;
IanBenzMaxim 0:33d4e66780c0 154 g_SlInternalSpawnCB.pFree = pEntry;
IanBenzMaxim 0:33d4e66780c0 155
IanBenzMaxim 0:33d4e66780c0 156
IanBenzMaxim 0:33d4e66780c0 157 if (NULL != g_SlInternalSpawnCB.pWaitForExe)
IanBenzMaxim 0:33d4e66780c0 158 {
IanBenzMaxim 0:33d4e66780c0 159 /* new entry received meanwhile */
IanBenzMaxim 0:33d4e66780c0 160 LastEntry = FALSE;
IanBenzMaxim 0:33d4e66780c0 161 }
IanBenzMaxim 0:33d4e66780c0 162
IanBenzMaxim 0:33d4e66780c0 163 SL_DRV_OBJ_UNLOCK(&g_SlInternalSpawnCB.LockObj);
IanBenzMaxim 0:33d4e66780c0 164
IanBenzMaxim 0:33d4e66780c0 165 }
IanBenzMaxim 0:33d4e66780c0 166
IanBenzMaxim 0:33d4e66780c0 167 }while (!LastEntry);
IanBenzMaxim 0:33d4e66780c0 168 }
IanBenzMaxim 0:33d4e66780c0 169 }
IanBenzMaxim 0:33d4e66780c0 170
IanBenzMaxim 0:33d4e66780c0 171
IanBenzMaxim 0:33d4e66780c0 172 _i16 _SlInternalSpawn(_SlSpawnEntryFunc_t pEntry , void* pValue , _u32 flags)
IanBenzMaxim 0:33d4e66780c0 173 {
IanBenzMaxim 0:33d4e66780c0 174 _i16 Res = 0;
IanBenzMaxim 0:33d4e66780c0 175 _SlInternalSpawnEntry_t* pSpawnEntry;
IanBenzMaxim 0:33d4e66780c0 176
IanBenzMaxim 0:33d4e66780c0 177
IanBenzMaxim 0:33d4e66780c0 178 /* Increment the counter that specifies that async event has recived
IanBenzMaxim 0:33d4e66780c0 179 from interrupt context and should be handled by the internal spawn task */
IanBenzMaxim 0:33d4e66780c0 180 if (flags & SL_SPAWN_FLAG_FROM_SL_IRQ_HANDLER)
IanBenzMaxim 0:33d4e66780c0 181 {
IanBenzMaxim 0:33d4e66780c0 182 g_SlInternalSpawnCB.IrqWriteCnt++;
IanBenzMaxim 0:33d4e66780c0 183 g_SlInternalSpawnCB.pIrqFuncValue = pValue;
IanBenzMaxim 0:33d4e66780c0 184 SL_DRV_SYNC_OBJ_SIGNAL(&g_SlInternalSpawnCB.SyncObj);
IanBenzMaxim 0:33d4e66780c0 185 return Res;
IanBenzMaxim 0:33d4e66780c0 186 }
IanBenzMaxim 0:33d4e66780c0 187
IanBenzMaxim 0:33d4e66780c0 188
IanBenzMaxim 0:33d4e66780c0 189 if (NULL == pEntry || (g_SlInternalSpawnCB.pFree == NULL))
IanBenzMaxim 0:33d4e66780c0 190 {
IanBenzMaxim 0:33d4e66780c0 191 Res = -1;
IanBenzMaxim 0:33d4e66780c0 192 }
IanBenzMaxim 0:33d4e66780c0 193 else
IanBenzMaxim 0:33d4e66780c0 194 {
IanBenzMaxim 0:33d4e66780c0 195 SL_DRV_OBJ_LOCK_FOREVER(&g_SlInternalSpawnCB.LockObj);
IanBenzMaxim 0:33d4e66780c0 196
IanBenzMaxim 0:33d4e66780c0 197 pSpawnEntry = g_SlInternalSpawnCB.pFree;
IanBenzMaxim 0:33d4e66780c0 198 g_SlInternalSpawnCB.pFree = pSpawnEntry->pNext;
IanBenzMaxim 0:33d4e66780c0 199
IanBenzMaxim 0:33d4e66780c0 200 pSpawnEntry->pEntry = pEntry;
IanBenzMaxim 0:33d4e66780c0 201 pSpawnEntry->pValue = pValue;
IanBenzMaxim 0:33d4e66780c0 202 pSpawnEntry->pNext = NULL;
IanBenzMaxim 0:33d4e66780c0 203
IanBenzMaxim 0:33d4e66780c0 204 if (NULL == g_SlInternalSpawnCB.pWaitForExe)
IanBenzMaxim 0:33d4e66780c0 205 {
IanBenzMaxim 0:33d4e66780c0 206 g_SlInternalSpawnCB.pWaitForExe = pSpawnEntry;
IanBenzMaxim 0:33d4e66780c0 207 g_SlInternalSpawnCB.pLastInWaitList = pSpawnEntry;
IanBenzMaxim 0:33d4e66780c0 208 }
IanBenzMaxim 0:33d4e66780c0 209 else
IanBenzMaxim 0:33d4e66780c0 210 {
IanBenzMaxim 0:33d4e66780c0 211 g_SlInternalSpawnCB.pLastInWaitList->pNext = pSpawnEntry;
IanBenzMaxim 0:33d4e66780c0 212 g_SlInternalSpawnCB.pLastInWaitList = pSpawnEntry;
IanBenzMaxim 0:33d4e66780c0 213 }
IanBenzMaxim 0:33d4e66780c0 214
IanBenzMaxim 0:33d4e66780c0 215 SL_DRV_OBJ_UNLOCK(&g_SlInternalSpawnCB.LockObj);
IanBenzMaxim 0:33d4e66780c0 216
IanBenzMaxim 0:33d4e66780c0 217 /* this sync is called after releasing the lock object to avoid unnecessary context switches */
IanBenzMaxim 0:33d4e66780c0 218 SL_DRV_SYNC_OBJ_SIGNAL(&g_SlInternalSpawnCB.SyncObj);
IanBenzMaxim 0:33d4e66780c0 219 }
IanBenzMaxim 0:33d4e66780c0 220
IanBenzMaxim 0:33d4e66780c0 221 return Res;
IanBenzMaxim 0:33d4e66780c0 222 }
IanBenzMaxim 0:33d4e66780c0 223
IanBenzMaxim 0:33d4e66780c0 224
IanBenzMaxim 0:33d4e66780c0 225
IanBenzMaxim 0:33d4e66780c0 226
IanBenzMaxim 0:33d4e66780c0 227
IanBenzMaxim 0:33d4e66780c0 228 #endif