Skip to content

Commit

Permalink
masterKey terminology applied
Browse files Browse the repository at this point in the history
  • Loading branch information
tttttangTH committed Aug 26, 2020
1 parent e0835d9 commit d83733c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/rest/frontend/res/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
extPanId: '1111111122222222',
panId: '0x1234',
passphrase: '123456',
networkKey: '00112233445566778899aabbccddeeff',
masterKey: '00112233445566778899aabbccddeeff',
channel: 15,
prefix: 'fd11:22::',
defaultRoute: true,
Expand Down Expand Up @@ -268,7 +268,7 @@
var networkInfo = sharedProperties.getNetworkInfo();
$scope.isDisplay = false;
$scope.thread = {
networkKey: '00112233445566778899aabbccddeeff',
masterKey: '00112233445566778899aabbccddeeff',
prefix: 'fd11:22::',
defaultRoute: true,
};
Expand Down Expand Up @@ -319,7 +319,7 @@
};
$scope.isDisplay = true;
var data = {
networkKey: $scope.thread.networkKey,
masterKey: $scope.thread.masterKey,
prefix: $scope.thread.prefix,
defaultRoute: $scope.thread.defaultRoute,
index: index,
Expand Down Expand Up @@ -373,7 +373,7 @@
$scope.thread.defaultRoute = false;
};
var data = {
networkKey: $scope.thread.networkKey,
masterKey: $scope.thread.masterKey,
prefix: $scope.thread.prefix,
defaultRoute: $scope.thread.defaultRoute,
extPanId: $scope.thread.extPanId,
Expand Down
4 changes: 2 additions & 2 deletions src/rest/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -636,9 +636,9 @@ bool JsonString2NetworkConfiguration(std::string aString, NetworkConfiguration &
bool ret = true;

jsonOut = cJSON_Parse(aString.c_str());
value = cJSON_GetObjectItemCaseSensitive(jsonOut, "networkKey");
value = cJSON_GetObjectItemCaseSensitive(jsonOut, "masterKey");
VerifyOrExit(cJSON_IsString(value) && (value->valuestring != nullptr), ret = false);
aNetwork.mNetworkKey = std::string(value->valuestring);
aNetwork.mMasterKey = std::string(value->valuestring);

value = cJSON_GetObjectItemCaseSensitive(jsonOut, "prefix");
VerifyOrExit(cJSON_IsString(value) && (value->valuestring != nullptr), ret = false);
Expand Down
10 changes: 5 additions & 5 deletions src/rest/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ void Resource::PutCurrentNetworkCallback(const Request &aRequest, Response &aRes
std::string requestBody;
otExtendedPanId extPanid;
long panid;
std::string networkKey, prefix, extPanId, networkName, panId;
std::string masterKey, prefix, extPanId, networkName, panId;
int32_t channel;
char * endptr;
bool defaultRoute;
Expand All @@ -528,8 +528,8 @@ void Resource::PutCurrentNetworkCallback(const Request &aRequest, Response &aRes

requestBody = aRequest.GetBody();

VerifyOrExit(Json::JsonString2String(requestBody, std::string("networkKey"), networkKey),
error = PostError::kPostBadRequest, errorDescription = "Failed at decode json : networkKey");
VerifyOrExit(Json::JsonString2String(requestBody, std::string("masterKey"), masterKey),
error = PostError::kPostBadRequest, errorDescription = "Failed at decode json : masterKey");
VerifyOrExit(Json::JsonString2Bool(requestBody, std::string("defaultRoute"), defaultRoute),
error = PostError::kPostBadRequest, errorDescription = "Failed at decode json : defaultRoute");
VerifyOrExit(Json::JsonString2String(requestBody, std::string("prefix"), prefix),
Expand All @@ -542,7 +542,7 @@ void Resource::PutCurrentNetworkCallback(const Request &aRequest, Response &aRes
errorDescription = "Failed at decode json : channel");
VerifyOrExit(Json::JsonString2String(requestBody, std::string("panId"), panId), error = PostError::kPostBadRequest,
errorDescription = "Failed at decode json : panId");
VerifyOrExit(otbr::Utils::Hex2Bytes(networkKey.c_str(), masterKey.m8, sizeof(masterKey.m8)) == OT_MASTER_KEY_SIZE,
VerifyOrExit(otbr::Utils::Hex2Bytes(masterKey.c_str(), masterKey.m8, sizeof(masterKey.m8)) == OT_MASTER_KEY_SIZE,
error = PostError::kPostBadRequest, errorDescription = "Failed at encode masterkey : not valid");

// Set Master Key
Expand Down Expand Up @@ -1021,7 +1021,7 @@ void Resource::PostNetworksCallback(const Request &aRequest, Response &aResponse
otbr::Utils::Bytes2Hex(psk.ComputePskc(extPanIdBytes, network.mNetworkName.c_str(), network.mPassphrase.c_str()),
OT_PSKC_MAX_LENGTH, pskcStr);

VerifyOrExit(otbr::Utils::Hex2Bytes(network.mNetworkKey.c_str(), masterKey.m8, sizeof(masterKey.m8)) ==
VerifyOrExit(otbr::Utils::Hex2Bytes(network.mMasterKey.c_str(), masterKey.m8, sizeof(masterKey.m8)) ==
OT_MASTER_KEY_SIZE,
error = PostError::kPostBadRequest, errorDescription = "Failed at encode masterkey : not valid");
// Set Master Key
Expand Down
2 changes: 1 addition & 1 deletion src/rest/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ struct NetworkConfiguration
{
bool mDefaultRoute;
uint8_t mChannel;
std::string mNetworkKey;
std::string mMasterKey;
std::string mPrefix;
std::string mNetworkName;
std::string mPanId;
Expand Down
6 changes: 3 additions & 3 deletions tests/rest/test_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ def form_network_test():
'extPanId': '1111111122222222',
'panId': '0x1234',
'passphrase': '123456',
'networkKey': '00112233445566778899aabbccddeeff',
'masterKey': '00112233445566778899aabbccddeeff',
'channel': 15,
'prefix': 'fd11:22::',
'defaultRoute': True,
Expand Down Expand Up @@ -556,7 +556,7 @@ def join():
'panId': '0xface',
'channel': 20,
'networkName': 'hello',
'networkKey': '10112233445566778899aabbccddeefe',
'masterKey': '10112233445566778899aabbccddeefe',
'defaultRoute': False,
"prefix": 'fd17:22::'
}
Expand All @@ -567,7 +567,7 @@ def join():

body = response.read()
data = json.loads(body)
assert data['networkKey'] == '10112233445566778899aabbccddeefe'
assert data['masterKey'] == '10112233445566778899aabbccddeefe'

time.sleep(10)

Expand Down

0 comments on commit d83733c

Please sign in to comment.