Implementation of 1-Wire with added Alarm Search Functionality
Dependents: Max32630_One_Wire_Interface
Authenticators/ISha256MacCoproc.h@73:2cecc1372acc, 2016-05-12 (annotated)
- Committer:
- IanBenzMaxim
- Date:
- Thu May 12 14:38:16 2016 -0500
- Revision:
- 73:2cecc1372acc
- Parent:
- OneWire_Masters/ISha256MacCoprocessor.hpp@49:36954b62f503
- Child:
- 74:23be10c32fa3
Added namespaces. Renamed files and directories for consistency. Use <stdint.h> instead of <cstdint> since it is not supported by C++98.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
IanBenzMaxim | 73:2cecc1372acc | 1 | #ifndef OneWire_Authenticators_ISha256MacCoproc |
IanBenzMaxim | 73:2cecc1372acc | 2 | #define OneWire_Authenticators_ISha256MacCoproc |
IanBenzMaxim | 21:00c94aeb533e | 3 | |
IanBenzMaxim | 73:2cecc1372acc | 4 | #include <stddef.h> |
IanBenzMaxim | 73:2cecc1372acc | 5 | #include <stdint.h> |
IanBenzMaxim | 21:00c94aeb533e | 6 | |
IanBenzMaxim | 73:2cecc1372acc | 7 | #include "array.h" |
IanBenzMaxim | 33:a4c015046956 | 8 | |
IanBenzMaxim | 73:2cecc1372acc | 9 | namespace OneWire |
IanBenzMaxim | 21:00c94aeb533e | 10 | { |
IanBenzMaxim | 73:2cecc1372acc | 11 | namespace Authenticators |
IanBenzMaxim | 21:00c94aeb533e | 12 | { |
IanBenzMaxim | 73:2cecc1372acc | 13 | /// Interface for SHA-256 coprocessors compatible with the DS28E15/22/25 family and similar. |
IanBenzMaxim | 73:2cecc1372acc | 14 | class ISha256MacCoproc |
IanBenzMaxim | 73:2cecc1372acc | 15 | { |
IanBenzMaxim | 73:2cecc1372acc | 16 | public: |
IanBenzMaxim | 73:2cecc1372acc | 17 | enum CmdResult |
IanBenzMaxim | 73:2cecc1372acc | 18 | { |
IanBenzMaxim | 73:2cecc1372acc | 19 | Success, |
IanBenzMaxim | 73:2cecc1372acc | 20 | OperationFailure |
IanBenzMaxim | 73:2cecc1372acc | 21 | }; |
IanBenzMaxim | 21:00c94aeb533e | 22 | |
IanBenzMaxim | 73:2cecc1372acc | 23 | /// Holds the contents of a device memory page. |
IanBenzMaxim | 73:2cecc1372acc | 24 | typedef array<uint8_t, 32> DevicePage; |
IanBenzMaxim | 73:2cecc1372acc | 25 | |
IanBenzMaxim | 73:2cecc1372acc | 26 | /// Holds the contents of a device scratchpad. |
IanBenzMaxim | 73:2cecc1372acc | 27 | typedef array<uint8_t, 32> DeviceScratchpad; |
IanBenzMaxim | 73:2cecc1372acc | 28 | |
IanBenzMaxim | 73:2cecc1372acc | 29 | /// Holds the contents of a device secret. |
IanBenzMaxim | 73:2cecc1372acc | 30 | typedef array<uint8_t, 32> Secret; |
IanBenzMaxim | 73:2cecc1372acc | 31 | |
IanBenzMaxim | 73:2cecc1372acc | 32 | /// Container for a SHA-256 MAC. |
IanBenzMaxim | 73:2cecc1372acc | 33 | typedef array<uint8_t, 32> Mac; |
IanBenzMaxim | 73:2cecc1372acc | 34 | |
IanBenzMaxim | 73:2cecc1372acc | 35 | /// Additional data fields for Compute Write MAC operation. |
IanBenzMaxim | 73:2cecc1372acc | 36 | typedef array<uint8_t, 20> WriteMacData; |
IanBenzMaxim | 73:2cecc1372acc | 37 | |
IanBenzMaxim | 73:2cecc1372acc | 38 | /// Additional data fields for the Compute Auth. MAC operation. |
IanBenzMaxim | 73:2cecc1372acc | 39 | typedef array<uint8_t, 12> AuthMacData; |
IanBenzMaxim | 73:2cecc1372acc | 40 | |
IanBenzMaxim | 73:2cecc1372acc | 41 | /// Additional data field for the Compute Slave Secret operation. |
IanBenzMaxim | 73:2cecc1372acc | 42 | typedef array<uint8_t, 12> SlaveSecretData; |
IanBenzMaxim | 73:2cecc1372acc | 43 | |
IanBenzMaxim | 73:2cecc1372acc | 44 | /// Set Master Secret in coprocessor. |
IanBenzMaxim | 73:2cecc1372acc | 45 | /// @param[in] masterSecret New master secret to set. |
IanBenzMaxim | 73:2cecc1372acc | 46 | virtual CmdResult setMasterSecret(const Secret & masterSecret) = 0; |
IanBenzMaxim | 73:2cecc1372acc | 47 | |
IanBenzMaxim | 73:2cecc1372acc | 48 | /// Compute Slave Secret in the coprocessor. |
IanBenzMaxim | 73:2cecc1372acc | 49 | /// @note Uses the previously set Master Secret in computation. |
IanBenzMaxim | 73:2cecc1372acc | 50 | /// @param[in] devicePage Page data stored on device. |
IanBenzMaxim | 73:2cecc1372acc | 51 | /// @param[in] deviceScratchpad Scratchpad data stored on device. |
IanBenzMaxim | 73:2cecc1372acc | 52 | /// @param[in] slaveSecretData Additional data fields as specified by device. |
IanBenzMaxim | 73:2cecc1372acc | 53 | virtual CmdResult computeSlaveSecret(const DevicePage & devicePage, const DeviceScratchpad & deviceScratchpad, const SlaveSecretData & slaveSecretData) = 0; |
IanBenzMaxim | 73:2cecc1372acc | 54 | |
IanBenzMaxim | 73:2cecc1372acc | 55 | /// Compute Write MAC |
IanBenzMaxim | 73:2cecc1372acc | 56 | /// @note Uses the previously computed Slave Secret in computation. |
IanBenzMaxim | 73:2cecc1372acc | 57 | /// @param[in] writeMacData Additional data fields as specified by device. |
IanBenzMaxim | 73:2cecc1372acc | 58 | /// @param[out] mac The computed MAC. |
IanBenzMaxim | 73:2cecc1372acc | 59 | virtual CmdResult computeWriteMac(const WriteMacData & writeMacData, Mac & mac) const = 0; |
IanBenzMaxim | 73:2cecc1372acc | 60 | |
IanBenzMaxim | 73:2cecc1372acc | 61 | /// Compute Authentication MAC |
IanBenzMaxim | 73:2cecc1372acc | 62 | /// @note Uses the previously computed Slave Secret in computation. |
IanBenzMaxim | 73:2cecc1372acc | 63 | /// @param[in] devicePage Page data stored on device. |
IanBenzMaxim | 73:2cecc1372acc | 64 | /// @param[in] challege Random challenge for device. |
IanBenzMaxim | 73:2cecc1372acc | 65 | /// @param[in] authMacData Additional data fields as specified by device. |
IanBenzMaxim | 73:2cecc1372acc | 66 | /// @param[out] mac The computed MAC. |
IanBenzMaxim | 73:2cecc1372acc | 67 | virtual CmdResult computeAuthMac(const DevicePage & devicePage, const DeviceScratchpad & challenge, const AuthMacData & authMacData, Mac & mac) const = 0; |
IanBenzMaxim | 73:2cecc1372acc | 68 | }; |
IanBenzMaxim | 73:2cecc1372acc | 69 | } |
IanBenzMaxim | 73:2cecc1372acc | 70 | } |
IanBenzMaxim | 21:00c94aeb533e | 71 | |
IanBenzMaxim | 48:6f9208ae280e | 72 | #endif |