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:
Fri Jan 19 10:28:27 2018 -0600
Revision:
15:75404fab3615
Parent:
13:6a6225690c2e
Updated MaximInterface revision.

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