Device interface library for multiple platforms including Mbed.

Dependents:   DeepCover Embedded Security in IoT MaximInterface MAXREFDES155#

Maxim Interface is a library framework focused on providing flexible and expressive hardware interfaces. Both communication interfaces such as I2C and 1-Wire and device interfaces such as DS18B20 are supported. Modern C++ concepts are used extensively while keeping compatibility with C++98/C++03 and requiring no external dependencies. The embedded-friendly design does not depend on exceptions or RTTI.

The full version of the project is hosted on GitLab: https://gitlab.com/iabenz/MaximInterface

Committer:
IanBenzMaxim
Date:
Mon Sep 16 11:13:37 2019 -0500
Revision:
8:5ea891c7d1a1
Parent:
7:9cd16581b578
Updated to version 2.0.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IanBenzMaxim 7:9cd16581b578 1 /*******************************************************************************
IanBenzMaxim 8:5ea891c7d1a1 2 * Copyright (C) Maxim Integrated Products, Inc., All Rights Reserved.
IanBenzMaxim 7:9cd16581b578 3 *
IanBenzMaxim 7:9cd16581b578 4 * Permission is hereby granted, free of charge, to any person obtaining a
IanBenzMaxim 7:9cd16581b578 5 * copy of this software and associated documentation files (the "Software"),
IanBenzMaxim 7:9cd16581b578 6 * to deal in the Software without restriction, including without limitation
IanBenzMaxim 7:9cd16581b578 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
IanBenzMaxim 7:9cd16581b578 8 * and/or sell copies of the Software, and to permit persons to whom the
IanBenzMaxim 7:9cd16581b578 9 * Software is furnished to do so, subject to the following conditions:
IanBenzMaxim 7:9cd16581b578 10 *
IanBenzMaxim 7:9cd16581b578 11 * The above copyright notice and this permission notice shall be included
IanBenzMaxim 7:9cd16581b578 12 * in all copies or substantial portions of the Software.
IanBenzMaxim 7:9cd16581b578 13 *
IanBenzMaxim 7:9cd16581b578 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
IanBenzMaxim 7:9cd16581b578 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
IanBenzMaxim 7:9cd16581b578 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IanBenzMaxim 7:9cd16581b578 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
IanBenzMaxim 7:9cd16581b578 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
IanBenzMaxim 7:9cd16581b578 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
IanBenzMaxim 7:9cd16581b578 20 * OTHER DEALINGS IN THE SOFTWARE.
IanBenzMaxim 7:9cd16581b578 21 *
IanBenzMaxim 7:9cd16581b578 22 * Except as contained in this notice, the name of Maxim Integrated
IanBenzMaxim 7:9cd16581b578 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
IanBenzMaxim 7:9cd16581b578 24 * Products, Inc. Branding Policy.
IanBenzMaxim 7:9cd16581b578 25 *
IanBenzMaxim 7:9cd16581b578 26 * The mere transfer of this software does not imply any licenses
IanBenzMaxim 7:9cd16581b578 27 * of trade secrets, proprietary technology, copyrights, patents,
IanBenzMaxim 7:9cd16581b578 28 * trademarks, maskwork rights, or any other form of intellectual
IanBenzMaxim 7:9cd16581b578 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
IanBenzMaxim 7:9cd16581b578 30 * ownership rights.
IanBenzMaxim 7:9cd16581b578 31 *******************************************************************************/
IanBenzMaxim 7:9cd16581b578 32
IanBenzMaxim 7:9cd16581b578 33 #include "Ecc256.hpp"
IanBenzMaxim 7:9cd16581b578 34
IanBenzMaxim 7:9cd16581b578 35 namespace MaximInterfaceCore {
IanBenzMaxim 7:9cd16581b578 36 namespace Ecc256 {
IanBenzMaxim 7:9cd16581b578 37
IanBenzMaxim 7:9cd16581b578 38 void copy(Point::const_span src, Point::span dst) {
IanBenzMaxim 7:9cd16581b578 39 copy(src.x, dst.x);
IanBenzMaxim 7:9cd16581b578 40 copy(src.y, dst.y);
IanBenzMaxim 7:9cd16581b578 41 }
IanBenzMaxim 7:9cd16581b578 42
IanBenzMaxim 8:5ea891c7d1a1 43 bool equal(Point::const_span lhs, Point::const_span rhs) {
IanBenzMaxim 8:5ea891c7d1a1 44 return equal(lhs.x, rhs.x) && equal(lhs.y, rhs.y);
IanBenzMaxim 8:5ea891c7d1a1 45 }
IanBenzMaxim 8:5ea891c7d1a1 46
IanBenzMaxim 7:9cd16581b578 47 void copy(KeyPair::const_span src, KeyPair::span dst) {
IanBenzMaxim 7:9cd16581b578 48 copy(src.privateKey, dst.privateKey);
IanBenzMaxim 7:9cd16581b578 49 copy(src.publicKey, dst.publicKey);
IanBenzMaxim 7:9cd16581b578 50 }
IanBenzMaxim 7:9cd16581b578 51
IanBenzMaxim 8:5ea891c7d1a1 52 bool equal(KeyPair::const_span lhs, KeyPair::const_span rhs) {
IanBenzMaxim 8:5ea891c7d1a1 53 return equal(lhs.privateKey, rhs.privateKey) &&
IanBenzMaxim 8:5ea891c7d1a1 54 equal(lhs.publicKey, rhs.publicKey);
IanBenzMaxim 8:5ea891c7d1a1 55 }
IanBenzMaxim 8:5ea891c7d1a1 56
IanBenzMaxim 7:9cd16581b578 57 void copy(Signature::const_span src, Signature::span dst) {
IanBenzMaxim 7:9cd16581b578 58 copy(src.r, dst.r);
IanBenzMaxim 7:9cd16581b578 59 copy(src.s, dst.s);
IanBenzMaxim 7:9cd16581b578 60 }
IanBenzMaxim 7:9cd16581b578 61
IanBenzMaxim 8:5ea891c7d1a1 62 bool equal(Signature::const_span lhs, Signature::const_span rhs) {
IanBenzMaxim 8:5ea891c7d1a1 63 return equal(lhs.r, rhs.r) && equal(lhs.s, rhs.s);
IanBenzMaxim 8:5ea891c7d1a1 64 }
IanBenzMaxim 8:5ea891c7d1a1 65
IanBenzMaxim 7:9cd16581b578 66 PublicKey::span CertificateData::publicKey() {
IanBenzMaxim 7:9cd16581b578 67 const PublicKey::span span = {
IanBenzMaxim 7:9cd16581b578 68 make_span(result_).subspan<publicKeyIdx, Scalar::size>(),
IanBenzMaxim 7:9cd16581b578 69 make_span(result_).subspan<publicKeyIdx + Scalar::size, Scalar::size>()};
IanBenzMaxim 7:9cd16581b578 70 return span;
IanBenzMaxim 7:9cd16581b578 71 }
IanBenzMaxim 7:9cd16581b578 72
IanBenzMaxim 7:9cd16581b578 73 } // namespace Ecc256
IanBenzMaxim 7:9cd16581b578 74 } // namespace MaximInterfaceCore