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 Oct 04 12:10:11 2019 -0500
Revision:
17:5926077e5345
Parent:
16:a004191a79ab
Set pin maps through the mbed configuration system. Added support for MAX32625MBED target. Updated mbed-os to version 5.7.7 for MAX32625 I2C fixes. Consolidated simplelink hook definitions.

Who changed what in which revision?

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