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:
Thu Apr 07 11:26:20 2016 -0500
Revision:
48:6f9208ae280e
Parent:
33:a4c015046956
Child:
49:36954b62f503
Fix narrowing warning. Add comments to ISha256MacCoprocessor.

Who changed what in which revision?

UserRevisionLine numberNew 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 48:6f9208ae280e 9 /// Interface for SHA-256 coprocessors compatible with the DS28E15/22/25 family.
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 33:a4c015046956 19 typedef array<std::uint8_t, 32> DevicePage;
IanBenzMaxim 33:a4c015046956 20 typedef array<std::uint8_t, 32> DeviceScratchpad;
IanBenzMaxim 33:a4c015046956 21 typedef array<std::uint8_t, 32> Secret;
IanBenzMaxim 33:a4c015046956 22 typedef array<std::uint8_t, 32> Mac;
IanBenzMaxim 33:a4c015046956 23 typedef array<std::uint8_t, 20> WriteMacData;
IanBenzMaxim 33:a4c015046956 24 typedef array<std::uint8_t, 12> AuthMacData;
IanBenzMaxim 33:a4c015046956 25 typedef array<std::uint8_t, 12> SlaveSecretData;
IanBenzMaxim 21:00c94aeb533e 26
IanBenzMaxim 48:6f9208ae280e 27 /// Set Master Secret in coprocessor.
IanBenzMaxim 48:6f9208ae280e 28 /// @param[in] masterSecret New master secret to set.
IanBenzMaxim 48:6f9208ae280e 29 virtual CmdResult setMasterSecret(const Secret & masterSecret) = 0;
IanBenzMaxim 48:6f9208ae280e 30
IanBenzMaxim 48:6f9208ae280e 31 /// Compute Slave Secret in the coprocessor.
IanBenzMaxim 48:6f9208ae280e 32 /// @note Uses the previously set Master Secret in computation.
IanBenzMaxim 48:6f9208ae280e 33 /// @param[in] devicePage Page data stored on device.
IanBenzMaxim 48:6f9208ae280e 34 /// @param[in] deviceScratchpad Scratchpad data stored on device.
IanBenzMaxim 48:6f9208ae280e 35 /// @param[in] slaveSecretData Variable data field used in calculation.
IanBenzMaxim 48:6f9208ae280e 36 virtual CmdResult computeSlaveSecret(const DevicePage & devicePage, const DeviceScratchpad & deviceScratchpad, const SlaveSecretData & slaveSecretData) = 0;
IanBenzMaxim 48:6f9208ae280e 37
IanBenzMaxim 48:6f9208ae280e 38 /// Compute Write MAC
IanBenzMaxim 48:6f9208ae280e 39 /// @note Uses the previously computed Slave Secret in computation.
IanBenzMaxim 48:6f9208ae280e 40 /// @param[in] writeMacData Variable data fields used in calculation.
IanBenzMaxim 48:6f9208ae280e 41 /// @param[out] mac The computed MAC.
IanBenzMaxim 33:a4c015046956 42 virtual CmdResult computeWriteMac(const WriteMacData & writeMacData, Mac & mac) const = 0;
IanBenzMaxim 48:6f9208ae280e 43
IanBenzMaxim 48:6f9208ae280e 44 /// Compute Authentication MAC
IanBenzMaxim 48:6f9208ae280e 45 /// @note Uses the previously computed Slave Secret in computation.
IanBenzMaxim 48:6f9208ae280e 46 /// @param[in] devicePage Page data stored on device.
IanBenzMaxim 48:6f9208ae280e 47 /// @param[in] challege Random challenge for device.
IanBenzMaxim 48:6f9208ae280e 48 /// @param[in] authMacData Variable data fields used in calculation.
IanBenzMaxim 48:6f9208ae280e 49 /// @param[out] mac The computed MAC.
IanBenzMaxim 33:a4c015046956 50 virtual CmdResult computeAuthMac(const DevicePage & devicePage, const DeviceScratchpad & challenge, const AuthMacData & authMacData, Mac & mac) const = 0;
IanBenzMaxim 21:00c94aeb533e 51 };
IanBenzMaxim 21:00c94aeb533e 52
IanBenzMaxim 48:6f9208ae280e 53 #endif