Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Slaves/Authenticators/ISha256MacCoproc.h@86:2ce08ca58b9e, 2016-06-15 (annotated)
- Committer:
- IanBenzMaxim
- Date:
- Wed Jun 15 15:00:06 2016 -0500
- Revision:
- 86:2ce08ca58b9e
- Parent:
- Authenticators/ISha256MacCoproc.h@76:84e6c4994e29
Updated to match new directory structure.
Who changed what in which revision?
User | Revision | Line number | New 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 | 86:2ce08ca58b9e | 38 | #include "Utilities/array.h" |
IanBenzMaxim | 33:a4c015046956 | 39 | |
IanBenzMaxim | 73:2cecc1372acc | 40 | namespace OneWire |
IanBenzMaxim | 21:00c94aeb533e | 41 | { |
IanBenzMaxim | 76:84e6c4994e29 | 42 | /// Interface for SHA-256 coprocessors compatible with the DS28E15/22/25 family and similar. |
IanBenzMaxim | 76:84e6c4994e29 | 43 | class ISha256MacCoproc |
IanBenzMaxim | 73:2cecc1372acc | 44 | { |
IanBenzMaxim | 76:84e6c4994e29 | 45 | public: |
IanBenzMaxim | 76:84e6c4994e29 | 46 | enum CmdResult |
IanBenzMaxim | 74:23be10c32fa3 | 47 | { |
IanBenzMaxim | 76:84e6c4994e29 | 48 | Success, |
IanBenzMaxim | 76:84e6c4994e29 | 49 | OperationFailure |
IanBenzMaxim | 76:84e6c4994e29 | 50 | }; |
IanBenzMaxim | 74:23be10c32fa3 | 51 | |
IanBenzMaxim | 76:84e6c4994e29 | 52 | /// Holds the contents of a device memory page. |
IanBenzMaxim | 76:84e6c4994e29 | 53 | typedef array<uint8_t, 32> DevicePage; |
IanBenzMaxim | 74:23be10c32fa3 | 54 | |
IanBenzMaxim | 76:84e6c4994e29 | 55 | /// Holds the contents of a device scratchpad. |
IanBenzMaxim | 76:84e6c4994e29 | 56 | typedef array<uint8_t, 32> DeviceScratchpad; |
IanBenzMaxim | 74:23be10c32fa3 | 57 | |
IanBenzMaxim | 76:84e6c4994e29 | 58 | /// Holds the contents of a device secret. |
IanBenzMaxim | 76:84e6c4994e29 | 59 | typedef array<uint8_t, 32> Secret; |
IanBenzMaxim | 74:23be10c32fa3 | 60 | |
IanBenzMaxim | 76:84e6c4994e29 | 61 | /// Container for a SHA-256 MAC. |
IanBenzMaxim | 76:84e6c4994e29 | 62 | typedef array<uint8_t, 32> Mac; |
IanBenzMaxim | 74:23be10c32fa3 | 63 | |
IanBenzMaxim | 76:84e6c4994e29 | 64 | /// Additional data fields for Compute Write MAC operation. |
IanBenzMaxim | 76:84e6c4994e29 | 65 | typedef array<uint8_t, 20> WriteMacData; |
IanBenzMaxim | 74:23be10c32fa3 | 66 | |
IanBenzMaxim | 76:84e6c4994e29 | 67 | /// Additional data fields for the Compute Auth. MAC operation. |
IanBenzMaxim | 76:84e6c4994e29 | 68 | typedef array<uint8_t, 12> AuthMacData; |
IanBenzMaxim | 21:00c94aeb533e | 69 | |
IanBenzMaxim | 76:84e6c4994e29 | 70 | /// Additional data field for the Compute Slave Secret operation. |
IanBenzMaxim | 76:84e6c4994e29 | 71 | typedef array<uint8_t, 12> SlaveSecretData; |
IanBenzMaxim | 74:23be10c32fa3 | 72 | |
IanBenzMaxim | 76:84e6c4994e29 | 73 | /// Set Master Secret in coprocessor. |
IanBenzMaxim | 76:84e6c4994e29 | 74 | /// @param[in] masterSecret New master secret to set. |
IanBenzMaxim | 76:84e6c4994e29 | 75 | virtual CmdResult setMasterSecret(const Secret & masterSecret) = 0; |
IanBenzMaxim | 74:23be10c32fa3 | 76 | |
IanBenzMaxim | 76:84e6c4994e29 | 77 | /// Compute Slave Secret in the coprocessor. |
IanBenzMaxim | 76:84e6c4994e29 | 78 | /// @note Uses the previously set Master Secret in computation. |
IanBenzMaxim | 76:84e6c4994e29 | 79 | /// @param[in] devicePage Page data stored on device. |
IanBenzMaxim | 76:84e6c4994e29 | 80 | /// @param[in] deviceScratchpad Scratchpad data stored on device. |
IanBenzMaxim | 76:84e6c4994e29 | 81 | /// @param[in] slaveSecretData Additional data fields as specified by device. |
IanBenzMaxim | 76:84e6c4994e29 | 82 | virtual CmdResult computeSlaveSecret(const DevicePage & devicePage, const DeviceScratchpad & deviceScratchpad, const SlaveSecretData & slaveSecretData) = 0; |
IanBenzMaxim | 74:23be10c32fa3 | 83 | |
IanBenzMaxim | 76:84e6c4994e29 | 84 | /// Compute Write MAC |
IanBenzMaxim | 76:84e6c4994e29 | 85 | /// @note Uses the previously computed Slave Secret in computation. |
IanBenzMaxim | 76:84e6c4994e29 | 86 | /// @param[in] writeMacData Additional data fields as specified by device. |
IanBenzMaxim | 76:84e6c4994e29 | 87 | /// @param[out] mac The computed MAC. |
IanBenzMaxim | 76:84e6c4994e29 | 88 | virtual CmdResult computeWriteMac(const WriteMacData & writeMacData, Mac & mac) const = 0; |
IanBenzMaxim | 74:23be10c32fa3 | 89 | |
IanBenzMaxim | 76:84e6c4994e29 | 90 | /// Compute Authentication MAC |
IanBenzMaxim | 76:84e6c4994e29 | 91 | /// @note Uses the previously computed Slave Secret in computation. |
IanBenzMaxim | 76:84e6c4994e29 | 92 | /// @param[in] devicePage Page data stored on device. |
IanBenzMaxim | 76:84e6c4994e29 | 93 | /// @param[in] challege Random challenge for device. |
IanBenzMaxim | 76:84e6c4994e29 | 94 | /// @param[in] authMacData Additional data fields as specified by device. |
IanBenzMaxim | 76:84e6c4994e29 | 95 | /// @param[out] mac The computed MAC. |
IanBenzMaxim | 76:84e6c4994e29 | 96 | virtual CmdResult computeAuthMac(const DevicePage & devicePage, const DeviceScratchpad & challenge, const AuthMacData & authMacData, Mac & mac) const = 0; |
IanBenzMaxim | 76:84e6c4994e29 | 97 | }; |
IanBenzMaxim | 73:2cecc1372acc | 98 | } |
IanBenzMaxim | 21:00c94aeb533e | 99 | |
IanBenzMaxim | 48:6f9208ae280e | 100 | #endif |