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:
Mon Apr 10 11:55:33 2017 -0500
Revision:
10:71359af61af8
Parent:
8:a0d75dff3c9b
Child:
13:6a6225690c2e
Reduced copying and dynamic allocations during rendering. Added support for partial redrawing of a scene.

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 10:71359af61af8 34 #include <functional>
IanBenzMaxim 10:71359af61af8 35 #include "Bitmap.hpp"
IanBenzMaxim 0:33d4e66780c0 36 #include "Graphic.hpp"
IanBenzMaxim 0:33d4e66780c0 37
IanBenzMaxim 0:33d4e66780c0 38 static const int minWidthHeight = 1;
IanBenzMaxim 0:33d4e66780c0 39
IanBenzMaxim 8:a0d75dff3c9b 40 Graphic::Graphic() :
IanBenzMaxim 0:33d4e66780c0 41 m_parent(NULL), m_children(), m_focusedChild(NULL),
IanBenzMaxim 0:33d4e66780c0 42 m_x(0), m_y(0), m_width(minWidthHeight), m_height(minWidthHeight),
IanBenzMaxim 8:a0d75dff3c9b 43 m_valid(false) { }
IanBenzMaxim 0:33d4e66780c0 44
IanBenzMaxim 0:33d4e66780c0 45 static void setParentNull(Graphic * node)
IanBenzMaxim 0:33d4e66780c0 46 {
IanBenzMaxim 0:33d4e66780c0 47 node->setParent(NULL);
IanBenzMaxim 0:33d4e66780c0 48 }
IanBenzMaxim 0:33d4e66780c0 49
IanBenzMaxim 0:33d4e66780c0 50 Graphic::~Graphic()
IanBenzMaxim 0:33d4e66780c0 51 {
IanBenzMaxim 8:a0d75dff3c9b 52 // Set children's parent to NULL.
IanBenzMaxim 0:33d4e66780c0 53 std::for_each(m_children.begin(), m_children.end(), setParentNull);
IanBenzMaxim 0:33d4e66780c0 54 // Remove from parent.
IanBenzMaxim 0:33d4e66780c0 55 setParent(NULL);
IanBenzMaxim 0:33d4e66780c0 56 }
IanBenzMaxim 0:33d4e66780c0 57
IanBenzMaxim 0:33d4e66780c0 58 void Graphic::setParent(Graphic * parent)
IanBenzMaxim 0:33d4e66780c0 59 {
IanBenzMaxim 0:33d4e66780c0 60 if ((m_parent == parent) || (parent == this))
IanBenzMaxim 0:33d4e66780c0 61 return;
IanBenzMaxim 0:33d4e66780c0 62
IanBenzMaxim 0:33d4e66780c0 63 if (m_parent != NULL)
IanBenzMaxim 0:33d4e66780c0 64 {
IanBenzMaxim 0:33d4e66780c0 65 // Remove this from the old parent's list of children.
IanBenzMaxim 0:33d4e66780c0 66 m_parent->m_children.erase(std::remove(m_parent->m_children.begin(), m_parent->m_children.end(), this));
IanBenzMaxim 0:33d4e66780c0 67 // Ensure that the old parent's focused child is not this.
IanBenzMaxim 0:33d4e66780c0 68 if (m_parent->m_focusedChild == this)
IanBenzMaxim 0:33d4e66780c0 69 {
IanBenzMaxim 0:33d4e66780c0 70 m_parent->m_focusedChild = NULL;
IanBenzMaxim 0:33d4e66780c0 71 }
IanBenzMaxim 8:a0d75dff3c9b 72 // Signal children changed event on old parent.
IanBenzMaxim 8:a0d75dff3c9b 73 m_parent->childrenChanged();
IanBenzMaxim 0:33d4e66780c0 74 }
IanBenzMaxim 0:33d4e66780c0 75 if (parent != NULL)
IanBenzMaxim 0:33d4e66780c0 76 {
IanBenzMaxim 0:33d4e66780c0 77 // Add this to new parent's list of children.
IanBenzMaxim 0:33d4e66780c0 78 parent->m_children.push_back(this);
IanBenzMaxim 8:a0d75dff3c9b 79 // Signal children changed event on new parent.
IanBenzMaxim 8:a0d75dff3c9b 80 parent->childrenChanged();
IanBenzMaxim 0:33d4e66780c0 81 }
IanBenzMaxim 0:33d4e66780c0 82 m_parent = parent;
IanBenzMaxim 0:33d4e66780c0 83 }
IanBenzMaxim 0:33d4e66780c0 84
IanBenzMaxim 0:33d4e66780c0 85 bool Graphic::focused() const
IanBenzMaxim 0:33d4e66780c0 86 {
IanBenzMaxim 0:33d4e66780c0 87 // First check if a focused child has not been set on this graphic.
IanBenzMaxim 0:33d4e66780c0 88 bool focused = (m_focusedChild == NULL);
IanBenzMaxim 0:33d4e66780c0 89 // Then check if each parent has the correct focused child set.
IanBenzMaxim 0:33d4e66780c0 90 for (const Graphic * node = this; focused && (node->m_parent != NULL); node = node->m_parent)
IanBenzMaxim 0:33d4e66780c0 91 {
IanBenzMaxim 0:33d4e66780c0 92 focused = (node->m_parent->m_focusedChild == node);
IanBenzMaxim 0:33d4e66780c0 93 }
IanBenzMaxim 0:33d4e66780c0 94 return focused;
IanBenzMaxim 0:33d4e66780c0 95 }
IanBenzMaxim 0:33d4e66780c0 96
IanBenzMaxim 0:33d4e66780c0 97 void Graphic::setFocused()
IanBenzMaxim 0:33d4e66780c0 98 {
IanBenzMaxim 0:33d4e66780c0 99 // Locate top-level parent.
IanBenzMaxim 0:33d4e66780c0 100 Graphic * node = this;
IanBenzMaxim 0:33d4e66780c0 101 while (node->m_parent != NULL)
IanBenzMaxim 0:33d4e66780c0 102 {
IanBenzMaxim 0:33d4e66780c0 103 node = node->m_parent;
IanBenzMaxim 0:33d4e66780c0 104 }
IanBenzMaxim 0:33d4e66780c0 105 // Locate currently focused item.
IanBenzMaxim 0:33d4e66780c0 106 while (node->m_focusedChild != NULL)
IanBenzMaxim 0:33d4e66780c0 107 {
IanBenzMaxim 0:33d4e66780c0 108 node = node->m_focusedChild;
IanBenzMaxim 0:33d4e66780c0 109 }
IanBenzMaxim 0:33d4e66780c0 110 // Do nothing if this is already focused.
IanBenzMaxim 0:33d4e66780c0 111 if (node == this)
IanBenzMaxim 0:33d4e66780c0 112 return;
IanBenzMaxim 0:33d4e66780c0 113
IanBenzMaxim 0:33d4e66780c0 114 // Create new focus chain by setting the focused child of each parent.
IanBenzMaxim 0:33d4e66780c0 115 m_focusedChild = NULL;
IanBenzMaxim 8:a0d75dff3c9b 116 for (Graphic * node = this; node->m_parent != NULL; node = node->m_parent)
IanBenzMaxim 0:33d4e66780c0 117 {
IanBenzMaxim 0:33d4e66780c0 118 node->m_parent->m_focusedChild = node;
IanBenzMaxim 0:33d4e66780c0 119 }
IanBenzMaxim 8:a0d75dff3c9b 120 // Raise focus changed events on both nodes.
IanBenzMaxim 8:a0d75dff3c9b 121 node->focusChanged(false);
IanBenzMaxim 8:a0d75dff3c9b 122 focusChanged(true);
IanBenzMaxim 0:33d4e66780c0 123 }
IanBenzMaxim 0:33d4e66780c0 124
IanBenzMaxim 8:a0d75dff3c9b 125 void Graphic::move(int x, int y)
IanBenzMaxim 0:33d4e66780c0 126 {
IanBenzMaxim 8:a0d75dff3c9b 127 if (m_x != x || m_y != y)
IanBenzMaxim 0:33d4e66780c0 128 {
IanBenzMaxim 0:33d4e66780c0 129 m_x = x;
IanBenzMaxim 0:33d4e66780c0 130 m_y = y;
IanBenzMaxim 8:a0d75dff3c9b 131 invalidate();
IanBenzMaxim 8:a0d75dff3c9b 132 moved();
IanBenzMaxim 0:33d4e66780c0 133 }
IanBenzMaxim 0:33d4e66780c0 134 }
IanBenzMaxim 0:33d4e66780c0 135
IanBenzMaxim 8:a0d75dff3c9b 136 void Graphic::resize(int width, int height)
IanBenzMaxim 0:33d4e66780c0 137 {
IanBenzMaxim 8:a0d75dff3c9b 138 if (m_width != width || m_height != height)
IanBenzMaxim 0:33d4e66780c0 139 {
IanBenzMaxim 8:a0d75dff3c9b 140 m_width = std::max(width, minWidthHeight);
IanBenzMaxim 8:a0d75dff3c9b 141 m_height = std::max(height, minWidthHeight);
IanBenzMaxim 8:a0d75dff3c9b 142 invalidate();
IanBenzMaxim 8:a0d75dff3c9b 143 resized();
IanBenzMaxim 0:33d4e66780c0 144 }
IanBenzMaxim 0:33d4e66780c0 145 }
IanBenzMaxim 0:33d4e66780c0 146
IanBenzMaxim 10:71359af61af8 147 // Functor overlays rendered graphics onto a bitmap.
IanBenzMaxim 10:71359af61af8 148 class RenderOverlay
IanBenzMaxim 0:33d4e66780c0 149 {
IanBenzMaxim 10:71359af61af8 150 public:
IanBenzMaxim 10:71359af61af8 151 RenderOverlay(Bitmap & bitmap, int xOffset, int yOffset) :
IanBenzMaxim 10:71359af61af8 152 bitmap(bitmap), xOffset(xOffset), yOffset(yOffset) { }
IanBenzMaxim 10:71359af61af8 153
IanBenzMaxim 10:71359af61af8 154 void operator()(const Graphic * graphic)
IanBenzMaxim 10:71359af61af8 155 {
IanBenzMaxim 10:71359af61af8 156 if (graphic != NULL)
IanBenzMaxim 10:71359af61af8 157 {
IanBenzMaxim 10:71359af61af8 158 graphic->render(bitmap, xOffset, yOffset);
IanBenzMaxim 10:71359af61af8 159 }
IanBenzMaxim 10:71359af61af8 160 }
IanBenzMaxim 10:71359af61af8 161
IanBenzMaxim 10:71359af61af8 162 private:
IanBenzMaxim 10:71359af61af8 163 Bitmap & bitmap;
IanBenzMaxim 10:71359af61af8 164 const int xOffset;
IanBenzMaxim 10:71359af61af8 165 const int yOffset;
IanBenzMaxim 10:71359af61af8 166 };
IanBenzMaxim 10:71359af61af8 167
IanBenzMaxim 10:71359af61af8 168 void Graphic::doRender(Bitmap & bitmap, int xOffset, int yOffset) const
IanBenzMaxim 10:71359af61af8 169 {
IanBenzMaxim 10:71359af61af8 170 std::for_each(m_children.begin(), m_children.end(),
IanBenzMaxim 10:71359af61af8 171 RenderOverlay(bitmap, xOffset + x(), yOffset + y()));
IanBenzMaxim 0:33d4e66780c0 172 }
IanBenzMaxim 0:33d4e66780c0 173
IanBenzMaxim 10:71359af61af8 174 void Graphic::render(Bitmap & bitmap, int xOffset, int yOffset) const
IanBenzMaxim 10:71359af61af8 175 {
IanBenzMaxim 10:71359af61af8 176 // Clear region.
IanBenzMaxim 10:71359af61af8 177 bitmap.clear(xOffset + x(), yOffset + y(), width(), height());
IanBenzMaxim 10:71359af61af8 178 // Do actual rendering.
IanBenzMaxim 10:71359af61af8 179 doRender(bitmap, xOffset, yOffset);
IanBenzMaxim 10:71359af61af8 180 }
IanBenzMaxim 10:71359af61af8 181
IanBenzMaxim 10:71359af61af8 182 void Graphic::render(Bitmap & bitmap) const
IanBenzMaxim 0:33d4e66780c0 183 {
IanBenzMaxim 10:71359af61af8 184 int xOffset = 0;
IanBenzMaxim 10:71359af61af8 185 int yOffset = 0;
IanBenzMaxim 10:71359af61af8 186 for (const Graphic * graphic = parent(); graphic != NULL; graphic = graphic->parent())
IanBenzMaxim 10:71359af61af8 187 {
IanBenzMaxim 10:71359af61af8 188 xOffset += graphic->x();
IanBenzMaxim 10:71359af61af8 189 yOffset += graphic->y();
IanBenzMaxim 10:71359af61af8 190 }
IanBenzMaxim 10:71359af61af8 191 render(bitmap, xOffset, yOffset);
IanBenzMaxim 10:71359af61af8 192 }
IanBenzMaxim 10:71359af61af8 193
IanBenzMaxim 10:71359af61af8 194 void Graphic::updateAll()
IanBenzMaxim 10:71359af61af8 195 {
IanBenzMaxim 8:a0d75dff3c9b 196 // Perform updated event on this graphic.
IanBenzMaxim 8:a0d75dff3c9b 197 updated();
IanBenzMaxim 8:a0d75dff3c9b 198 // Call recursively on each child.
IanBenzMaxim 10:71359af61af8 199 std::for_each(m_children.begin(), m_children.end(), std::mem_fun(&Graphic::updateAll));
IanBenzMaxim 10:71359af61af8 200 }
IanBenzMaxim 10:71359af61af8 201
IanBenzMaxim 10:71359af61af8 202 bool Graphic::redrawInvalid(Bitmap & canvas)
IanBenzMaxim 10:71359af61af8 203 {
IanBenzMaxim 10:71359af61af8 204 bool redraw = !m_valid;
IanBenzMaxim 10:71359af61af8 205 if (redraw)
IanBenzMaxim 8:a0d75dff3c9b 206 {
IanBenzMaxim 10:71359af61af8 207 // Redraw if invalid.
IanBenzMaxim 10:71359af61af8 208 render(canvas);
IanBenzMaxim 10:71359af61af8 209 // Set all children to valid since they were incorporated in the redraw.
IanBenzMaxim 10:71359af61af8 210 setAllValid();
IanBenzMaxim 8:a0d75dff3c9b 211 }
IanBenzMaxim 10:71359af61af8 212 else
IanBenzMaxim 0:33d4e66780c0 213 {
IanBenzMaxim 10:71359af61af8 214 // Call recursively on each child.
IanBenzMaxim 10:71359af61af8 215 for (ChildContainer::iterator it = m_children.begin(); it != m_children.end(); it++)
IanBenzMaxim 8:a0d75dff3c9b 216 {
IanBenzMaxim 10:71359af61af8 217 if ((*it)->redrawInvalid(canvas))
IanBenzMaxim 10:71359af61af8 218 {
IanBenzMaxim 10:71359af61af8 219 redraw = true;
IanBenzMaxim 10:71359af61af8 220 }
IanBenzMaxim 8:a0d75dff3c9b 221 }
IanBenzMaxim 0:33d4e66780c0 222 }
IanBenzMaxim 0:33d4e66780c0 223 return redraw;
IanBenzMaxim 0:33d4e66780c0 224 }
IanBenzMaxim 0:33d4e66780c0 225
IanBenzMaxim 10:71359af61af8 226 void Graphic::setAllValid()
IanBenzMaxim 8:a0d75dff3c9b 227 {
IanBenzMaxim 10:71359af61af8 228 m_valid = true;
IanBenzMaxim 10:71359af61af8 229 // Call recursively on each child.
IanBenzMaxim 10:71359af61af8 230 std::for_each(m_children.begin(), m_children.end(), std::mem_fun(&Graphic::setAllValid));
IanBenzMaxim 10:71359af61af8 231 }
IanBenzMaxim 10:71359af61af8 232
IanBenzMaxim 10:71359af61af8 233 bool Graphic::update(Bitmap * canvas)
IanBenzMaxim 10:71359af61af8 234 {
IanBenzMaxim 10:71359af61af8 235 bool redraw = false;
IanBenzMaxim 10:71359af61af8 236 updateAll();
IanBenzMaxim 10:71359af61af8 237 if (canvas != NULL)
IanBenzMaxim 8:a0d75dff3c9b 238 {
IanBenzMaxim 10:71359af61af8 239 redraw = redrawInvalid(*canvas);
IanBenzMaxim 8:a0d75dff3c9b 240 }
IanBenzMaxim 10:71359af61af8 241 return redraw;
IanBenzMaxim 8:a0d75dff3c9b 242 }
IanBenzMaxim 8:a0d75dff3c9b 243
IanBenzMaxim 0:33d4e66780c0 244 bool Graphic::processKey(Key key)
IanBenzMaxim 0:33d4e66780c0 245 {
IanBenzMaxim 0:33d4e66780c0 246 // Find focused child.
IanBenzMaxim 0:33d4e66780c0 247 Graphic * receiver = this;
IanBenzMaxim 0:33d4e66780c0 248 while (receiver->m_focusedChild != NULL)
IanBenzMaxim 0:33d4e66780c0 249 {
IanBenzMaxim 0:33d4e66780c0 250 receiver = receiver->m_focusedChild;
IanBenzMaxim 0:33d4e66780c0 251 }
IanBenzMaxim 0:33d4e66780c0 252 // Pass event to focused child and then to each parent until handled.
IanBenzMaxim 0:33d4e66780c0 253 bool handled = false;
IanBenzMaxim 0:33d4e66780c0 254 do
IanBenzMaxim 0:33d4e66780c0 255 {
IanBenzMaxim 0:33d4e66780c0 256 handled = receiver->doProcessKey(key);
IanBenzMaxim 0:33d4e66780c0 257 receiver = receiver->m_parent;
IanBenzMaxim 0:33d4e66780c0 258 } while (!handled && (receiver != NULL));
IanBenzMaxim 0:33d4e66780c0 259 return handled;
IanBenzMaxim 0:33d4e66780c0 260 }
IanBenzMaxim 0:33d4e66780c0 261
IanBenzMaxim 10:71359af61af8 262 void Graphic::childrenChanged() { invalidate(); }
IanBenzMaxim 8:a0d75dff3c9b 263
IanBenzMaxim 8:a0d75dff3c9b 264 void Graphic::focusChanged(bool) { }
IanBenzMaxim 8:a0d75dff3c9b 265
IanBenzMaxim 8:a0d75dff3c9b 266 void Graphic::moved() { }
IanBenzMaxim 8:a0d75dff3c9b 267
IanBenzMaxim 8:a0d75dff3c9b 268 void Graphic::resized() { }
IanBenzMaxim 8:a0d75dff3c9b 269
IanBenzMaxim 8:a0d75dff3c9b 270 void Graphic::updated() { }
IanBenzMaxim 8:a0d75dff3c9b 271
IanBenzMaxim 8:a0d75dff3c9b 272 bool Graphic::doProcessKey(Key) { return false; }