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:
Thu Apr 06 15:16:30 2017 -0500
Revision:
8:a0d75dff3c9b
Parent:
0:33d4e66780c0
Child:
10:71359af61af8
Simplified graphics system for better clarity and expandability.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IanBenzMaxim 0:33d4e66780c0 1 /*******************************************************************************
IanBenzMaxim 0:33d4e66780c0 2 * Copyright (C) 2017 Maxim Integrated Products, Inc., All Rights Reserved.
IanBenzMaxim 0:33d4e66780c0 3 *
IanBenzMaxim 0:33d4e66780c0 4 * Permission is hereby granted, free of charge, to any person obtaining a
IanBenzMaxim 0:33d4e66780c0 5 * copy of this software and associated documentation files (the "Software"),
IanBenzMaxim 0:33d4e66780c0 6 * to deal in the Software without restriction, including without limitation
IanBenzMaxim 0:33d4e66780c0 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
IanBenzMaxim 0:33d4e66780c0 8 * and/or sell copies of the Software, and to permit persons to whom the
IanBenzMaxim 0:33d4e66780c0 9 * Software is furnished to do so, subject to the following conditions:
IanBenzMaxim 0:33d4e66780c0 10 *
IanBenzMaxim 0:33d4e66780c0 11 * The above copyright notice and this permission notice shall be included
IanBenzMaxim 0:33d4e66780c0 12 * in all copies or substantial portions of the Software.
IanBenzMaxim 0:33d4e66780c0 13 *
IanBenzMaxim 0:33d4e66780c0 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
IanBenzMaxim 0:33d4e66780c0 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
IanBenzMaxim 0:33d4e66780c0 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IanBenzMaxim 0:33d4e66780c0 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
IanBenzMaxim 0:33d4e66780c0 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
IanBenzMaxim 0:33d4e66780c0 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
IanBenzMaxim 0:33d4e66780c0 20 * OTHER DEALINGS IN THE SOFTWARE.
IanBenzMaxim 0:33d4e66780c0 21 *
IanBenzMaxim 0:33d4e66780c0 22 * Except as contained in this notice, the name of Maxim Integrated
IanBenzMaxim 0:33d4e66780c0 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
IanBenzMaxim 0:33d4e66780c0 24 * Products, Inc. Branding Policy.
IanBenzMaxim 0:33d4e66780c0 25 *
IanBenzMaxim 0:33d4e66780c0 26 * The mere transfer of this software does not imply any licenses
IanBenzMaxim 0:33d4e66780c0 27 * of trade secrets, proprietary technology, copyrights, patents,
IanBenzMaxim 0:33d4e66780c0 28 * trademarks, maskwork rights, or any other form of intellectual
IanBenzMaxim 0:33d4e66780c0 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
IanBenzMaxim 0:33d4e66780c0 30 * ownership rights.
IanBenzMaxim 0:33d4e66780c0 31 *******************************************************************************/
IanBenzMaxim 0:33d4e66780c0 32
IanBenzMaxim 0:33d4e66780c0 33 #include <algorithm>
IanBenzMaxim 8:a0d75dff3c9b 34 #include "Display.hpp"
IanBenzMaxim 0:33d4e66780c0 35 #include "Graphic.hpp"
IanBenzMaxim 0:33d4e66780c0 36
IanBenzMaxim 0:33d4e66780c0 37 static const int minWidthHeight = 1;
IanBenzMaxim 0:33d4e66780c0 38
IanBenzMaxim 8:a0d75dff3c9b 39 Graphic::Graphic() :
IanBenzMaxim 0:33d4e66780c0 40 m_parent(NULL), m_children(), m_focusedChild(NULL),
IanBenzMaxim 0:33d4e66780c0 41 m_x(0), m_y(0), m_width(minWidthHeight), m_height(minWidthHeight),
IanBenzMaxim 8:a0d75dff3c9b 42 m_valid(false) { }
IanBenzMaxim 0:33d4e66780c0 43
IanBenzMaxim 0:33d4e66780c0 44 static void setParentNull(Graphic * node)
IanBenzMaxim 0:33d4e66780c0 45 {
IanBenzMaxim 0:33d4e66780c0 46 node->setParent(NULL);
IanBenzMaxim 0:33d4e66780c0 47 }
IanBenzMaxim 0:33d4e66780c0 48
IanBenzMaxim 0:33d4e66780c0 49 Graphic::~Graphic()
IanBenzMaxim 0:33d4e66780c0 50 {
IanBenzMaxim 8:a0d75dff3c9b 51 // Set children's parent to NULL.
IanBenzMaxim 0:33d4e66780c0 52 std::for_each(m_children.begin(), m_children.end(), setParentNull);
IanBenzMaxim 0:33d4e66780c0 53 // Remove from parent.
IanBenzMaxim 0:33d4e66780c0 54 setParent(NULL);
IanBenzMaxim 0:33d4e66780c0 55 }
IanBenzMaxim 0:33d4e66780c0 56
IanBenzMaxim 0:33d4e66780c0 57 void Graphic::setParent(Graphic * parent)
IanBenzMaxim 0:33d4e66780c0 58 {
IanBenzMaxim 0:33d4e66780c0 59 if ((m_parent == parent) || (parent == this))
IanBenzMaxim 0:33d4e66780c0 60 return;
IanBenzMaxim 0:33d4e66780c0 61
IanBenzMaxim 0:33d4e66780c0 62 if (m_parent != NULL)
IanBenzMaxim 0:33d4e66780c0 63 {
IanBenzMaxim 0:33d4e66780c0 64 // Remove this from the old parent's list of children.
IanBenzMaxim 0:33d4e66780c0 65 m_parent->m_children.erase(std::remove(m_parent->m_children.begin(), m_parent->m_children.end(), this));
IanBenzMaxim 0:33d4e66780c0 66 // Ensure that the old parent's focused child is not this.
IanBenzMaxim 0:33d4e66780c0 67 if (m_parent->m_focusedChild == this)
IanBenzMaxim 0:33d4e66780c0 68 {
IanBenzMaxim 0:33d4e66780c0 69 m_parent->m_focusedChild = NULL;
IanBenzMaxim 0:33d4e66780c0 70 }
IanBenzMaxim 8:a0d75dff3c9b 71 // Signal children changed event on old parent.
IanBenzMaxim 8:a0d75dff3c9b 72 m_parent->childrenChanged();
IanBenzMaxim 0:33d4e66780c0 73 }
IanBenzMaxim 0:33d4e66780c0 74 if (parent != NULL)
IanBenzMaxim 0:33d4e66780c0 75 {
IanBenzMaxim 0:33d4e66780c0 76 // Add this to new parent's list of children.
IanBenzMaxim 0:33d4e66780c0 77 parent->m_children.push_back(this);
IanBenzMaxim 8:a0d75dff3c9b 78 // Signal children changed event on new parent.
IanBenzMaxim 8:a0d75dff3c9b 79 parent->childrenChanged();
IanBenzMaxim 0:33d4e66780c0 80 }
IanBenzMaxim 0:33d4e66780c0 81 m_parent = parent;
IanBenzMaxim 0:33d4e66780c0 82 }
IanBenzMaxim 0:33d4e66780c0 83
IanBenzMaxim 0:33d4e66780c0 84 bool Graphic::focused() const
IanBenzMaxim 0:33d4e66780c0 85 {
IanBenzMaxim 0:33d4e66780c0 86 // First check if a focused child has not been set on this graphic.
IanBenzMaxim 0:33d4e66780c0 87 bool focused = (m_focusedChild == NULL);
IanBenzMaxim 0:33d4e66780c0 88 // Then check if each parent has the correct focused child set.
IanBenzMaxim 0:33d4e66780c0 89 for (const Graphic * node = this; focused && (node->m_parent != NULL); node = node->m_parent)
IanBenzMaxim 0:33d4e66780c0 90 {
IanBenzMaxim 0:33d4e66780c0 91 focused = (node->m_parent->m_focusedChild == node);
IanBenzMaxim 0:33d4e66780c0 92 }
IanBenzMaxim 0:33d4e66780c0 93 return focused;
IanBenzMaxim 0:33d4e66780c0 94 }
IanBenzMaxim 0:33d4e66780c0 95
IanBenzMaxim 0:33d4e66780c0 96 void Graphic::setFocused()
IanBenzMaxim 0:33d4e66780c0 97 {
IanBenzMaxim 0:33d4e66780c0 98 // Locate top-level parent.
IanBenzMaxim 0:33d4e66780c0 99 Graphic * node = this;
IanBenzMaxim 0:33d4e66780c0 100 while (node->m_parent != NULL)
IanBenzMaxim 0:33d4e66780c0 101 {
IanBenzMaxim 0:33d4e66780c0 102 node = node->m_parent;
IanBenzMaxim 0:33d4e66780c0 103 }
IanBenzMaxim 0:33d4e66780c0 104 // Locate currently focused item.
IanBenzMaxim 0:33d4e66780c0 105 while (node->m_focusedChild != NULL)
IanBenzMaxim 0:33d4e66780c0 106 {
IanBenzMaxim 0:33d4e66780c0 107 node = node->m_focusedChild;
IanBenzMaxim 0:33d4e66780c0 108 }
IanBenzMaxim 0:33d4e66780c0 109 // Do nothing if this is already focused.
IanBenzMaxim 0:33d4e66780c0 110 if (node == this)
IanBenzMaxim 0:33d4e66780c0 111 return;
IanBenzMaxim 0:33d4e66780c0 112
IanBenzMaxim 0:33d4e66780c0 113 // Create new focus chain by setting the focused child of each parent.
IanBenzMaxim 0:33d4e66780c0 114 m_focusedChild = NULL;
IanBenzMaxim 8:a0d75dff3c9b 115 for (Graphic * node = this; node->m_parent != NULL; node = node->m_parent)
IanBenzMaxim 0:33d4e66780c0 116 {
IanBenzMaxim 0:33d4e66780c0 117 node->m_parent->m_focusedChild = node;
IanBenzMaxim 0:33d4e66780c0 118 }
IanBenzMaxim 8:a0d75dff3c9b 119 // Raise focus changed events on both nodes.
IanBenzMaxim 8:a0d75dff3c9b 120 node->focusChanged(false);
IanBenzMaxim 8:a0d75dff3c9b 121 focusChanged(true);
IanBenzMaxim 0:33d4e66780c0 122 }
IanBenzMaxim 0:33d4e66780c0 123
IanBenzMaxim 8:a0d75dff3c9b 124 void Graphic::move(int x, int y)
IanBenzMaxim 0:33d4e66780c0 125 {
IanBenzMaxim 8:a0d75dff3c9b 126 if (m_x != x || m_y != y)
IanBenzMaxim 0:33d4e66780c0 127 {
IanBenzMaxim 0:33d4e66780c0 128 m_x = x;
IanBenzMaxim 0:33d4e66780c0 129 m_y = y;
IanBenzMaxim 8:a0d75dff3c9b 130 invalidate();
IanBenzMaxim 8:a0d75dff3c9b 131 moved();
IanBenzMaxim 0:33d4e66780c0 132 }
IanBenzMaxim 0:33d4e66780c0 133 }
IanBenzMaxim 0:33d4e66780c0 134
IanBenzMaxim 8:a0d75dff3c9b 135 void Graphic::resize(int width, int height)
IanBenzMaxim 0:33d4e66780c0 136 {
IanBenzMaxim 8:a0d75dff3c9b 137 if (m_width != width || m_height != height)
IanBenzMaxim 0:33d4e66780c0 138 {
IanBenzMaxim 8:a0d75dff3c9b 139 m_width = std::max(width, minWidthHeight);
IanBenzMaxim 8:a0d75dff3c9b 140 m_height = std::max(height, minWidthHeight);
IanBenzMaxim 8:a0d75dff3c9b 141 invalidate();
IanBenzMaxim 8:a0d75dff3c9b 142 resized();
IanBenzMaxim 0:33d4e66780c0 143 }
IanBenzMaxim 0:33d4e66780c0 144 }
IanBenzMaxim 0:33d4e66780c0 145
IanBenzMaxim 0:33d4e66780c0 146 Bitmap Graphic::render() const
IanBenzMaxim 0:33d4e66780c0 147 {
IanBenzMaxim 0:33d4e66780c0 148 Bitmap bitmap(width(), height());
IanBenzMaxim 8:a0d75dff3c9b 149 doRender(bitmap);
IanBenzMaxim 0:33d4e66780c0 150 return bitmap;
IanBenzMaxim 0:33d4e66780c0 151 }
IanBenzMaxim 0:33d4e66780c0 152
IanBenzMaxim 8:a0d75dff3c9b 153 bool Graphic::doUpdate(bool setValid)
IanBenzMaxim 0:33d4e66780c0 154 {
IanBenzMaxim 0:33d4e66780c0 155 bool redraw = false;
IanBenzMaxim 8:a0d75dff3c9b 156 // Perform updated event on this graphic.
IanBenzMaxim 8:a0d75dff3c9b 157 updated();
IanBenzMaxim 8:a0d75dff3c9b 158 // Call recursively on each child.
IanBenzMaxim 8:a0d75dff3c9b 159 for (ChildContainer::iterator it = m_children.begin(); it != m_children.end(); it++)
IanBenzMaxim 8:a0d75dff3c9b 160 {
IanBenzMaxim 8:a0d75dff3c9b 161 if ((*it)->doUpdate(setValid))
IanBenzMaxim 8:a0d75dff3c9b 162 {
IanBenzMaxim 8:a0d75dff3c9b 163 redraw = true;
IanBenzMaxim 8:a0d75dff3c9b 164 }
IanBenzMaxim 8:a0d75dff3c9b 165 }
IanBenzMaxim 8:a0d75dff3c9b 166 // Request redraw if region invalid.
IanBenzMaxim 8:a0d75dff3c9b 167 if (!m_valid)
IanBenzMaxim 0:33d4e66780c0 168 {
IanBenzMaxim 0:33d4e66780c0 169 redraw = true;
IanBenzMaxim 8:a0d75dff3c9b 170 if (setValid)
IanBenzMaxim 8:a0d75dff3c9b 171 {
IanBenzMaxim 8:a0d75dff3c9b 172 m_valid = true;
IanBenzMaxim 8:a0d75dff3c9b 173 }
IanBenzMaxim 0:33d4e66780c0 174 }
IanBenzMaxim 0:33d4e66780c0 175 return redraw;
IanBenzMaxim 0:33d4e66780c0 176 }
IanBenzMaxim 0:33d4e66780c0 177
IanBenzMaxim 8:a0d75dff3c9b 178 void Graphic::update(Display * display)
IanBenzMaxim 8:a0d75dff3c9b 179 {
IanBenzMaxim 8:a0d75dff3c9b 180 bool redraw = doUpdate(display != NULL);
IanBenzMaxim 8:a0d75dff3c9b 181 if (display != NULL && redraw)
IanBenzMaxim 8:a0d75dff3c9b 182 {
IanBenzMaxim 8:a0d75dff3c9b 183 Bitmap bitmap(Display::width, Display::height);
IanBenzMaxim 8:a0d75dff3c9b 184 bitmap.overlay(render(), x(), y());
IanBenzMaxim 8:a0d75dff3c9b 185 display->update(bitmap);
IanBenzMaxim 8:a0d75dff3c9b 186 }
IanBenzMaxim 8:a0d75dff3c9b 187 }
IanBenzMaxim 8:a0d75dff3c9b 188
IanBenzMaxim 0:33d4e66780c0 189 bool Graphic::processKey(Key key)
IanBenzMaxim 0:33d4e66780c0 190 {
IanBenzMaxim 0:33d4e66780c0 191 // Find focused child.
IanBenzMaxim 0:33d4e66780c0 192 Graphic * receiver = this;
IanBenzMaxim 0:33d4e66780c0 193 while (receiver->m_focusedChild != NULL)
IanBenzMaxim 0:33d4e66780c0 194 {
IanBenzMaxim 0:33d4e66780c0 195 receiver = receiver->m_focusedChild;
IanBenzMaxim 0:33d4e66780c0 196 }
IanBenzMaxim 0:33d4e66780c0 197 // Pass event to focused child and then to each parent until handled.
IanBenzMaxim 0:33d4e66780c0 198 bool handled = false;
IanBenzMaxim 0:33d4e66780c0 199 do
IanBenzMaxim 0:33d4e66780c0 200 {
IanBenzMaxim 0:33d4e66780c0 201 handled = receiver->doProcessKey(key);
IanBenzMaxim 0:33d4e66780c0 202 receiver = receiver->m_parent;
IanBenzMaxim 0:33d4e66780c0 203 } while (!handled && (receiver != NULL));
IanBenzMaxim 0:33d4e66780c0 204 return handled;
IanBenzMaxim 0:33d4e66780c0 205 }
IanBenzMaxim 0:33d4e66780c0 206
IanBenzMaxim 8:a0d75dff3c9b 207 void Graphic::childrenChanged() { }
IanBenzMaxim 8:a0d75dff3c9b 208
IanBenzMaxim 8:a0d75dff3c9b 209 void Graphic::focusChanged(bool) { }
IanBenzMaxim 8:a0d75dff3c9b 210
IanBenzMaxim 8:a0d75dff3c9b 211 void Graphic::moved() { }
IanBenzMaxim 8:a0d75dff3c9b 212
IanBenzMaxim 8:a0d75dff3c9b 213 void Graphic::resized() { }
IanBenzMaxim 8:a0d75dff3c9b 214
IanBenzMaxim 8:a0d75dff3c9b 215 void Graphic::updated() { }
IanBenzMaxim 8:a0d75dff3c9b 216
IanBenzMaxim 8:a0d75dff3c9b 217 // Functor overlays rendered graphics onto a bitmap.
IanBenzMaxim 8:a0d75dff3c9b 218 class RenderOverlay
IanBenzMaxim 0:33d4e66780c0 219 {
IanBenzMaxim 8:a0d75dff3c9b 220 public:
IanBenzMaxim 8:a0d75dff3c9b 221 RenderOverlay(Bitmap & bitmap) : bitmap(bitmap) { }
IanBenzMaxim 8:a0d75dff3c9b 222
IanBenzMaxim 8:a0d75dff3c9b 223 void operator()(const Graphic * graphic)
IanBenzMaxim 0:33d4e66780c0 224 {
IanBenzMaxim 8:a0d75dff3c9b 225 if (graphic != NULL)
IanBenzMaxim 0:33d4e66780c0 226 {
IanBenzMaxim 8:a0d75dff3c9b 227 bitmap.overlay(graphic->render(), graphic->x(), graphic->y());
IanBenzMaxim 0:33d4e66780c0 228 }
IanBenzMaxim 0:33d4e66780c0 229 }
IanBenzMaxim 8:a0d75dff3c9b 230
IanBenzMaxim 8:a0d75dff3c9b 231 private:
IanBenzMaxim 8:a0d75dff3c9b 232 Bitmap & bitmap;
IanBenzMaxim 8:a0d75dff3c9b 233 };
IanBenzMaxim 8:a0d75dff3c9b 234
IanBenzMaxim 8:a0d75dff3c9b 235 void Graphic::doRender(Bitmap & bitmap) const
IanBenzMaxim 8:a0d75dff3c9b 236 {
IanBenzMaxim 8:a0d75dff3c9b 237 std::for_each(m_children.begin(), m_children.end(), RenderOverlay(bitmap));
IanBenzMaxim 0:33d4e66780c0 238 }
IanBenzMaxim 0:33d4e66780c0 239
IanBenzMaxim 8:a0d75dff3c9b 240 bool Graphic::doProcessKey(Key) { return false; }