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