1-Wire® library for mbed. Complete 1-Wire library that supports our silicon masters along with a bit-bang master on the MAX32600MBED platform with one common interface for mbed. Slave support has also been included and more slaves will be added as time permits.

Dependents:   MAXREFDES131_Qt_Demo MAX32630FTHR_iButton_uSD_Logger MAX32630FTHR_DS18B20_uSD_Logger MAXREFDES130_131_Demo ... more

Superseded by MaximInterface.

Committer:
IanBenzMaxim
Date:
Fri May 13 14:52:50 2016 -0500
Revision:
75:8b627804927c
Parent:
74:23be10c32fa3
Child:
76:84e6c4994e29
Code cleanup.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IanBenzMaxim 75:8b627804927c 1 /******************************************************************//**
IanBenzMaxim 75:8b627804927c 2 * Copyright (C) 2016 Maxim Integrated Products, Inc., All Rights Reserved.
IanBenzMaxim 75:8b627804927c 3 *
IanBenzMaxim 75:8b627804927c 4 * Permission is hereby granted, free of charge, to any person obtaining a
IanBenzMaxim 75:8b627804927c 5 * copy of this software and associated documentation files (the "Software"),
IanBenzMaxim 75:8b627804927c 6 * to deal in the Software without restriction, including without limitation
IanBenzMaxim 75:8b627804927c 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
IanBenzMaxim 75:8b627804927c 8 * and/or sell copies of the Software, and to permit persons to whom the
IanBenzMaxim 75:8b627804927c 9 * Software is furnished to do so, subject to the following conditions:
IanBenzMaxim 75:8b627804927c 10 *
IanBenzMaxim 75:8b627804927c 11 * The above copyright notice and this permission notice shall be included
IanBenzMaxim 75:8b627804927c 12 * in all copies or substantial portions of the Software.
IanBenzMaxim 75:8b627804927c 13 *
IanBenzMaxim 75:8b627804927c 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
IanBenzMaxim 75:8b627804927c 15 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
IanBenzMaxim 75:8b627804927c 16 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IanBenzMaxim 75:8b627804927c 17 * IN NO EVENT SHALL MAXIM INTEGRATED BE LIABLE FOR ANY CLAIM, DAMAGES
IanBenzMaxim 75:8b627804927c 18 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
IanBenzMaxim 75:8b627804927c 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
IanBenzMaxim 75:8b627804927c 20 * OTHER DEALINGS IN THE SOFTWARE.
IanBenzMaxim 75:8b627804927c 21 *
IanBenzMaxim 75:8b627804927c 22 * Except as contained in this notice, the name of Maxim Integrated
IanBenzMaxim 75:8b627804927c 23 * Products, Inc. shall not be used except as stated in the Maxim Integrated
IanBenzMaxim 75:8b627804927c 24 * Products, Inc. Branding Policy.
IanBenzMaxim 75:8b627804927c 25 *
IanBenzMaxim 75:8b627804927c 26 * The mere transfer of this software does not imply any licenses
IanBenzMaxim 75:8b627804927c 27 * of trade secrets, proprietary technology, copyrights, patents,
IanBenzMaxim 75:8b627804927c 28 * trademarks, maskwork rights, or any other form of intellectual
IanBenzMaxim 75:8b627804927c 29 * property whatsoever. Maxim Integrated Products, Inc. retains all
IanBenzMaxim 75:8b627804927c 30 * ownership rights.
IanBenzMaxim 75:8b627804927c 31 **********************************************************************/
IanBenzMaxim 75:8b627804927c 32
IanBenzMaxim 73:2cecc1372acc 33 #ifndef OneWire_Authenticators_ISha256MacCoproc
IanBenzMaxim 73:2cecc1372acc 34 #define OneWire_Authenticators_ISha256MacCoproc
IanBenzMaxim 21:00c94aeb533e 35
IanBenzMaxim 73:2cecc1372acc 36 #include <stddef.h>
IanBenzMaxim 73:2cecc1372acc 37 #include <stdint.h>
IanBenzMaxim 73:2cecc1372acc 38 #include "array.h"
IanBenzMaxim 33:a4c015046956 39
IanBenzMaxim 73:2cecc1372acc 40 namespace OneWire
IanBenzMaxim 21:00c94aeb533e 41 {
IanBenzMaxim 74:23be10c32fa3 42 namespace Authenticators
IanBenzMaxim 73:2cecc1372acc 43 {
IanBenzMaxim 74:23be10c32fa3 44 /// Interface for SHA-256 coprocessors compatible with the DS28E15/22/25 family and similar.
IanBenzMaxim 74:23be10c32fa3 45 class ISha256MacCoproc
IanBenzMaxim 74:23be10c32fa3 46 {
IanBenzMaxim 74:23be10c32fa3 47 public:
IanBenzMaxim 74:23be10c32fa3 48 enum CmdResult
IanBenzMaxim 74:23be10c32fa3 49 {
IanBenzMaxim 74:23be10c32fa3 50 Success,
IanBenzMaxim 74:23be10c32fa3 51 OperationFailure
IanBenzMaxim 74:23be10c32fa3 52 };
IanBenzMaxim 74:23be10c32fa3 53
IanBenzMaxim 74:23be10c32fa3 54 /// Holds the contents of a device memory page.
IanBenzMaxim 74:23be10c32fa3 55 typedef array<uint8_t, 32> DevicePage;
IanBenzMaxim 74:23be10c32fa3 56
IanBenzMaxim 74:23be10c32fa3 57 /// Holds the contents of a device scratchpad.
IanBenzMaxim 74:23be10c32fa3 58 typedef array<uint8_t, 32> DeviceScratchpad;
IanBenzMaxim 74:23be10c32fa3 59
IanBenzMaxim 74:23be10c32fa3 60 /// Holds the contents of a device secret.
IanBenzMaxim 74:23be10c32fa3 61 typedef array<uint8_t, 32> Secret;
IanBenzMaxim 74:23be10c32fa3 62
IanBenzMaxim 74:23be10c32fa3 63 /// Container for a SHA-256 MAC.
IanBenzMaxim 74:23be10c32fa3 64 typedef array<uint8_t, 32> Mac;
IanBenzMaxim 74:23be10c32fa3 65
IanBenzMaxim 74:23be10c32fa3 66 /// Additional data fields for Compute Write MAC operation.
IanBenzMaxim 74:23be10c32fa3 67 typedef array<uint8_t, 20> WriteMacData;
IanBenzMaxim 74:23be10c32fa3 68
IanBenzMaxim 74:23be10c32fa3 69 /// Additional data fields for the Compute Auth. MAC operation.
IanBenzMaxim 74:23be10c32fa3 70 typedef array<uint8_t, 12> AuthMacData;
IanBenzMaxim 21:00c94aeb533e 71
IanBenzMaxim 74:23be10c32fa3 72 /// Additional data field for the Compute Slave Secret operation.
IanBenzMaxim 74:23be10c32fa3 73 typedef array<uint8_t, 12> SlaveSecretData;
IanBenzMaxim 74:23be10c32fa3 74
IanBenzMaxim 74:23be10c32fa3 75 /// Set Master Secret in coprocessor.
IanBenzMaxim 74:23be10c32fa3 76 /// @param[in] masterSecret New master secret to set.
IanBenzMaxim 74:23be10c32fa3 77 virtual CmdResult setMasterSecret(const Secret & masterSecret) = 0;
IanBenzMaxim 74:23be10c32fa3 78
IanBenzMaxim 74:23be10c32fa3 79 /// Compute Slave Secret in the coprocessor.
IanBenzMaxim 74:23be10c32fa3 80 /// @note Uses the previously set Master Secret in computation.
IanBenzMaxim 74:23be10c32fa3 81 /// @param[in] devicePage Page data stored on device.
IanBenzMaxim 74:23be10c32fa3 82 /// @param[in] deviceScratchpad Scratchpad data stored on device.
IanBenzMaxim 74:23be10c32fa3 83 /// @param[in] slaveSecretData Additional data fields as specified by device.
IanBenzMaxim 74:23be10c32fa3 84 virtual CmdResult computeSlaveSecret(const DevicePage & devicePage, const DeviceScratchpad & deviceScratchpad, const SlaveSecretData & slaveSecretData) = 0;
IanBenzMaxim 74:23be10c32fa3 85
IanBenzMaxim 74:23be10c32fa3 86 /// Compute Write MAC
IanBenzMaxim 74:23be10c32fa3 87 /// @note Uses the previously computed Slave Secret in computation.
IanBenzMaxim 74:23be10c32fa3 88 /// @param[in] writeMacData Additional data fields as specified by device.
IanBenzMaxim 74:23be10c32fa3 89 /// @param[out] mac The computed MAC.
IanBenzMaxim 74:23be10c32fa3 90 virtual CmdResult computeWriteMac(const WriteMacData & writeMacData, Mac & mac) const = 0;
IanBenzMaxim 74:23be10c32fa3 91
IanBenzMaxim 74:23be10c32fa3 92 /// Compute Authentication MAC
IanBenzMaxim 74:23be10c32fa3 93 /// @note Uses the previously computed Slave Secret in computation.
IanBenzMaxim 74:23be10c32fa3 94 /// @param[in] devicePage Page data stored on device.
IanBenzMaxim 74:23be10c32fa3 95 /// @param[in] challege Random challenge for device.
IanBenzMaxim 74:23be10c32fa3 96 /// @param[in] authMacData Additional data fields as specified by device.
IanBenzMaxim 74:23be10c32fa3 97 /// @param[out] mac The computed MAC.
IanBenzMaxim 74:23be10c32fa3 98 virtual CmdResult computeAuthMac(const DevicePage & devicePage, const DeviceScratchpad & challenge, const AuthMacData & authMacData, Mac & mac) const = 0;
IanBenzMaxim 74:23be10c32fa3 99 };
IanBenzMaxim 74:23be10c32fa3 100 }
IanBenzMaxim 73:2cecc1372acc 101 }
IanBenzMaxim 21:00c94aeb533e 102
IanBenzMaxim 48:6f9208ae280e 103 #endif