Require Thread Master Key to be 16 bytes. (#1724)

- Update code to use `otMasterKey` type.
This commit is contained in:
Jonathan Hui
2017-05-05 09:21:43 -07:00
committed by GitHub
parent 08f46b3038
commit da7ba8ba19
18 changed files with 89 additions and 140 deletions
+2 -5
View File
@@ -232,14 +232,12 @@ OTAPI ThreadError OTCALL otThreadSetLinkMode(otInstance *aInstance, otLinkModeCo
* Get the thrMasterKey.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[out] aKeyLength A pointer to an unsigned 8-bit value that the function will set to the number of bytes that
* represent the thrMasterKey. Caller may set to NULL.
*
* @returns A pointer to a buffer containing the thrMasterKey.
*
* @sa otThreadSetMasterKey
*/
OTAPI const uint8_t *OTCALL otThreadGetMasterKey(otInstance *aInstance, uint8_t *aKeyLength);
OTAPI const otMasterKey *OTCALL otThreadGetMasterKey(otInstance *aInstance);
/**
* Set the thrMasterKey.
@@ -250,7 +248,6 @@ OTAPI const uint8_t *OTCALL otThreadGetMasterKey(otInstance *aInstance, uint8_t
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aKey A pointer to a buffer containing the thrMasterKey.
* @param[in] aKeyLength Number of bytes representing the thrMasterKey stored at aKey. Valid range is [0, 16].
*
* @retval kThreadErrorNone Successfully set the thrMasterKey.
* @retval kThreadErrorInvalidArgs If aKeyLength is larger than 16.
@@ -258,7 +255,7 @@ OTAPI const uint8_t *OTCALL otThreadGetMasterKey(otInstance *aInstance, uint8_t
*
* @sa otThreadGetMasterKey
*/
OTAPI ThreadError OTCALL otThreadSetMasterKey(otInstance *aInstance, const uint8_t *aKey, uint8_t aKeyLength);
OTAPI ThreadError OTCALL otThreadSetMasterKey(otInstance *aInstance, const otMasterKey *aKey);
/**
* Get the thrPSKc.
+5 -2
View File
@@ -213,10 +213,13 @@ typedef enum ThreadError
* This structure represents a Thread Master Key.
*
*/
typedef struct otMasterKey
OT_TOOL_PACKED_BEGIN
struct otMasterKey
{
uint8_t m8[OT_MASTER_KEY_SIZE];
} otMasterKey;
} OT_TOOL_PACKED_END;
typedef struct otMasterKey otMasterKey;
#define OT_NETWORK_NAME_MAX_SIZE 16 ///< Maximum size of the Thread Network Name field (bytes)