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
+5 -7
View File
@@ -1354,10 +1354,9 @@ void Interpreter::ProcessMasterKey(int argc, char *argv[])
if (argc == 0)
{
uint8_t keyLength;
otBufferPtr key(otThreadGetMasterKey(mInstance, &keyLength));
otBufferPtr key(reinterpret_cast<const uint8_t *>(otThreadGetMasterKey(mInstance)));
for (int i = 0; i < keyLength; i++)
for (int i = 0; i < OT_MASTER_KEY_SIZE; i++)
{
sServer->OutputFormat("%02x", key[i]);
}
@@ -1366,11 +1365,10 @@ void Interpreter::ProcessMasterKey(int argc, char *argv[])
}
else
{
int keyLength;
uint8_t key[OT_MASTER_KEY_SIZE];
otMasterKey key;
VerifyOrExit((keyLength = Hex2Bin(argv[0], key, sizeof(key))) == OT_MASTER_KEY_SIZE, error = kThreadError_Parse);
SuccessOrExit(error = otThreadSetMasterKey(mInstance, key, static_cast<uint8_t>(keyLength)));
VerifyOrExit(Hex2Bin(argv[0], key.m8, sizeof(key.m8)) == OT_MASTER_KEY_SIZE, error = kThreadError_Parse);
SuccessOrExit(error = otThreadSetMasterKey(mInstance, &key));
}
exit: