[network-key] change name from master to network (#6721)

This commit is contained in:
Jonathan Hui
2021-06-16 23:07:23 -07:00
committed by GitHub
parent b0081172af
commit aaabf25ff2
76 changed files with 556 additions and 550 deletions
+10 -2
View File
@@ -406,6 +406,7 @@ jobs:
CXXFLAGS: -m32
LDFLAGS: -m32
COVERAGE: 1
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
NODE_TYPE: ncp-sim
PYTHONUNBUFFERED: 1
REFERENCE_DEVICE: 1
@@ -420,7 +421,10 @@ jobs:
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y g++-multilib python3-setuptools python3-wheel lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
sudo python3 -m pip install git+https://github.com/openthread/pyspinel
pyspineldir=$(mktemp -d -t pyspinel_XXXXXX)
./script/git-tool clone https://github.com/openthread/pyspinel.git --depth 1 "${pyspineldir}"
cd "${pyspineldir}"
pip3 install .
- name: Build
run: |
./bootstrap
@@ -445,6 +449,7 @@ jobs:
runs-on: ubuntu-20.04
env:
COVERAGE: 1
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
NODE_TYPE: ncp-sim
PYTHONUNBUFFERED: 1
REFERENCE_DEVICE: 1
@@ -461,7 +466,10 @@ jobs:
sudo rm /etc/apt/sources.list.d/* && sudo apt-get update
sudo apt-get --no-install-recommends install -y clang-10 clang++-10 python3-setuptools python3-wheel llvm lcov
python3 -m pip install -r tests/scripts/thread-cert/requirements.txt
sudo python3 -m pip install git+https://github.com/openthread/pyspinel
pyspineldir=$(mktemp -d -t pyspinel_XXXXXX)
./script/git-tool clone https://github.com/openthread/pyspinel.git --depth 1 "${pyspineldir}"
cd "${pyspineldir}"
pip3 install .
- name: Build
run: |
./bootstrap
+3 -3
View File
@@ -30,7 +30,7 @@ Channel: 13
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
@@ -82,10 +82,10 @@ $ cd <path-to-openthread>/output/<platform>/bin
$ ./ot-cli-ftd 2
```
Configure Thread Master Key from Node 1's Active Operational Dataset:
Configure Thread Network Key from Node 1's Active Operational Dataset:
```bash
> dataset masterkey dfd34f0f05cad978ec4e32b0413038ff
> dataset networkkey dfd34f0f05cad978ec4e32b0413038ff
Done
> dataset commit active
Done
+1 -1
View File
@@ -93,10 +93,10 @@ extpanid
ipaddr
keysequence
leaderweight
masterkey
mode
netdata register
networkidtimeout
networkkey
networkname
panid
ping
+1 -1
View File
@@ -52,10 +52,10 @@ extpanid
ipaddr
keysequence
leaderweight
masterkey
mode
netdata register
networkidtimeout
networkkey
networkname
panid
ping
+14 -14
View File
@@ -50,25 +50,25 @@ extern "C" {
*
*/
#define OT_MASTER_KEY_SIZE 16 ///< Size of the Thread Master Key (bytes)
#define OT_NETWORK_KEY_SIZE 16 ///< Size of the Thread Network Key (bytes)
/**
* @struct otMasterKey
* @struct otNetworkKey
*
* This structure represents a Thread Master Key.
* This structure represents a Thread Network Key.
*
*/
OT_TOOL_PACKED_BEGIN
struct otMasterKey
struct otNetworkKey
{
uint8_t m8[OT_MASTER_KEY_SIZE]; ///< Byte values
uint8_t m8[OT_NETWORK_KEY_SIZE]; ///< Byte values
} OT_TOOL_PACKED_END;
/**
* This structure represents a Thread Master Key.
* This structure represents a Thread Network Key.
*
*/
typedef struct otMasterKey otMasterKey;
typedef struct otNetworkKey otNetworkKey;
#define OT_NETWORK_NAME_MAX_SIZE 16 ///< Maximum size of the Thread Network Name field (bytes)
@@ -135,14 +135,14 @@ typedef struct otSecurityPolicy
{
uint16_t mRotationTime; ///< The value for thrKeyRotation in units of hours.
bool mObtainMasterKeyEnabled : 1; ///< Obtaining the Master Key for out-of-band commissioning is enabled
bool mObtainNetworkKeyEnabled : 1; ///< Obtaining the Network Key for out-of-band commissioning is enabled
bool mNativeCommissioningEnabled : 1; ///< Native Commissioning using PSKc is allowed
bool mRoutersEnabled : 1; ///< Thread 1.0/1.1.x Routers are enabled
bool mExternalCommissioningEnabled : 1; ///< External Commissioner authentication is allowed
bool mBeaconsEnabled : 1; ///< Thread 1.0/1.1.x Beacons are enabled
bool mCommercialCommissioningEnabled : 1; ///< Commercial Commissioning is enabled
bool mAutonomousEnrollmentEnabled : 1; ///< Autonomous Enrollment is enabled
bool mMasterKeyProvisioningEnabled : 1; ///< Network Master-key Provisioning is enabled
bool mNetworkKeyProvisioningEnabled : 1; ///< Network Key Provisioning is enabled
bool mTobleLinkEnabled : 1; ///< ToBLE link is enabled
bool mNonCcmRoutersEnabled : 1; ///< Non-CCM Routers enabled
uint8_t mVersionThresholdForRouting : 3; ///< Version-threshold for Routing
@@ -189,7 +189,7 @@ typedef struct otOperationalDatasetComponents
{
bool mIsActiveTimestampPresent : 1; ///< TRUE if Active Timestamp is present, FALSE otherwise.
bool mIsPendingTimestampPresent : 1; ///< TRUE if Pending Timestamp is present, FALSE otherwise.
bool mIsMasterKeyPresent : 1; ///< TRUE if Network Master Key is present, FALSE otherwise.
bool mIsNetworkKeyPresent : 1; ///< TRUE if Network Key is present, FALSE otherwise.
bool mIsNetworkNamePresent : 1; ///< TRUE if Network Name is present, FALSE otherwise.
bool mIsExtendedPanIdPresent : 1; ///< TRUE if Extended PAN ID is present, FALSE otherwise.
bool mIsMeshLocalPrefixPresent : 1; ///< TRUE if Mesh Local Prefix is present, FALSE otherwise.
@@ -211,7 +211,7 @@ typedef struct otOperationalDataset
{
uint64_t mActiveTimestamp; ///< Active Timestamp
uint64_t mPendingTimestamp; ///< Pending Timestamp
otMasterKey mMasterKey; ///< Network Master Key
otNetworkKey mNetworkKey; ///< Network Key
otNetworkName mNetworkName; ///< Network Name
otExtendedPanId mExtendedPanId; ///< Extended PAN ID
otMeshLocalPrefix mMeshLocalPrefix; ///< Mesh Local Prefix
@@ -253,7 +253,7 @@ typedef enum otMeshcopTlvType
OT_MESHCOP_TLV_EXTPANID = 2, ///< meshcop Extended Pan Id TLV
OT_MESHCOP_TLV_NETWORKNAME = 3, ///< meshcop Network Name TLV
OT_MESHCOP_TLV_PSKC = 4, ///< meshcop PSKc TLV
OT_MESHCOP_TLV_MASTERKEY = 5, ///< meshcop Network Master Key TLV
OT_MESHCOP_TLV_NETWORKKEY = 5, ///< meshcop Network Key TLV
OT_MESHCOP_TLV_NETWORK_KEY_SEQUENCE = 6, ///< meshcop Network Key Sequence TLV
OT_MESHCOP_TLV_MESHLOCALPREFIX = 7, ///< meshcop Mesh Local Prefix TLV
OT_MESHCOP_TLV_STEERING_DATA = 8, ///< meshcop Steering Data TLV
@@ -330,7 +330,7 @@ otError otDatasetGetActiveTlvs(otInstance *aInstance, otOperationalDatasetTlvs *
* If the dataset does not include an Active Timestamp, the dataset is only partially complete.
*
* If Thread is enabled on a device that has a partially complete Active Dataset, the device will attempt to attach to
* an existing Thread network using any existing information in the dataset. Only the Thread Master Key is needed to
* an existing Thread network using any existing information in the dataset. Only the Thread Network Key is needed to
* attach to a network.
*
* If channel is not included in the dataset, the device will send MLE Announce messages across different channels to
@@ -356,7 +356,7 @@ otError otDatasetSetActive(otInstance *aInstance, const otOperationalDataset *aD
* If the dataset does not include an Active Timestamp, the dataset is only partially complete.
*
* If Thread is enabled on a device that has a partially complete Active Dataset, the device will attempt to attach to
* an existing Thread network using any existing information in the dataset. Only the Thread Master Key is needed to
* an existing Thread network using any existing information in the dataset. Only the Thread Network Key is needed to
* attach to a network.
*
* If channel is not included in the dataset, the device will send MLE Announce messages across different channels to
+2 -2
View File
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (125)
#define OPENTHREAD_API_VERSION (126)
/**
* @addtogroup api-instance
@@ -150,7 +150,7 @@ enum
OT_CHANGED_THREAD_PANID = 1 << 15, ///< Thread network PAN Id changed
OT_CHANGED_THREAD_NETWORK_NAME = 1 << 16, ///< Thread network name changed
OT_CHANGED_THREAD_EXT_PANID = 1 << 17, ///< Thread network extended PAN ID changed
OT_CHANGED_MASTER_KEY = 1 << 18, ///< Master key changed
OT_CHANGED_NETWORK_KEY = 1 << 18, ///< Network key changed
OT_CHANGED_PSKC = 1 << 19, ///< PSKc changed
OT_CHANGED_SECURITY_POLICY = 1 << 20, ///< Security Policy changed
OT_CHANGED_CHANNEL_MANAGER_NEW_CHANNEL = 1 << 21, ///< Channel Manager new pending Thread channel changed
+9 -9
View File
@@ -378,35 +378,35 @@ otLinkModeConfig otThreadGetLinkMode(otInstance *aInstance);
otError otThreadSetLinkMode(otInstance *aInstance, otLinkModeConfig aConfig);
/**
* Get the thrMasterKey.
* Get the thrNetworkKey.
*
* @param[in] aInstance A pointer to an OpenThread instance.
*
* @returns A pointer to a buffer containing the thrMasterKey.
* @returns A pointer to a buffer containing the thrNetworkKey.
*
* @sa otThreadSetMasterKey
* @sa otThreadSetNetworkKey
*
*/
const otMasterKey *otThreadGetMasterKey(otInstance *aInstance);
const otNetworkKey *otThreadGetNetworkKey(otInstance *aInstance);
/**
* Set the thrMasterKey.
* Set the thrNetworkKey.
*
* This function succeeds only when Thread protocols are disabled. A successful
* call to this function invalidates the Active and Pending Operational Datasets in
* non-volatile memory.
*
* @param[in] aInstance A pointer to an OpenThread instance.
* @param[in] aKey A pointer to a buffer containing the thrMasterKey.
* @param[in] aKey A pointer to a buffer containing the thrNetworkKey.
*
* @retval OT_ERROR_NONE Successfully set the thrMasterKey.
* @retval OT_ERROR_NONE Successfully set the thrNetworkKey.
* @retval OT_ERROR_INVALID_ARGS If aKeyLength is larger than 16.
* @retval OT_ERROR_INVALID_STATE Thread protocols are enabled.
*
* @sa otThreadGetMasterKey
* @sa otThreadGetNetworkKey
*
*/
otError otThreadSetMasterKey(otInstance *aInstance, const otMasterKey *aKey);
otError otThreadSetNetworkKey(otInstance *aInstance, const otNetworkKey *aKey);
/**
* This function returns a pointer to the Thread Routing Locator (RLOC) address.
+1 -1
View File
@@ -42,7 +42,7 @@ main()
{
mkdir -p tmp
echo "The master branch must be ${OT_SHA_OLD}"
echo "The main branch must be ${OT_SHA_OLD}"
git fetch --depth 1 origin "${OT_SHA_OLD}"
+4 -4
View File
@@ -58,7 +58,7 @@ check()
EXT_PANID="0123456789abcdef"
NETWORK_NAME="OT_NCP_TO_RCP"
CHANNEL="20"
MASTER_KEY="0123456789abcdef0123456789abcdef"
NETWORK_KEY="0123456789abcdef0123456789abcdef"
echo "Step 1. Start NCP platform and form a PAN..."
RADIO_NCP_CMD="$PWD/output/simulation/bin/ot-cli-ftd"
@@ -77,7 +77,7 @@ send "networkname ${NETWORK_NAME}\r\n"
expect "Done"
send "channel ${CHANNEL}\r\n"
expect "Done"
send "masterkey ${MASTER_KEY}\r\n"
send "networkkey ${NETWORK_KEY}\r\n"
expect "Done"
send "ifconfig up\r\n"
expect "Done"
@@ -118,8 +118,8 @@ expect "Done"
send "channel\r\n"
expect ${CHANNEL}
expect "Done"
send "masterkey\r\n"
expect ${MASTER_KEY}
send "networkkey\r\n"
expect ${NETWORK_KEY}
expect "Done"
send "exit\r\n"
expect eof
+20 -20
View File
@@ -65,7 +65,6 @@ Done
- [log](#log-filename-filename)
- [mac](#mac-retries-direct)
- [macfilter](#macfilter)
- [masterkey](#masterkey)
- [mliid](#mliid-iid)
- [mlr](#mlr-reg-ipaddr--timeout)
- [mode](#mode)
@@ -75,6 +74,7 @@ Done
- [netstat](#netstat)
- [networkdiagnostic](#networkdiagnostic-get-addr-type-)
- [networkidtimeout](#networkidtimeout)
- [networkkey](#networkkey)
- [networkname](#networkname)
- [networktime](#networktime)
- [panid](#panid)
@@ -1608,25 +1608,6 @@ Set the log level.
Done
```
### masterkey
Get the Thread Master Key value.
```bash
> masterkey
00112233445566778899aabbccddeeff
Done
```
### masterkey \<key\>
Set the Thread Master Key value.
```bash
> masterkey 00112233445566778899aabbccddeeff
Done
```
### mliid \<iid\>
Set the Mesh Local IID.
@@ -1834,6 +1815,25 @@ Set the NETWORK_ID_TIMEOUT parameter used in the Router role.
Done
```
### networkkey
Get the Thread Network Key value.
```bash
> networkkey
00112233445566778899aabbccddeeff
Done
```
### networkkey \<key\>
Set the Thread Network Key value.
```bash
> networkkey 00112233445566778899aabbccddeeff
Done
```
### networkname
Get the Thread Network Name.
+2 -2
View File
@@ -17,7 +17,7 @@ Form a network with the device that has Commissioner support.
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
@@ -103,7 +103,7 @@ Form a network with the device that has Commissioner support.
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
+29 -29
View File
@@ -40,7 +40,7 @@ The Pending Operational Dataset is used to communicate changes to the Active Ope
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
@@ -66,7 +66,7 @@ The Pending Operational Dataset is used to communicate changes to the Active Ope
### Attach to Existing Network
Only the Master Key is required for a device to attach to a Thread network.
Only the Network Key is required for a device to attach to a Thread network.
While not required, specifying the channel avoids the need to search across multiple channels, improving both latency and efficiency of the attach process.
@@ -75,7 +75,7 @@ After the device successfully attaches to a Thread network, the device will retr
1. Create a partial Active Operational Dataset.
```bash
> dataset masterkey dfd34f0f05cad978ec4e32b0413038ff
> dataset networkkey dfd34f0f05cad978ec4e32b0413038ff
Done
> dataset commit active
Done
@@ -99,7 +99,7 @@ After the device successfully attaches to a Thread network, the device will retr
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
@@ -119,10 +119,10 @@ After the device successfully attaches to a Thread network, the device will retr
- [delay](#delay)
- [extpanid](#extpanid)
- [init](#init)
- [masterkey](#masterkey)
- [meshlocalprefix](#meshlocalprefix)
- [mgmtgetcommand](#mgmtgetcommand)
- [mgmtsetcommand](#mgmtsetcommand)
- [networkkey](#networkkey)
- [networkname](#networkname)
- [panid](#panid)
- [pending](#pending)
@@ -150,10 +150,10 @@ commit
delay
extpanid
init
masterkey
meshlocalprefix
mgmtgetcommand
mgmtsetcommand
networkkey
networkname
panid
pending
@@ -176,7 +176,7 @@ Channel: 13
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
@@ -322,25 +322,6 @@ Initialize operational dataset buffer.
Done
```
### masterkey
Usage: `dataset masterkey [key]`
Get master key
```bash
> dataset masterkey
00112233445566778899aabbccddeeff
Done
```
Set master key.
```bash
> dataset masterkey 00112233445566778899aabbccddeeff
Done
```
### meshlocalprefix
Usage: `dataset meshlocalprefix [prefix]`
@@ -382,6 +363,25 @@ Send MGMT_ACTIVE_SET or MGMT_PENDING_SET.
Done
```
### networkkey
Usage: `dataset networkkey [key]`
Get network key
```bash
> dataset networkkey
00112233445566778899aabbccddeeff
Done
```
Set network key.
```bash
> dataset networkkey 00112233445566778899aabbccddeeff
Done
```
### networkname
Usage: `dataset networkname [name]`
@@ -437,7 +437,7 @@ Channel Mask: 0x07fff800
Delay: 58706
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
@@ -509,14 +509,14 @@ Done
Set security policy.
- o: Obtaining the Master Key for out-of-band commissioning is enabled.
- o: Obtaining the Network Key for out-of-band commissioning is enabled.
- n: Native Commissioning using PSKc is allowed.
- r: Thread 1.x Routers are enabled.
- c: External Commissioner authentication is allowed using PSKc.
- b: Thread 1.x Beacons are enabled.
- C: Thread 1.2 Commercial Commissioning is enabled.
- e: Thread 1.2 Autonomous Enrollment is enabled.
- p: Thread 1.2 Network Master Key Provisioning is enabled.
- p: Thread 1.2 Network Key Provisioning is enabled.
- R: Non-CCM routers are allowed in Thread 1.2 CCM networks.
```bash
+3 -3
View File
@@ -23,7 +23,7 @@ Border Router and service information may be stable or temporary. Stable Thread
Channel Mask: 0x07fff800
Ext PAN ID: d63e8e3e495ebbc3
Mesh Local Prefix: fd3d:b50b:f96d:722d::/64
Master Key: dfd34f0f05cad978ec4e32b0413038ff
Network Key: dfd34f0f05cad978ec4e32b0413038ff
Network Name: OpenThread-8f28
PAN ID: 0x8f28
PSKc: c23a76e98f1a6483639b1ac1271e2e27
@@ -92,7 +92,7 @@ Border Router and service information may be stable or temporary. Stable Thread
### Attach to Existing Network
Only the Master Key is required for a device to attach to a Thread network.
Only the Network Key is required for a device to attach to a Thread network.
While not required, specifying the channel avoids the need to search across multiple channels, improving both latency and efficiency of the attach process.
@@ -101,7 +101,7 @@ After the device successfully attaches to a Thread network, the device will retr
1. Create a partial Active Operational Dataset.
```bash
> dataset masterkey dfd34f0f05cad978ec4e32b0413038ff
> dataset networkkey dfd34f0f05cad978ec4e32b0413038ff
Done
> dataset commit active
Done
+2 -2
View File
@@ -21,7 +21,7 @@ Channel: 22
Channel Mask: 0x07fff800
Ext PAN ID: 8d6ed7a05a28fb3b
Mesh Local Prefix: fded:5114:8263:1fe1::/64
Master Key: 7fcbae4153cc2955c28440c15d4d4219
Network Key: 7fcbae4153cc2955c28440c15d4d4219
Network Name: OpenThread-f7af
PAN ID: 0xf7af
PSKc: b658e40f174e3a11be149b302ef07a0f
@@ -57,7 +57,7 @@ Start the SRP Client node:
Join the Thread Network and register a `_ipps._tcp` service:
```bash
> dataset masterkey 7fcbae4153cc2955c28440c15d4d4219
> dataset networkkey 7fcbae4153cc2955c28440c15d4d4219
Done
> dataset commit active
Done
+21 -21
View File
@@ -2546,27 +2546,6 @@ exit:
}
#endif // OPENTHREAD_FTD
otError Interpreter::ProcessMasterKey(uint8_t aArgsLength, Arg aArgs[])
{
otError error = OT_ERROR_NONE;
if (aArgsLength == 0)
{
OutputBytes(otThreadGetMasterKey(mInstance)->m8);
OutputLine("");
}
else
{
otMasterKey key;
SuccessOrExit(error = aArgs[0].ParseAsHexString(key.m8));
SuccessOrExit(error = otThreadSetMasterKey(mInstance, &key));
}
exit:
return error;
}
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
otError Interpreter::ProcessMlIid(uint8_t aArgsLength, Arg aArgs[])
{
@@ -2982,6 +2961,27 @@ otError Interpreter::ProcessNetworkIdTimeout(uint8_t aArgsLength, Arg aArgs[])
}
#endif
otError Interpreter::ProcessNetworkKey(uint8_t aArgsLength, Arg aArgs[])
{
otError error = OT_ERROR_NONE;
if (aArgsLength == 0)
{
OutputBytes(otThreadGetNetworkKey(mInstance)->m8);
OutputLine("");
}
else
{
otNetworkKey key;
SuccessOrExit(error = aArgs[0].ParseAsHexString(key.m8));
SuccessOrExit(error = otThreadSetNetworkKey(mInstance, &key));
}
exit:
return error;
}
otError Interpreter::ProcessNetworkName(uint8_t aArgsLength, Arg aArgs[])
{
otError error = OT_ERROR_NONE;
+2 -2
View File
@@ -518,7 +518,6 @@ private:
otError ProcessPartitionId(uint8_t aArgsLength, Arg aArgs[]);
otError ProcessLeaderWeight(uint8_t aArgsLength, Arg aArgs[]);
#endif
otError ProcessMasterKey(uint8_t aArgsLength, Arg aArgs[]);
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
otError ProcessMlIid(uint8_t aArgsLength, Arg aArgs[]);
#endif
@@ -570,6 +569,7 @@ private:
#if OPENTHREAD_FTD
otError ProcessNetworkIdTimeout(uint8_t aArgsLength, Arg aArgs[]);
#endif
otError ProcessNetworkKey(uint8_t aArgsLength, Arg aArgs[]);
otError ProcessNetworkName(uint8_t aArgsLength, Arg aArgs[]);
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
otError ProcessNetworkTime(uint8_t aArgsLength, Arg aArgs[]);
@@ -819,7 +819,6 @@ private:
#if OPENTHREAD_CONFIG_MAC_FILTER_ENABLE
{"macfilter", &Interpreter::ProcessMacFilter},
#endif
{"masterkey", &Interpreter::ProcessMasterKey},
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
{"mliid", &Interpreter::ProcessMlIid},
#endif
@@ -839,6 +838,7 @@ private:
#if OPENTHREAD_FTD
{"networkidtimeout", &Interpreter::ProcessNetworkIdTimeout},
#endif
{"networkkey", &Interpreter::ProcessNetworkKey},
{"networkname", &Interpreter::ProcessNetworkName},
#if OPENTHREAD_CONFIG_TIME_SYNC_ENABLE
{"networktime", &Interpreter::ProcessNetworkTime},
+34 -34
View File
@@ -89,10 +89,10 @@ otError Dataset::Print(otOperationalDataset &aDataset)
mInterpreter.OutputLine("");
}
if (aDataset.mComponents.mIsMasterKeyPresent)
if (aDataset.mComponents.mIsNetworkKeyPresent)
{
mInterpreter.OutputFormat("Master Key: ");
mInterpreter.OutputBytes(aDataset.mMasterKey.m8);
mInterpreter.OutputFormat("Network Key: ");
mInterpreter.OutputBytes(aDataset.mNetworkKey.m8);
mInterpreter.OutputLine("");
}
@@ -383,28 +383,6 @@ exit:
return error;
}
otError Dataset::ProcessMasterKey(uint8_t aArgsLength, Arg aArgs[])
{
otError error = OT_ERROR_NONE;
if (aArgsLength == 0)
{
if (sDataset.mComponents.mIsMasterKeyPresent)
{
mInterpreter.OutputBytes(sDataset.mMasterKey.m8);
mInterpreter.OutputLine("");
}
}
else
{
SuccessOrExit(error = aArgs[0].ParseAsHexString(sDataset.mMasterKey.m8));
sDataset.mComponents.mIsMasterKeyPresent = true;
}
exit:
return error;
}
otError Dataset::ProcessMeshLocalPrefix(uint8_t aArgsLength, Arg aArgs[])
{
otError error = OT_ERROR_NONE;
@@ -432,6 +410,28 @@ exit:
return error;
}
otError Dataset::ProcessNetworkKey(uint8_t aArgsLength, Arg aArgs[])
{
otError error = OT_ERROR_NONE;
if (aArgsLength == 0)
{
if (sDataset.mComponents.mIsNetworkKeyPresent)
{
mInterpreter.OutputBytes(sDataset.mNetworkKey.m8);
mInterpreter.OutputLine("");
}
}
else
{
SuccessOrExit(error = aArgs[0].ParseAsHexString(sDataset.mNetworkKey.m8));
sDataset.mComponents.mIsNetworkKeyPresent = true;
}
exit:
return error;
}
otError Dataset::ProcessNetworkName(uint8_t aArgsLength, Arg aArgs[])
{
otError error = OT_ERROR_NONE;
@@ -520,11 +520,11 @@ otError Dataset::ProcessMgmtSetCommand(uint8_t aArgsLength, Arg aArgs[])
dataset.mComponents.mIsPendingTimestampPresent = true;
SuccessOrExit(error = aArgs[index].ParseAsUint64(dataset.mPendingTimestamp));
}
else if (aArgs[index] == "masterkey")
else if (aArgs[index] == "networkkey")
{
VerifyOrExit(++index < aArgsLength, error = OT_ERROR_INVALID_ARGS);
dataset.mComponents.mIsMasterKeyPresent = true;
SuccessOrExit(error = aArgs[index].ParseAsHexString(dataset.mMasterKey.m8));
dataset.mComponents.mIsNetworkKeyPresent = true;
SuccessOrExit(error = aArgs[index].ParseAsHexString(dataset.mNetworkKey.m8));
}
else if (aArgs[index] == "networkname")
{
@@ -633,9 +633,9 @@ otError Dataset::ProcessMgmtGetCommand(uint8_t aArgsLength, Arg aArgs[])
{
datasetComponents.mIsPendingTimestampPresent = true;
}
else if (aArgs[index] == "masterkey")
else if (aArgs[index] == "networkkey")
{
datasetComponents.mIsMasterKeyPresent = true;
datasetComponents.mIsNetworkKeyPresent = true;
}
else if (aArgs[index] == "networkname")
{
@@ -750,7 +750,7 @@ void Dataset::OutputSecurityPolicy(const otSecurityPolicy &aSecurityPolicy)
{
mInterpreter.OutputFormat("%d ", aSecurityPolicy.mRotationTime);
if (aSecurityPolicy.mObtainMasterKeyEnabled)
if (aSecurityPolicy.mObtainNetworkKeyEnabled)
{
mInterpreter.OutputFormat("o");
}
@@ -785,7 +785,7 @@ void Dataset::OutputSecurityPolicy(const otSecurityPolicy &aSecurityPolicy)
mInterpreter.OutputFormat("e");
}
if (aSecurityPolicy.mMasterKeyProvisioningEnabled)
if (aSecurityPolicy.mNetworkKeyProvisioningEnabled)
{
mInterpreter.OutputFormat("p");
}
@@ -811,7 +811,7 @@ otError Dataset::ParseSecurityPolicy(otSecurityPolicy &aSecurityPolicy, uint8_t
switch (*flag)
{
case 'o':
policy.mObtainMasterKeyEnabled = true;
policy.mObtainNetworkKeyEnabled = true;
break;
case 'n':
@@ -839,7 +839,7 @@ otError Dataset::ParseSecurityPolicy(otSecurityPolicy &aSecurityPolicy, uint8_t
break;
case 'p':
policy.mMasterKeyProvisioningEnabled = true;
policy.mNetworkKeyProvisioningEnabled = true;
break;
case 'R':
+2 -2
View File
@@ -90,8 +90,8 @@ private:
otError ProcessDelay(uint8_t aArgsLength, Arg aArgs[]);
otError ProcessExtPanId(uint8_t aArgsLength, Arg aArgs[]);
otError ProcessInit(uint8_t aArgsLength, Arg aArgs[]);
otError ProcessMasterKey(uint8_t aArgsLength, Arg aArgs[]);
otError ProcessMeshLocalPrefix(uint8_t aArgsLength, Arg aArgs[]);
otError ProcessNetworkKey(uint8_t aArgsLength, Arg aArgs[]);
otError ProcessNetworkName(uint8_t aArgsLength, Arg aArgs[]);
otError ProcessPanId(uint8_t aArgsLength, Arg aArgs[]);
otError ProcessPending(uint8_t aArgsLength, Arg aArgs[]);
@@ -122,10 +122,10 @@ private:
{"extpanid", &Dataset::ProcessExtPanId},
{"help", &Dataset::ProcessHelp},
{"init", &Dataset::ProcessInit},
{"masterkey", &Dataset::ProcessMasterKey},
{"meshlocalprefix", &Dataset::ProcessMeshLocalPrefix},
{"mgmtgetcommand", &Dataset::ProcessMgmtGetCommand},
{"mgmtsetcommand", &Dataset::ProcessMgmtSetCommand},
{"networkkey", &Dataset::ProcessNetworkKey},
{"networkname", &Dataset::ProcessNetworkName},
{"panid", &Dataset::ProcessPanId},
{"pending", &Dataset::ProcessPending},
+4 -4
View File
@@ -112,14 +112,14 @@ otError otThreadSetLinkMode(otInstance *aInstance, otLinkModeConfig aConfig)
return instance.Get<Mle::MleRouter>().SetDeviceMode(Mle::DeviceMode(aConfig));
}
const otMasterKey *otThreadGetMasterKey(otInstance *aInstance)
const otNetworkKey *otThreadGetNetworkKey(otInstance *aInstance)
{
Instance &instance = *static_cast<Instance *>(aInstance);
return &instance.Get<KeyManager>().GetMasterKey();
return &instance.Get<KeyManager>().GetNetworkKey();
}
otError otThreadSetMasterKey(otInstance *aInstance, const otMasterKey *aKey)
otError otThreadSetNetworkKey(otInstance *aInstance, const otNetworkKey *aKey)
{
Error error = kErrorNone;
Instance &instance = *static_cast<Instance *>(aInstance);
@@ -128,7 +128,7 @@ otError otThreadSetMasterKey(otInstance *aInstance, const otMasterKey *aKey)
VerifyOrExit(instance.Get<Mle::MleRouter>().IsDisabled(), error = kErrorInvalidState);
error = instance.Get<KeyManager>().SetMasterKey(*static_cast<const MasterKey *>(aKey));
error = instance.Get<KeyManager>().SetNetworkKey(*static_cast<const NetworkKey *>(aKey));
instance.Get<MeshCoP::ActiveDataset>().Clear();
instance.Get<MeshCoP::PendingDataset>().Clear();
+1 -1
View File
@@ -266,7 +266,7 @@ const char *Notifier::EventToString(Event aEvent) const
"PanId", // kEventThreadPanIdChanged (1 << 15)
"NetName", // kEventThreadNetworkNameChanged (1 << 16)
"ExtPanId", // kEventThreadExtPanIdChanged (1 << 17)
"MstrKey", // kEventMasterKeyChanged (1 << 18)
"NetworkKey", // kEventNetworkKeyChanged (1 << 18)
"PSKc", // kEventPskcChanged (1 << 19)
"SecPolicy", // kEventSecurityPolicyChanged (1 << 20)
"CMNewChan", // kEventChannelManagerNewChannelChanged (1 << 21)
+1 -1
View File
@@ -83,7 +83,7 @@ enum Event : uint32_t
kEventThreadPanIdChanged = OT_CHANGED_THREAD_PANID, ///< Network PAN ID changed
kEventThreadNetworkNameChanged = OT_CHANGED_THREAD_NETWORK_NAME, ///< Network name changed
kEventThreadExtPanIdChanged = OT_CHANGED_THREAD_EXT_PANID, ///< Extended PAN ID changed
kEventMasterKeyChanged = OT_CHANGED_MASTER_KEY, ///< Master Key changed
kEventNetworkKeyChanged = OT_CHANGED_NETWORK_KEY, ///< Network Key changed
kEventPskcChanged = OT_CHANGED_PSKC, ///< PSKc changed
kEventSecurityPolicyChanged = OT_CHANGED_SECURITY_POLICY, ///< Security Policy changed
kEventChannelManagerNewChannelChanged = OT_CHANGED_CHANNEL_MANAGER_NEW_CHANNEL, ///< New Channel (channel-manager)
+16 -16
View File
@@ -73,7 +73,7 @@ Error Dataset::Info::GenerateRandom(Instance &aInstance)
mPanId = Mac::GenerateRandomPanId();
static_cast<SecurityPolicy &>(mSecurityPolicy).SetToDefault();
SuccessOrExit(error = static_cast<MasterKey &>(mMasterKey).GenerateRandom());
SuccessOrExit(error = static_cast<NetworkKey &>(mNetworkKey).GenerateRandom());
SuccessOrExit(error = static_cast<Pskc &>(mPskc).GenerateRandom());
SuccessOrExit(error = Random::Crypto::FillBuffer(mExtendedPanId.m8, sizeof(mExtendedPanId.m8)));
SuccessOrExit(error = static_cast<Ip6::NetworkPrefix &>(mMeshLocalPrefix).GenerateRandomUla());
@@ -81,7 +81,7 @@ Error Dataset::Info::GenerateRandom(Instance &aInstance)
snprintf(mNetworkName.m8, sizeof(mNetworkName), "OpenThread-%04x", mPanId);
mComponents.mIsActiveTimestampPresent = true;
mComponents.mIsMasterKeyPresent = true;
mComponents.mIsNetworkKeyPresent = true;
mComponents.mIsNetworkNamePresent = true;
mComponents.mIsExtendedPanIdPresent = true;
mComponents.mIsMeshLocalPrefixPresent = true;
@@ -99,9 +99,9 @@ bool Dataset::Info::IsSubsetOf(const Info &aOther) const
{
bool isSubset = false;
if (IsMasterKeyPresent())
if (IsNetworkKeyPresent())
{
VerifyOrExit(aOther.IsMasterKeyPresent() && GetMasterKey() == aOther.GetMasterKey());
VerifyOrExit(aOther.IsNetworkKeyPresent() && GetNetworkKey() == aOther.GetNetworkKey());
}
if (IsNetworkNamePresent())
@@ -223,8 +223,8 @@ void Dataset::ConvertTo(Info &aDatasetInfo) const
aDatasetInfo.SetMeshLocalPrefix(static_cast<const MeshLocalPrefixTlv *>(cur)->GetMeshLocalPrefix());
break;
case Tlv::kNetworkMasterKey:
aDatasetInfo.SetMasterKey(static_cast<const NetworkMasterKeyTlv *>(cur)->GetNetworkMasterKey());
case Tlv::kNetworkKey:
aDatasetInfo.SetNetworkKey(static_cast<const NetworkKeyTlv *>(cur)->GetNetworkKey());
break;
case Tlv::kNetworkName:
@@ -336,9 +336,9 @@ Error Dataset::SetFrom(const Info &aDatasetInfo)
IgnoreError(SetTlv(Tlv::kMeshLocalPrefix, aDatasetInfo.GetMeshLocalPrefix()));
}
if (aDatasetInfo.IsMasterKeyPresent())
if (aDatasetInfo.IsNetworkKeyPresent())
{
IgnoreError(SetTlv(Tlv::kNetworkMasterKey, aDatasetInfo.GetMasterKey()));
IgnoreError(SetTlv(Tlv::kNetworkKey, aDatasetInfo.GetNetworkKey()));
}
if (aDatasetInfo.IsNetworkNamePresent())
@@ -517,7 +517,7 @@ void Dataset::RemoveTlv(Tlv *aTlv)
mLength -= length;
}
Error Dataset::ApplyConfiguration(Instance &aInstance, bool *aIsMasterKeyUpdated) const
Error Dataset::ApplyConfiguration(Instance &aInstance, bool *aIsNetworkKeyUpdated) const
{
Mac::Mac & mac = aInstance.Get<Mac::Mac>();
KeyManager &keyManager = aInstance.Get<KeyManager>();
@@ -525,9 +525,9 @@ Error Dataset::ApplyConfiguration(Instance &aInstance, bool *aIsMasterKeyUpdated
VerifyOrExit(IsValid(), error = kErrorParse);
if (aIsMasterKeyUpdated)
if (aIsNetworkKeyUpdated)
{
*aIsMasterKeyUpdated = false;
*aIsNetworkKeyUpdated = false;
}
for (const Tlv *cur = GetTlvsStart(); cur < GetTlvsEnd(); cur = cur->GetNext())
@@ -562,16 +562,16 @@ Error Dataset::ApplyConfiguration(Instance &aInstance, bool *aIsMasterKeyUpdated
IgnoreError(mac.SetNetworkName(static_cast<const NetworkNameTlv *>(cur)->GetNetworkName()));
break;
case Tlv::kNetworkMasterKey:
case Tlv::kNetworkKey:
{
const NetworkMasterKeyTlv *key = static_cast<const NetworkMasterKeyTlv *>(cur);
const NetworkKeyTlv *key = static_cast<const NetworkKeyTlv *>(cur);
if (aIsMasterKeyUpdated && (key->GetNetworkMasterKey() != keyManager.GetMasterKey()))
if (aIsNetworkKeyUpdated && (key->GetNetworkKey() != keyManager.GetNetworkKey()))
{
*aIsMasterKeyUpdated = true;
*aIsNetworkKeyUpdated = true;
}
IgnoreError(keyManager.SetMasterKey(key->GetNetworkMasterKey()));
IgnoreError(keyManager.SetNetworkKey(key->GetNetworkKey()));
break;
}
+24 -24
View File
@@ -100,12 +100,12 @@ public:
bool IsPendingTimestampPresent(void) const { return mIsPendingTimestampPresent; }
/**
* This method indicates whether or not the Network Master Key is present in the Dataset.
* This method indicates whether or not the Network Key is present in the Dataset.
*
* @returns TRUE if Network Master Key is present, FALSE otherwise.
* @returns TRUE if Network Key is present, FALSE otherwise.
*
*/
bool IsMasterKeyPresent(void) const { return mIsMasterKeyPresent; }
bool IsNetworkKeyPresent(void) const { return mIsNetworkKeyPresent; }
/**
* This method indicates whether or not the Network Name is present in the Dataset.
@@ -250,46 +250,46 @@ public:
}
/**
* This method indicates whether or not the Network Master Key is present in the Dataset.
* This method indicates whether or not the Network Key is present in the Dataset.
*
* @returns TRUE if Network Master Key is present, FALSE otherwise.
* @returns TRUE if Network Key is present, FALSE otherwise.
*
*/
bool IsMasterKeyPresent(void) const { return mComponents.mIsMasterKeyPresent; }
bool IsNetworkKeyPresent(void) const { return mComponents.mIsNetworkKeyPresent; }
/**
* This method gets the Network Master Key in the Dataset.
* This method gets the Network Key in the Dataset.
*
* This method MUST be used when Network Master Key component is present in the Dataset, otherwise its behavior
* This method MUST be used when Network Key component is present in the Dataset, otherwise its behavior
* is undefined.
*
* @returns The Network Master Key in the Dataset.
* @returns The Network Key in the Dataset.
*
*/
const MasterKey &GetMasterKey(void) const { return static_cast<const MasterKey &>(mMasterKey); }
const NetworkKey &GetNetworkKey(void) const { return static_cast<const NetworkKey &>(mNetworkKey); }
/**
* This method sets the Network Master Key in the Dataset.
* This method sets the Network Key in the Dataset.
*
* @param[in] aMasterKey A Master Key.
* @param[in] aNetworkKey A Network Key.
*
*/
void SetMasterKey(const MasterKey &aMasterKey)
void SetNetworkKey(const NetworkKey &aNetworkKey)
{
mMasterKey = aMasterKey;
mComponents.mIsMasterKeyPresent = true;
mNetworkKey = aNetworkKey;
mComponents.mIsNetworkKeyPresent = true;
}
/**
* This method returns a reference to the Network Master Key in the Dataset to be updated by caller.
* This method returns a reference to the Network Key in the Dataset to be updated by caller.
*
* @returns A reference to the Network Master Key in the Dataset.
* @returns A reference to the Network Key in the Dataset.
*
*/
MasterKey &UpdateMasterKey(void)
NetworkKey &UpdateNetworkKey(void)
{
mComponents.mIsMasterKeyPresent = true;
return static_cast<MasterKey &>(mMasterKey);
mComponents.mIsNetworkKeyPresent = true;
return static_cast<NetworkKey &>(mNetworkKey);
}
/**
@@ -585,7 +585,7 @@ public:
/**
* This method populates the Dataset with random fields.
*
* The Master Key, PSKc, Mesh Local Prefix, PAN ID, and Extended PAN ID are generated randomly (crypto-secure)
* The Network Key, PSKc, Mesh Local Prefix, PAN ID, and Extended PAN ID are generated randomly (crypto-secure)
* with Network Name set to "OpenThread-%04x" with PAN ID appended as hex. The Channel is chosen randomly from
* radio's preferred channel mask, Channel Mask is set from radio's supported mask, and Security Policy Flags
* from current `KeyManager` value.
@@ -856,14 +856,14 @@ public:
/**
* This method applies the Active or Pending Dataset to the Thread interface.
*
* @param[in] aInstance A reference to the OpenThread instance.
* @param[out] aIsMasterKeyUpdated A pointer to where to place whether master key was updated.
* @param[in] aInstance A reference to the OpenThread instance.
* @param[out] aIsNetworkKeyUpdated A pointer to where to place whether network key was updated.
*
* @retval kErrorNone Successfully applied configuration.
* @retval kErrorParse The dataset has at least one TLV with invalid format.
*
*/
Error ApplyConfiguration(Instance &aInstance, bool *aIsMasterKeyUpdated = nullptr) const;
Error ApplyConfiguration(Instance &aInstance, bool *aIsNetworkKeyUpdated = nullptr) const;
/**
* This method converts a Pending Dataset to an Active Dataset.
+8 -10
View File
@@ -140,7 +140,7 @@ Error DatasetManager::Save(const Dataset &aDataset)
Error error = kErrorNone;
const Timestamp *timestamp;
int compare;
bool isMasterkeyUpdated = false;
bool isNetworkkeyUpdated = false;
timestamp = aDataset.GetTimestamp();
@@ -151,13 +151,13 @@ Error DatasetManager::Save(const Dataset &aDataset)
if (IsActiveDataset())
{
SuccessOrExit(error = aDataset.ApplyConfiguration(GetInstance(), &isMasterkeyUpdated));
SuccessOrExit(error = aDataset.ApplyConfiguration(GetInstance(), &isNetworkkeyUpdated));
}
}
compare = mLocal.Compare(timestamp);
if (isMasterkeyUpdated || compare > 0)
if (isNetworkkeyUpdated || compare > 0)
{
IgnoreError(mLocal.Save(aDataset));
@@ -416,8 +416,7 @@ void DatasetManager::SendGetResponse(const Coap::Message & aRequest,
{
for (const Tlv *cur = dataset.GetTlvsStart(); cur < dataset.GetTlvsEnd(); cur = cur->GetNext())
{
if (cur->GetType() != Tlv::kNetworkMasterKey ||
Get<KeyManager>().GetSecurityPolicy().mObtainMasterKeyEnabled)
if (cur->GetType() != Tlv::kNetworkKey || Get<KeyManager>().GetSecurityPolicy().mObtainNetworkKeyEnabled)
{
SuccessOrExit(error = cur->AppendTo(*message));
}
@@ -429,8 +428,7 @@ void DatasetManager::SendGetResponse(const Coap::Message & aRequest,
{
const Tlv *tlv;
if (aTlvs[index] == Tlv::kNetworkMasterKey &&
!Get<KeyManager>().GetSecurityPolicy().mObtainMasterKeyEnabled)
if (aTlvs[index] == Tlv::kNetworkKey && !Get<KeyManager>().GetSecurityPolicy().mObtainNetworkKeyEnabled)
{
continue;
}
@@ -544,9 +542,9 @@ Error DatasetManager::SendGetRequest(const Dataset::Components &aDatasetComponen
datasetTlvs[length++] = Tlv::kPendingTimestamp;
}
if (aDatasetComponents.IsMasterKeyPresent())
if (aDatasetComponents.IsNetworkKeyPresent())
{
datasetTlvs[length++] = Tlv::kNetworkMasterKey;
datasetTlvs[length++] = Tlv::kNetworkKey;
}
if (aDatasetComponents.IsNetworkNamePresent())
@@ -663,7 +661,7 @@ bool ActiveDataset::IsCommissioned(void) const
SuccessOrExit(Read(datasetInfo));
isValid = (datasetInfo.IsMasterKeyPresent() && datasetInfo.IsNetworkNamePresent() &&
isValid = (datasetInfo.IsNetworkKeyPresent() && datasetInfo.IsNetworkNamePresent() &&
datasetInfo.IsExtendedPanIdPresent() && datasetInfo.IsPanIdPresent() && datasetInfo.IsChannelPresent());
exit:
+13 -13
View File
@@ -76,8 +76,8 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo
Tlv::Type type;
bool isUpdateFromCommissioner = false;
bool doesAffectConnectivity = false;
bool doesAffectMasterKey = false;
bool hasMasterKey = false;
bool doesAffectNetworkKey = false;
bool hasNetworkKey = false;
StateTlv::State state = StateTlv::kReject;
Dataset dataset(GetType());
@@ -86,7 +86,7 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo
ChannelTlv channel;
uint16_t sessionId;
Mle::MeshLocalPrefix meshLocalPrefix;
MasterKey masterKey;
NetworkKey networkKey;
uint16_t panId;
activeTimestamp.SetLength(0);
@@ -151,22 +151,22 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo
doesAffectConnectivity = true;
}
// check network master key
if (Tlv::Find<NetworkMasterKeyTlv>(aMessage, masterKey) == kErrorNone)
// check network key
if (Tlv::Find<NetworkKeyTlv>(aMessage, networkKey) == kErrorNone)
{
hasMasterKey = true;
hasNetworkKey = true;
if (masterKey != Get<KeyManager>().GetMasterKey())
if (networkKey != Get<KeyManager>().GetNetworkKey())
{
doesAffectConnectivity = true;
doesAffectMasterKey = true;
doesAffectNetworkKey = true;
}
}
// check active timestamp rollback
if (type == Tlv::kPendingTimestamp && (!hasMasterKey || (masterKey == Get<KeyManager>().GetMasterKey())))
if (type == Tlv::kPendingTimestamp && (!hasNetworkKey || (networkKey == Get<KeyManager>().GetNetworkKey())))
{
// no change to master key, active timestamp must be ahead
// no change to network key, active timestamp must be ahead
const Timestamp *localActiveTimestamp = Get<ActiveDataset>().GetTimestamp();
VerifyOrExit(localActiveTimestamp == nullptr || localActiveTimestamp->Compare(activeTimestamp) > 0);
@@ -215,7 +215,7 @@ Error DatasetManager::HandleSet(Coap::Message &aMessage, const Ip6::MessageInfo
{
DelayTimerTlv &delayTimerTlv = static_cast<DelayTimerTlv &>(static_cast<Tlv &>(datasetTlv));
if (doesAffectMasterKey && delayTimerTlv.GetDelayTimer() < DelayTimerTlv::kDelayTimerDefault)
if (doesAffectNetworkKey && delayTimerTlv.GetDelayTimer() < DelayTimerTlv::kDelayTimerDefault)
{
delayTimerTlv.SetDelayTimer(DelayTimerTlv::kDelayTimerDefault);
}
@@ -351,9 +351,9 @@ Error ActiveDataset::GenerateLocal(void)
IgnoreError(dataset.SetTlv(Tlv::kMeshLocalPrefix, Get<Mle::MleRouter>().GetMeshLocalPrefix()));
}
if (dataset.GetTlv<NetworkMasterKeyTlv>() == nullptr)
if (dataset.GetTlv<NetworkKeyTlv>() == nullptr)
{
IgnoreError(dataset.SetTlv(Tlv::kNetworkMasterKey, Get<KeyManager>().GetMasterKey()));
IgnoreError(dataset.SetTlv(Tlv::kNetworkKey, Get<KeyManager>().GetNetworkKey()));
}
if (dataset.GetTlv<NetworkNameTlv>() == nullptr)
+1 -1
View File
@@ -573,7 +573,7 @@ void Joiner::HandleJoinerEntrust(Coap::Message &aMessage, const Ip6::MessageInfo
datasetInfo.Clear();
SuccessOrExit(error = Tlv::Find<NetworkMasterKeyTlv>(aMessage, datasetInfo.UpdateMasterKey()));
SuccessOrExit(error = Tlv::Find<NetworkKeyTlv>(aMessage, datasetInfo.UpdateNetworkKey()));
datasetInfo.SetChannel(Get<Mac::Mac>().GetPanChannel());
datasetInfo.SetPanId(Get<Mac::Mac>().GetPanId());
+1 -1
View File
@@ -326,7 +326,7 @@ Coap::Message *JoinerRouter::PrepareJoinerEntrustMessage(void)
SuccessOrExit(error = message->SetPayloadMarker());
message->SetSubType(Message::kSubTypeJoinerEntrust);
SuccessOrExit(error = Tlv::Append<NetworkMasterKeyTlv>(*message, Get<KeyManager>().GetMasterKey()));
SuccessOrExit(error = Tlv::Append<NetworkKeyTlv>(*message, Get<KeyManager>().GetNetworkKey()));
SuccessOrExit(error = Tlv::Append<MeshLocalPrefixTlv>(*message, Get<Mle::MleRouter>().GetMeshLocalPrefix()));
SuccessOrExit(error = Tlv::Append<ExtendedPanIdTlv>(*message, Get<Mac::Mac>().GetExtendedPanId()));
+2 -2
View File
@@ -62,8 +62,8 @@ bool Tlv::IsValid(const Tlv &aTlv)
rval = static_cast<const NetworkNameTlv &>(aTlv).IsValid();
break;
case Tlv::kNetworkMasterKey:
rval = static_cast<const NetworkMasterKeyTlv &>(aTlv).IsValid();
case Tlv::kNetworkKey:
rval = static_cast<const NetworkKeyTlv &>(aTlv).IsValid();
break;
case Tlv::kPskc:
+11 -11
View File
@@ -79,7 +79,7 @@ public:
kExtendedPanId = OT_MESHCOP_TLV_EXTPANID, ///< Extended PAN ID TLV
kNetworkName = OT_MESHCOP_TLV_NETWORKNAME, ///< Network Name TLV
kPskc = OT_MESHCOP_TLV_PSKC, ///< PSKc TLV
kNetworkMasterKey = OT_MESHCOP_TLV_MASTERKEY, ///< Network Master Key TLV
kNetworkKey = OT_MESHCOP_TLV_NETWORKKEY, ///< Network Network Key TLV
kNetworkKeySequence = OT_MESHCOP_TLV_NETWORK_KEY_SEQUENCE, ///< Network Key Sequence TLV
kMeshLocalPrefix = OT_MESHCOP_TLV_MESHLOCALPREFIX, ///< Mesh Local Prefix TLV
kSteeringData = OT_MESHCOP_TLV_STEERING_DATA, ///< Steering Data TLV
@@ -581,11 +581,11 @@ private:
} OT_TOOL_PACKED_END;
/**
* This class implements Network Master Key TLV generation and parsing.
* This class implements Network Network Key TLV generation and parsing.
*
*/
OT_TOOL_PACKED_BEGIN
class NetworkMasterKeyTlv : public Tlv, public SimpleTlvInfo<Tlv::kNetworkMasterKey, MasterKey>
class NetworkKeyTlv : public Tlv, public SimpleTlvInfo<Tlv::kNetworkKey, NetworkKey>
{
public:
/**
@@ -594,7 +594,7 @@ public:
*/
void Init(void)
{
SetType(kNetworkMasterKey);
SetType(kNetworkKey);
SetLength(sizeof(*this) - sizeof(Tlv));
}
@@ -608,23 +608,23 @@ public:
bool IsValid(void) const { return GetLength() >= sizeof(*this) - sizeof(Tlv); }
/**
* This method returns the Network Master Key value.
* This method returns the Network Network Key value.
*
* @returns The Network Master Key value.
* @returns The Network Network Key value.
*
*/
const MasterKey &GetNetworkMasterKey(void) const { return mNetworkMasterKey; }
const NetworkKey &GetNetworkKey(void) const { return mNetworkKey; }
/**
* This method sets the Network Master Key value.
* This method sets the Network Network Key value.
*
* @param[in] aMasterKey The Network Master Key.
* @param[in] aNetworkKey The Network Network Key.
*
*/
void SetNetworkMasterKey(const MasterKey &aMasterKey) { mNetworkMasterKey = aMasterKey; }
void SetNetworkKey(const NetworkKey &aNetworkKey) { mNetworkKey = aNetworkKey; }
private:
MasterKey mNetworkMasterKey;
NetworkKey mNetworkKey;
} OT_TOOL_PACKED_END;
/**
+13 -13
View File
@@ -64,14 +64,14 @@ void SecurityPolicy::SetToDefault(void)
void SecurityPolicy::SetToDefaultFlags(void)
{
mObtainMasterKeyEnabled = true;
mObtainNetworkKeyEnabled = true;
mNativeCommissioningEnabled = true;
mRoutersEnabled = true;
mExternalCommissioningEnabled = true;
mBeaconsEnabled = true;
mCommercialCommissioningEnabled = false;
mAutonomousEnrollmentEnabled = false;
mMasterKeyProvisioningEnabled = false;
mNetworkKeyProvisioningEnabled = false;
mTobleLinkEnabled = true;
mNonCcmRoutersEnabled = false;
mVersionThresholdForRouting = 0;
@@ -83,14 +83,14 @@ void SecurityPolicy::SetFlags(const uint8_t *aFlags, uint8_t aFlagsLength)
SetToDefaultFlags();
mObtainMasterKeyEnabled = aFlags[0] & kObtainMasterKeyMask;
mObtainNetworkKeyEnabled = aFlags[0] & kObtainNetworkKeyMask;
mNativeCommissioningEnabled = aFlags[0] & kNativeCommissioningMask;
mRoutersEnabled = aFlags[0] & kRoutersMask;
mExternalCommissioningEnabled = aFlags[0] & kExternalCommissioningMask;
mBeaconsEnabled = aFlags[0] & kBeaconsMask;
mCommercialCommissioningEnabled = (aFlags[0] & kCommercialCommissioningMask) == 0;
mAutonomousEnrollmentEnabled = (aFlags[0] & kAutonomousEnrollmentMask) == 0;
mMasterKeyProvisioningEnabled = (aFlags[0] & kMasterKeyProvisioningMask) == 0;
mNetworkKeyProvisioningEnabled = (aFlags[0] & kNetworkKeyProvisioningMask) == 0;
VerifyOrExit(aFlagsLength > sizeof(aFlags[0]));
mTobleLinkEnabled = aFlags[1] & kTobleLinkMask;
@@ -107,9 +107,9 @@ void SecurityPolicy::GetFlags(uint8_t *aFlags, uint8_t aFlagsLength) const
memset(aFlags, 0, aFlagsLength);
if (mObtainMasterKeyEnabled)
if (mObtainNetworkKeyEnabled)
{
aFlags[0] |= kObtainMasterKeyMask;
aFlags[0] |= kObtainNetworkKeyMask;
}
if (mNativeCommissioningEnabled)
@@ -142,9 +142,9 @@ void SecurityPolicy::GetFlags(uint8_t *aFlags, uint8_t aFlagsLength) const
aFlags[0] |= kAutonomousEnrollmentMask;
}
if (!mMasterKeyProvisioningEnabled)
if (!mNetworkKeyProvisioningEnabled)
{
aFlags[0] |= kMasterKeyProvisioningMask;
aFlags[0] |= kNetworkKeyProvisioningMask;
}
VerifyOrExit(aFlagsLength > sizeof(aFlags[0]));
@@ -179,7 +179,7 @@ KeyManager::KeyManager(Instance &aInstance)
, mKekFrameCounter(0)
, mIsPskcSet(false)
{
Error error = mMasterKey.GenerateRandom();
Error error = mNetworkKey.GenerateRandom();
OT_ASSERT(error == kErrorNone);
OT_UNUSED_VARIABLE(error);
@@ -207,12 +207,12 @@ void KeyManager::SetPskc(const Pskc &aPskc)
}
#endif // OPENTHREAD_MTD || OPENTHREAD_FTD
Error KeyManager::SetMasterKey(const MasterKey &aKey)
Error KeyManager::SetNetworkKey(const NetworkKey &aKey)
{
Error error = kErrorNone;
Router *parent;
SuccessOrExit(Get<Notifier>().Update(mMasterKey, aKey, kEventMasterKeyChanged));
SuccessOrExit(Get<Notifier>().Update(mNetworkKey, aKey, kEventNetworkKeyChanged));
Get<Notifier>().Signal(kEventThreadKeySeqCounterChanged);
mKeySequence = 0;
UpdateKeyMaterial();
@@ -253,7 +253,7 @@ void KeyManager::ComputeKeys(uint32_t aKeySequence, HashKeys &aHashKeys)
Crypto::HmacSha256 hmac;
uint8_t keySequenceBytes[sizeof(uint32_t)];
hmac.Start(mMasterKey.m8, sizeof(mMasterKey.m8));
hmac.Start(mNetworkKey.m8, sizeof(mNetworkKey.m8));
Encoding::BigEndian::WriteUint32(aKeySequence, keySequenceBytes);
hmac.Update(keySequenceBytes);
@@ -271,7 +271,7 @@ void KeyManager::ComputeTrelKey(uint32_t aKeySequence, Mac::Key &aTrelKey)
Encoding::BigEndian::WriteUint32(aKeySequence, salt);
memcpy(salt + sizeof(uint32_t), kHkdfExtractSaltString, sizeof(kHkdfExtractSaltString));
hkdf.Extract(salt, sizeof(salt), mMasterKey.m8, sizeof(MasterKey));
hkdf.Extract(salt, sizeof(salt), mNetworkKey.m8, sizeof(NetworkKey));
hkdf.Expand(kTrelInfoString, sizeof(kTrelInfoString), aTrelKey.m8, sizeof(Mac::Key));
}
#endif
+14 -14
View File
@@ -111,14 +111,14 @@ private:
enum : uint8_t
{
kDefaultFlags = 0xff,
kObtainMasterKeyMask = 1 << 7,
kObtainNetworkKeyMask = 1 << 7,
kNativeCommissioningMask = 1 << 6,
kRoutersMask = 1 << 5,
kExternalCommissioningMask = 1 << 4,
kBeaconsMask = 1 << 3,
kCommercialCommissioningMask = 1 << 2,
kAutonomousEnrollmentMask = 1 << 1,
kMasterKeyProvisioningMask = 1 << 0,
kNetworkKeyProvisioningMask = 1 << 0,
kTobleLinkMask = 1 << 7,
kNonCcmRoutersMask = 1 << 6,
kReservedMask = 0x38,
@@ -129,18 +129,18 @@ private:
};
/**
* This class represents a Thread Master Key.
* This class represents a Thread Network Key.
*
*/
OT_TOOL_PACKED_BEGIN
class MasterKey : public otMasterKey, public Equatable<MasterKey>
class NetworkKey : public otNetworkKey, public Equatable<NetworkKey>
{
public:
#if !OPENTHREAD_RADIO
/**
* This method generates a cryptographically secure random sequence to populate the Thread Master Key.
* This method generates a cryptographically secure random sequence to populate the Thread Network Key.
*
* @retval kErrorNone Successfully generated a random Thread Master Key.
* @retval kErrorNone Successfully generated a random Thread Network Key.
* @retval kErrorFailed Failed to generate random sequence.
*
*/
@@ -203,23 +203,23 @@ public:
void Stop(void);
/**
* This method returns the Thread Master Key.
* This method returns the Thread Network Key.
*
* @returns The Thread Master Key.
* @returns The Thread Network Key.
*
*/
const MasterKey &GetMasterKey(void) const { return mMasterKey; }
const NetworkKey &GetNetworkKey(void) const { return mNetworkKey; }
/**
* This method sets the Thread Master Key.
* This method sets the Thread Network Key.
*
* @param[in] aKey A Thread Master Key.
* @param[in] aKey A Thread Network Key.
*
* @retval kErrorNone Successfully set the Thread Master Key.
* @retval kErrorNone Successfully set the Thread Network Key.
* @retval kErrorInvalidArgs The @p aKeyLength value was invalid.
*
*/
Error SetMasterKey(const MasterKey &aKey);
Error SetNetworkKey(const NetworkKey &aKey);
#if OPENTHREAD_FTD || OPENTHREAD_MTD
/**
@@ -515,7 +515,7 @@ private:
static const uint8_t kTrelInfoString[];
#endif
MasterKey mMasterKey;
NetworkKey mNetworkKey;
uint32_t mKeySequence;
Mle::Key mMleKey;
+4 -4
View File
@@ -615,15 +615,15 @@ otError RadioSpinel<InterfaceType, ProcessContextType>::ThreadDatasetHandler(con
switch (static_cast<spinel_prop_key_t>(propKey))
{
case SPINEL_PROP_NET_MASTER_KEY:
case SPINEL_PROP_NET_NETWORK_KEY:
{
const uint8_t *key;
uint16_t len;
SuccessOrExit(error = decoder.ReadData(key, len));
VerifyOrExit(len == OT_MASTER_KEY_SIZE, error = OT_ERROR_INVALID_ARGS);
memcpy(opDataset.mMasterKey.m8, key, len);
opDataset.mComponents.mIsMasterKeyPresent = true;
VerifyOrExit(len == OT_NETWORK_KEY_SIZE, error = OT_ERROR_INVALID_ARGS);
memcpy(opDataset.mNetworkKey.m8, key, len);
opDataset.mComponents.mIsNetworkKeyPresent = true;
break;
}
+1 -1
View File
@@ -1278,7 +1278,7 @@ const char *spinel_prop_key_to_cstr(spinel_prop_key_t prop_key)
{SPINEL_PROP_NET_ROLE, "NET_ROLE"},
{SPINEL_PROP_NET_NETWORK_NAME, "NET_NETWORK_NAME"},
{SPINEL_PROP_NET_XPANID, "NET_XPANID"},
{SPINEL_PROP_NET_MASTER_KEY, "NET_MASTER_KEY"},
{SPINEL_PROP_NET_NETWORK_KEY, "NET_NETWORK_KEY"},
{SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER, "NET_KEY_SEQUENCE_COUNTER"},
{SPINEL_PROP_NET_PARTITION_ID, "NET_PARTITION_ID"},
{SPINEL_PROP_NET_REQUIRE_JOIN_EXISTING, "NET_REQUIRE_JOIN_EXISTING"},
+6 -6
View File
@@ -2217,11 +2217,11 @@ enum
*/
SPINEL_PROP_NET_XPANID = SPINEL_PROP_NET__BEGIN + 5,
/// Thread Network Master Key
/// Thread Network Key
/** Format `D` - Read-write
*
*/
SPINEL_PROP_NET_MASTER_KEY = SPINEL_PROP_NET__BEGIN + 6,
SPINEL_PROP_NET_NETWORK_KEY = SPINEL_PROP_NET__BEGIN + 6,
/// Thread Network Key Sequence Counter
/** Format `L` - Read-write
@@ -2675,7 +2675,7 @@ enum
* Operational Dataset that it has stored locally and the one currently in use by the partition to which it is
* attached. This property corresponds to the locally stored Dataset on the device.
*
* Operational Dataset consists of a set of supported properties (e.g., channel, master key, network name, PAN id,
* Operational Dataset consists of a set of supported properties (e.g., channel, network key, network name, PAN id,
* etc). Note that not all supported properties may be present (have a value) in a Dataset.
*
* The Dataset value is encoded as an array of structs containing pairs of property key (as `i`) followed by the
@@ -2688,7 +2688,7 @@ enum
* SPINEL_PROP_DATASET_ACTIVE_TIMESTAMP
* SPINEL_PROP_PHY_CHAN
* SPINEL_PROP_PHY_CHAN_SUPPORTED (Channel Mask Page 0)
* SPINEL_PROP_NET_MASTER_KEY
* SPINEL_PROP_NET_NETWORK_KEY
* SPINEL_PROP_NET_NETWORK_NAME
* SPINEL_PROP_NET_XPANID
* SPINEL_PROP_MAC_15_4_PANID
@@ -2953,7 +2953,7 @@ enum
* This property allows host to request NCP to create and return a new Operation Dataset to use when forming a new
* network.
*
* Operational Dataset consists of a set of supported properties (e.g., channel, master key, network name, PAN id,
* Operational Dataset consists of a set of supported properties (e.g., channel, network key, network name, PAN id,
* etc). Note that not all supported properties may be present (have a value) in a Dataset.
*
* The Dataset value is encoded as an array of structs containing pairs of property key (as `i`) followed by the
@@ -2964,7 +2964,7 @@ enum
* SPINEL_PROP_DATASET_ACTIVE_TIMESTAMP
* SPINEL_PROP_PHY_CHAN
* SPINEL_PROP_PHY_CHAN_SUPPORTED (Channel Mask Page 0)
* SPINEL_PROP_NET_MASTER_KEY
* SPINEL_PROP_NET_NETWORK_KEY
* SPINEL_PROP_NET_NETWORK_NAME
* SPINEL_PROP_NET_XPANID
* SPINEL_PROP_MAC_15_4_PANID
+1 -1
View File
@@ -79,7 +79,7 @@ const ChangedPropsSet::Entry ChangedPropsSet::mSupportedProps[] = {
{SPINEL_PROP_MAC_15_4_PANID, SPINEL_STATUS_OK, true},
{SPINEL_PROP_NET_NETWORK_NAME, SPINEL_STATUS_OK, true},
{SPINEL_PROP_NET_XPANID, SPINEL_STATUS_OK, true},
{SPINEL_PROP_NET_MASTER_KEY, SPINEL_STATUS_OK, true},
{SPINEL_PROP_NET_NETWORK_KEY, SPINEL_STATUS_OK, true},
{SPINEL_PROP_NET_PSKC, SPINEL_STATUS_OK, true},
{SPINEL_PROP_PHY_CHAN_SUPPORTED, SPINEL_STATUS_OK, true},
#if OPENTHREAD_CONFIG_CHANNEL_MANAGER_ENABLE
+2 -2
View File
@@ -92,7 +92,7 @@ NcpBase::PropertyHandler NcpBase::FindGetPropertyHandler(spinel_prop_key_t aKey)
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NET_ROLE),
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NET_NETWORK_NAME),
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NET_XPANID),
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NET_MASTER_KEY),
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NET_NETWORK_KEY),
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER),
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NET_PARTITION_ID),
OT_NCP_GET_HANDLER_ENTRY(SPINEL_PROP_NET_REQUIRE_JOIN_EXISTING),
@@ -430,7 +430,7 @@ NcpBase::PropertyHandler NcpBase::FindSetPropertyHandler(spinel_prop_key_t aKey)
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_NET_ROLE),
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_NET_NETWORK_NAME),
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_NET_XPANID),
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_NET_MASTER_KEY),
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_NET_NETWORK_KEY),
OT_NCP_SET_HANDLER_ENTRY(SPINEL_PROP_NET_KEY_SEQUENCE_COUNTER),
#if OPENTHREAD_FTD
#if OPENTHREAD_CONFIG_REFERENCE_DEVICE_ENABLE
+13 -13
View File
@@ -660,12 +660,12 @@ exit:
return error;
}
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_NET_MASTER_KEY>(void)
template <> otError NcpBase::HandlePropertyGet<SPINEL_PROP_NET_NETWORK_KEY>(void)
{
return mEncoder.WriteData(otThreadGetMasterKey(mInstance)->m8, OT_MASTER_KEY_SIZE);
return mEncoder.WriteData(otThreadGetNetworkKey(mInstance)->m8, OT_NETWORK_KEY_SIZE);
}
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_NET_MASTER_KEY>(void)
template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_NET_NETWORK_KEY>(void)
{
const uint8_t *ptr = nullptr;
uint16_t len;
@@ -673,9 +673,9 @@ template <> otError NcpBase::HandlePropertySet<SPINEL_PROP_NET_MASTER_KEY>(void)
SuccessOrExit(error = mDecoder.ReadData(ptr, len));
VerifyOrExit(len == OT_MASTER_KEY_SIZE, error = OT_ERROR_PARSE);
VerifyOrExit(len == OT_NETWORK_KEY_SIZE, error = OT_ERROR_PARSE);
error = otThreadSetMasterKey(mInstance, reinterpret_cast<const otMasterKey *>(ptr));
error = otThreadSetNetworkKey(mInstance, reinterpret_cast<const otNetworkKey *>(ptr));
exit:
return error;
@@ -1267,11 +1267,11 @@ otError NcpBase::EncodeOperationalDataset(const otOperationalDataset &aDataset)
SuccessOrExit(error = mEncoder.CloseStruct());
}
if (aDataset.mComponents.mIsMasterKeyPresent)
if (aDataset.mComponents.mIsNetworkKeyPresent)
{
SuccessOrExit(error = mEncoder.OpenStruct());
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_PROP_NET_MASTER_KEY));
SuccessOrExit(error = mEncoder.WriteData(aDataset.mMasterKey.m8, OT_MASTER_KEY_SIZE));
SuccessOrExit(error = mEncoder.WriteUintPacked(SPINEL_PROP_NET_NETWORK_KEY));
SuccessOrExit(error = mEncoder.WriteData(aDataset.mNetworkKey.m8, OT_NETWORK_KEY_SIZE));
SuccessOrExit(error = mEncoder.CloseStruct());
}
@@ -1441,7 +1441,7 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
aDataset.mComponents.mIsPendingTimestampPresent = true;
break;
case SPINEL_PROP_NET_MASTER_KEY:
case SPINEL_PROP_NET_NETWORK_KEY:
if (!aAllowEmptyValues || !mDecoder.IsAllReadInStruct())
{
@@ -1449,11 +1449,11 @@ otError NcpBase::DecodeOperationalDataset(otOperationalDataset &aDataset,
uint16_t len;
SuccessOrExit(error = mDecoder.ReadData(key, len));
VerifyOrExit(len == OT_MASTER_KEY_SIZE, error = OT_ERROR_INVALID_ARGS);
memcpy(aDataset.mMasterKey.m8, key, len);
VerifyOrExit(len == OT_NETWORK_KEY_SIZE, error = OT_ERROR_INVALID_ARGS);
memcpy(aDataset.mNetworkKey.m8, key, len);
}
aDataset.mComponents.mIsMasterKeyPresent = true;
aDataset.mComponents.mIsNetworkKeyPresent = true;
break;
case SPINEL_PROP_NET_NETWORK_NAME:
@@ -4686,7 +4686,7 @@ void NcpBase::ProcessThreadChangedFlags(void)
{OT_CHANGED_THREAD_EXT_PANID, SPINEL_PROP_NET_XPANID},
{OT_CHANGED_THREAD_RLOC_ADDED, SPINEL_PROP_IPV6_ADDRESS_TABLE},
{OT_CHANGED_THREAD_RLOC_REMOVED, SPINEL_PROP_IPV6_ADDRESS_TABLE},
{OT_CHANGED_MASTER_KEY, SPINEL_PROP_NET_MASTER_KEY},
{OT_CHANGED_NETWORK_KEY, SPINEL_PROP_NET_NETWORK_KEY},
{OT_CHANGED_PSKC, SPINEL_PROP_NET_PSKC},
{OT_CHANGED_CHANNEL_MANAGER_NEW_CHANNEL, SPINEL_PROP_CHANNEL_MANAGER_NEW_CHANNEL},
{OT_CHANGED_SUPPORTED_CHANNEL_MASK, SPINEL_PROP_PHY_CHAN_SUPPORTED},
+2 -2
View File
@@ -128,7 +128,7 @@ proc switch_node {id} {
proc setup_leader {} {
send "dataset init new\n"
expect_line "Done"
send "dataset masterkey 00112233445566778899aabbccddeeff\n"
send "dataset networkkey 00112233445566778899aabbccddeeff\n"
expect_line "Done"
send "dataset commit active\n"
expect_line "Done"
@@ -195,7 +195,7 @@ proc setup_default_network {} {
expect_line "Done"
send "panid 0xface\n"
expect_line "Done"
send "masterkey 00112233445566778899aabbccddeeff\n"
send "networkkey 00112233445566778899aabbccddeeff\n"
expect_line "Done"
}
+8 -8
View File
@@ -40,7 +40,7 @@ set channel $expect_out(1,string)
expect -re {Channel Mask: 0x[0-9a-f]{8}}
expect -re {Ext PAN ID: [0-9a-f]{16}}
expect -re {Mesh Local Prefix: ([0-9a-f]{1,4}:){3}[0-9a-f]{1,4}::\/64}
expect -re {Master Key: [0-9a-f]{32}}
expect -re {Network Key: [0-9a-f]{32}}
expect -re {Network Name: [^\r\n]+}
expect -re {PAN ID: 0x[0-9a-f]{4}}
expect -re {PSKc: [0-9a-f]{32}}
@@ -77,9 +77,9 @@ expect_line "Done"
send "dataset extpanid\n"
expect "aabbccddeeff0011"
expect_line "Done"
send "dataset masterkey aabbccddeeff00112233445566778899\n"
send "dataset networkkey aabbccddeeff00112233445566778899\n"
expect_line "Done"
send "dataset masterkey\n"
send "dataset networkkey\n"
expect "aabbccddeeff00112233445566778899"
expect_line "Done"
send "dataset meshlocalprefix fdde:4860::\n"
@@ -131,7 +131,7 @@ expect "Channel Mask: 0x03fff800"
expect -re {Delay: \d+}
expect "Ext PAN ID: aabbccddeeff0011"
expect "Mesh Local Prefix: fdde:4860:0:0::/64"
expect "Master Key: aabbccddeeff00112233445566778899"
expect "Network Key: aabbccddeeff00112233445566778899"
expect "Network Name: OT-network"
expect "PAN ID: 0xface"
expect "PSKc: 00112233445566778899aabbccddeeff"
@@ -153,7 +153,7 @@ if {$channel == 11} {
expect "Channel Mask: 0x03fff800"
expect "Ext PAN ID: aabbccddeeff0011"
expect "Mesh Local Prefix: fdde:4860:0:0::/64"
expect "Master Key: aabbccddeeff00112233445566778899"
expect "Network Key: aabbccddeeff00112233445566778899"
expect "Network Name: OT-network"
expect "PAN ID: 0xface"
expect "PSKc: 00112233445566778899aabbccddeeff"
@@ -173,7 +173,7 @@ if {$channel == 11} {
expect "Channel Mask: 0x03fff800"
expect "Ext PAN ID: aabbccddeeff0011"
expect "Mesh Local Prefix: fdde:4860:0:0::/64"
expect "Master Key: aabbccddeeff00112233445566778899"
expect "Network Key: aabbccddeeff00112233445566778899"
expect "Network Name: OT-network"
expect "PAN ID: 0xface"
expect "PSKc: 00112233445566778899aabbccddeeff"
@@ -187,13 +187,13 @@ set addr [get_ipaddr mleid]
switch_node 2
send "dataset mgmtgetcommand active \
activetimestamp pendingtimestamp masterkey networkname extpanid \
activetimestamp pendingtimestamp networkkey networkname extpanid \
localprefix delaytimer panid channel \
-x 000102030405060708090a0b0e0f0c333435 \
address $addr\n"
expect_line "Done"
send "dataset mgmtgetcommand pending \
activetimestamp pendingtimestamp masterkey networkname extpanid \
activetimestamp pendingtimestamp networkkey networkname extpanid \
localprefix delaytimer panid channel \
-x 000102030405060708090a0b0e0f0c333435 \
address $addr\n"
@@ -31,7 +31,7 @@ import unittest
from mesh_cop import TlvType
import thread_cert
from pktverify.consts import MLE_DATA_RESPONSE, MGMT_ACTIVE_SET_URI, MGMT_ACTIVE_GET_URI, LEADER_ALOC, NM_COMMISSIONER_SESSION_ID_TLV, NM_ACTIVE_TIMESTAMP_TLV, NM_SECURITY_POLICY_TLV, NM_NETWORK_MASTER_KEY_TLV, MLE_DISCOVERY_RESPONSE
from pktverify.consts import MLE_DATA_RESPONSE, MGMT_ACTIVE_SET_URI, MGMT_ACTIVE_GET_URI, LEADER_ALOC, NM_COMMISSIONER_SESSION_ID_TLV, NM_ACTIVE_TIMESTAMP_TLV, NM_SECURITY_POLICY_TLV, NM_NETWORK_KEY_TLV, MLE_DISCOVERY_RESPONSE
from pktverify.packet_verifier import PacketVerifier
from pktverify.layer_fields import nullField
from pktverify.bytes import Bytes
@@ -76,7 +76,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
'active_dataset': {
'timestamp': 1,
'channel': 19,
'master_key': '00112233445566778899aabbccddeeff',
'network_key': '00112233445566778899aabbccddeeff',
'security_policy': [3600, 'onrcb']
},
'mode': 'rdn',
@@ -86,7 +86,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
'active_dataset': {
'timestamp': 1,
'channel': 19,
'master_key': '00112233445566778899aabbccddeeff',
'network_key': '00112233445566778899aabbccddeeff',
'security_policy': [3600, 'onrcb']
},
'mode': 'rdn',
@@ -102,7 +102,7 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
'active_dataset': {
'timestamp': 1,
'channel': 19,
'master_key': '00112233445566778899aabbccddeeff',
'network_key': '00112233445566778899aabbccddeeff',
'security_policy': [3600, 'onrcb']
},
'mode': 'rdn',
@@ -138,8 +138,8 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
self.simulator.go(5)
# Step 7
# Get MasterKey
self.nodes[COMMISSIONER_1].send_mgmt_active_get(leader_rloc, [TlvType.NETWORK_MASTER_KEY])
# Get NetworkKey
self.nodes[COMMISSIONER_1].send_mgmt_active_get(leader_rloc, [TlvType.NETWORK_KEY])
self.simulator.go(5)
# Step 9
@@ -257,18 +257,18 @@ class Cert_5_8_04_SecurityPolicyTLV(thread_cert.TestCase):
# CoAP Request URI
# coap://[<L>]:MM/c/ag
# CoAP Payload
# Network Master Key TLV
# Network Key TLV
pkts.filter_wpan_src64(COMMISSIONER_1).\
filter_ipv6_2dsts(LEADER_RLOC, LEADER_ALOC).\
filter_coap_request(MGMT_ACTIVE_GET_URI).\
filter(lambda p: NM_NETWORK_MASTER_KEY_TLV in p.thread_meshcop.tlv.type).\
filter(lambda p: NM_NETWORK_KEY_TLV in p.thread_meshcop.tlv.type).\
must_next()
# Step 8: Leader MUST send MGMT_ACTIVE_GET.rsp to the Commissioner_1
# CoAP Response Code
# 2.04 Changed
# CoAP Payload
# Network Master Key TLV MUST NOT be included
# Network Key TLV MUST NOT be included
pkts.filter_wpan_src64(LEADER).\
filter_ipv6_dst(COMMISSIONER_1_RLOC).\
filter_coap_ack(MGMT_ACTIVE_GET_URI).\
@@ -64,12 +64,12 @@ class Cert_8_1_01_Commissioning(thread_cert.TestCase):
TOPOLOGY = {
COMMISSIONER: {
'name': 'COMMISSIONER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
JOINER: {
'name': 'JOINER',
'masterkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'networkkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'mode': 'rdn',
},
}
@@ -88,8 +88,8 @@ class Cert_8_1_01_Commissioning(thread_cert.TestCase):
self.simulator.go(10)
self.simulator.read_cert_messages_in_commissioning_log([COMMISSIONER, JOINER])
self.assertEqual(
self.nodes[JOINER].get_masterkey(),
self.nodes[COMMISSIONER].get_masterkey(),
self.nodes[JOINER].get_networkkey(),
self.nodes[COMMISSIONER].get_networkkey(),
)
joiner_messages = self.simulator.get_messages_sent_by(JOINER)
commissioner_messages = self.simulator.get_messages_sent_by(COMMISSIONER)
@@ -43,12 +43,12 @@ class Cert_8_1_02_Commissioning(thread_cert.TestCase):
TOPOLOGY = {
COMMISSIONER: {
'name': 'COMMISSIONER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
JOINER: {
'name': 'JOINER',
'masterkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'networkkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'mode': 'rdn',
},
}
@@ -64,11 +64,11 @@ class Cert_8_1_06_Commissioning(thread_cert.TestCase):
TOPOLOGY = {
COMMISSIONER: {
'name': 'COMMISSIONER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
JOINER: {
'masterkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'networkkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'mode': 'rdn',
},
}
@@ -88,8 +88,8 @@ class Cert_8_1_06_Commissioning(thread_cert.TestCase):
self.simulator.go(10)
self.simulator.read_cert_messages_in_commissioning_log([COMMISSIONER, JOINER])
self.assertEqual(
self.nodes[JOINER].get_masterkey(),
self.nodes[COMMISSIONER].get_masterkey(),
self.nodes[JOINER].get_networkkey(),
self.nodes[COMMISSIONER].get_networkkey(),
)
joiner_messages = self.simulator.get_messages_sent_by(JOINER)
commissioner_messages = self.simulator.get_messages_sent_by(COMMISSIONER)
@@ -44,17 +44,17 @@ class Cert_8_2_01_JoinerRouter(thread_cert.TestCase):
TOPOLOGY = {
COMMISSIONER: {
'name': 'COMMISSIONER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
JOINER_ROUTER: {
'name': 'JOINER_ROUTER',
'masterkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'networkkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'mode': 'rdn',
},
JOINER: {
'name': 'JOINER',
'masterkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'networkkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'mode': 'rdn',
},
}
@@ -75,8 +75,8 @@ class Cert_8_2_01_JoinerRouter(thread_cert.TestCase):
self.nodes[JOINER_ROUTER].joiner_start('PSKD01')
self.simulator.go(10)
self.assertEqual(
self.nodes[JOINER_ROUTER].get_masterkey(),
self.nodes[COMMISSIONER].get_masterkey(),
self.nodes[JOINER_ROUTER].get_networkkey(),
self.nodes[COMMISSIONER].get_networkkey(),
)
self.nodes[JOINER_ROUTER].thread_start()
@@ -93,8 +93,8 @@ class Cert_8_2_01_JoinerRouter(thread_cert.TestCase):
self.nodes[JOINER].joiner_start('PSKD02')
self.simulator.go(10)
self.assertEqual(
self.nodes[JOINER].get_masterkey(),
self.nodes[COMMISSIONER].get_masterkey(),
self.nodes[JOINER].get_networkkey(),
self.nodes[COMMISSIONER].get_networkkey(),
)
self.nodes[JOINER].thread_start()
@@ -44,17 +44,17 @@ class Cert_8_2_02_JoinerRouter(thread_cert.TestCase):
TOPOLOGY = {
COMMISSIONER: {
'name': 'COMMISSIONER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
JOINER_ROUTER: {
'name': 'JOINER_ROUTER',
'masterkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'networkkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'mode': 'rdn',
},
JOINER: {
'name': 'JOINER',
'masterkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'networkkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'mode': 'rdn',
},
}
@@ -75,8 +75,8 @@ class Cert_8_2_02_JoinerRouter(thread_cert.TestCase):
self.nodes[JOINER_ROUTER].joiner_start('PSKD01')
self.simulator.go(10)
self.assertEqual(
self.nodes[JOINER_ROUTER].get_masterkey(),
self.nodes[COMMISSIONER].get_masterkey(),
self.nodes[JOINER_ROUTER].get_networkkey(),
self.nodes[COMMISSIONER].get_networkkey(),
)
self.nodes[JOINER_ROUTER].thread_start()
@@ -70,17 +70,17 @@ class Cert_8_2_05_JoinerRouter(thread_cert.TestCase):
TOPOLOGY = {
COMMISSIONER: {
'name': 'COMMISSIONER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
JOINER_ROUTER: {
'name': 'JOINER_ROUTER',
'masterkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'networkkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'mode': 'rdn',
},
JOINER: {
'name': 'JOINER',
'masterkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'networkkey': 'deadbeefdeadbeefdeadbeefdeadbeef',
'mode': 'rdn',
},
}
@@ -102,8 +102,8 @@ class Cert_8_2_05_JoinerRouter(thread_cert.TestCase):
self.nodes[JOINER_ROUTER].joiner_start(PSKD, URL_1)
self.simulator.go(10)
self.assertEqual(
self.nodes[JOINER_ROUTER].get_masterkey(),
self.nodes[COMMISSIONER].get_masterkey(),
self.nodes[JOINER_ROUTER].get_networkkey(),
self.nodes[COMMISSIONER].get_networkkey(),
)
self.nodes[JOINER_ROUTER].thread_start()
@@ -124,8 +124,8 @@ class Cert_8_2_05_JoinerRouter(thread_cert.TestCase):
commissioner_messages = self.simulator.get_messages_sent_by(COMMISSIONER)
self.assertEqual(
self.nodes[JOINER].get_masterkey(),
self.nodes[COMMISSIONER].get_masterkey(),
self.nodes[JOINER].get_networkkey(),
self.nodes[COMMISSIONER].get_networkkey(),
)
# check commissioner sends JOIN_FIN.rsp with reject
command.check_commissioner_commissioning_messages(commissioner_messages.commissioning_messages,
@@ -65,12 +65,12 @@ class Cert_8_3_01_CommissionerPetition(thread_cert.TestCase):
TOPOLOGY = {
LEADER: {
'name': 'LEADER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
COMMISSIONER: {
'name': 'COMMISSIONER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
}
@@ -31,7 +31,7 @@ import unittest
import mesh_cop
import thread_cert
from pktverify.consts import MLE_DATA_RESPONSE, MGMT_ACTIVE_GET_URI, NM_CHANNEL_TLV, NM_COMMISSIONER_ID_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_STEERING_DATA_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_PAN_ID_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PSKC_TLV, NM_SCAN_DURATION, NM_ENERGY_LIST_TLV, NM_ACTIVE_TIMESTAMP_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MASTER_KEY_TLV, NM_SECURITY_POLICY_TLV, LEADER_ALOC
from pktverify.consts import MLE_DATA_RESPONSE, MGMT_ACTIVE_GET_URI, NM_CHANNEL_TLV, NM_COMMISSIONER_ID_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_STEERING_DATA_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_PAN_ID_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PSKC_TLV, NM_SCAN_DURATION, NM_ENERGY_LIST_TLV, NM_ACTIVE_TIMESTAMP_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_KEY_TLV, NM_SECURITY_POLICY_TLV, LEADER_ALOC
from pktverify.packet_verifier import PacketVerifier
from pktverify.null_field import nullField
@@ -143,7 +143,7 @@ class Cert_9_2_03_ActiveDatasetGet(thread_cert.TestCase):
# Channel Mask TLV
# Extended PAN ID TLV
# Network Mesh-Local Prefix TLV
# Network Master Key TLV
# Network Key TLV
# Network Name TLV
# PAN ID TLV
# PSKc TLV
@@ -156,7 +156,7 @@ class Cert_9_2_03_ActiveDatasetGet(thread_cert.TestCase):
NM_CHANNEL_MASK_TLV,
NM_EXTENDED_PAN_ID_TLV,
NM_NETWORK_MESH_LOCAL_PREFIX_TLV,
NM_NETWORK_MASTER_KEY_TLV,
NM_NETWORK_KEY_TLV,
NM_NETWORK_NAME_TLV,
NM_PAN_ID_TLV,
NM_PSKC_TLV,
@@ -46,7 +46,7 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
'name': 'COMMISSIONER',
'active_dataset': {
'timestamp': 10,
'master_key': '00112233445566778899aabbccddeeff'
'network_key': '00112233445566778899aabbccddeeff'
},
'mode': 'rdn',
'allowlist': [LEADER]
@@ -55,7 +55,7 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
'name': 'LEADER',
'active_dataset': {
'timestamp': 10,
'master_key': '00112233445566778899aabbccddeeff'
'network_key': '00112233445566778899aabbccddeeff'
},
'mode': 'rdn',
'allowlist': [COMMISSIONER]
@@ -113,12 +113,12 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
self.assertEqual(self.nodes[LEADER].get_network_name(), 'GRL')
# Step 10
# Attempt to set Network Master Key TLV
# Attempt to set Network Key TLV
self.nodes[COMMISSIONER].send_mgmt_active_set(
active_timestamp=104,
channel_mask=0x7fff800,
extended_panid='000db70000000000',
master_key='ffeeddccbbaa99887766554433221100',
network_key='ffeeddccbbaa99887766554433221100',
mesh_local='fd00:0db7::',
network_name='GRL',
)
@@ -131,7 +131,7 @@ class Cert_9_2_04_ActiveDataset(thread_cert.TestCase):
active_timestamp=105,
channel_mask=0x7fff800,
extended_panid='000db70000000000',
master_key='00112233445566778899aabbccddeeff',
network_key='00112233445566778899aabbccddeeff',
mesh_local='fd00:0db7::',
network_name='UL',
panid=0xafce,
@@ -30,7 +30,7 @@
import unittest
import thread_cert
from pktverify.consts import MLE_DATA_RESPONSE, MGMT_ACTIVE_SET_URI, NETWORK_DATA_TLV, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, ACTIVE_TIMESTAMP_TLV, ACTIVE_OPERATION_DATASET_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_NETWORK_MASTER_KEY_TLV, NM_NETWORK_NAME_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV
from pktverify.consts import MLE_DATA_RESPONSE, MGMT_ACTIVE_SET_URI, NETWORK_DATA_TLV, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, ACTIVE_TIMESTAMP_TLV, ACTIVE_OPERATION_DATASET_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_NETWORK_KEY_TLV, NM_NETWORK_NAME_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV
from pktverify.packet_verifier import PacketVerifier
ROUTER = 1
@@ -60,14 +60,14 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
ROUTER: {
'name': 'ROUTER',
'channel': 11,
'master_key': '00112233445566778899aabbccddeeff',
'network_key': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
'allowlist': [LEADER]
},
LEADER: {
'name': 'LEADER',
'channel': 11,
'master_key': '00112233445566778899aabbccddeeff',
'network_key': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
'allowlist': [ROUTER]
},
@@ -96,7 +96,7 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
extended_panid='000db80000000001',
mesh_local='fd00:0db8::',
network_name='TEST_1',
master_key='00112233445566778899aabbccddeeff',
network_key='00112233445566778899aabbccddeeff',
panid=0xface,
channel=11,
binary='0410d2aa9cd8dff7919122d77d37ec3c1b5f0c030e10e0',
@@ -113,7 +113,7 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
extended_panid='000db80000000002',
mesh_local='fd00:0db8::',
network_name='TEST_2',
master_key='00112233445566778899aabbccddeeff',
network_key='00112233445566778899aabbccddeeff',
panid=0xface,
channel=11,
binary='041017d672be32b0c24a2f8385f2fbaf1d970c030e10f0',
@@ -130,7 +130,7 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
extended_panid='000db80000000003',
mesh_local='fd00:0db8::',
network_name='TEST_3',
master_key='00112233445566778899aabbccddeeff',
network_key='00112233445566778899aabbccddeeff',
panid=0xface,
channel=11,
binary='041008f4e9531e8efa8e852d5f4fb951b13e0c030e10f88202aa55',
@@ -146,7 +146,7 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
extended_panid='000db80000000003',
mesh_local='fd00:0db8::',
network_name='TEST_3',
master_key='00112233445566778899aabbccddeeff',
network_key='00112233445566778899aabbccddeeff',
panid=0xface,
channel=63,
binary='041008f4e9531e8efa8e852d5f4fb951b13e0c030e10f8',
@@ -215,7 +215,7 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
# - Channel Mask TLV [new value set in Step 2]
# - Extended PAN ID TLV [new value set in Step 2]
# - Network Mesh-Local Prefix TLV
# - Network Master Key TLV
# - Network Key TLV
# - Network Name TLV [new value set in Step 2]
# - PAN ID TLV
# - PSKc TLV [new value set in Step 2]
@@ -236,7 +236,7 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
NM_CHANNEL_MASK_TLV,
NM_EXTENDED_PAN_ID_TLV,
NM_NETWORK_MESH_LOCAL_PREFIX_TLV,
NM_NETWORK_MASTER_KEY_TLV,
NM_NETWORK_KEY_TLV,
NM_NETWORK_NAME_TLV,
NM_PAN_ID_TLV,
NM_PSKC_TLV,
@@ -308,7 +308,7 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
# - Channel Mask TLV [new value set in Step 9]
# - Extended PAN ID TLV [new value set in Step 9]
# - Network Mesh-Local Prefix TLV
# - Network Master Key TLV
# - Network Key TLV
# - Network Name TLV [new value set in Step 9]
# - PAN ID TLV
# - PSKc TLV [new value set in Step 9]
@@ -329,7 +329,7 @@ class Cert_9_2_05_ActiveDataset(thread_cert.TestCase):
NM_CHANNEL_MASK_TLV,
NM_EXTENDED_PAN_ID_TLV,
NM_NETWORK_MESH_LOCAL_PREFIX_TLV,
NM_NETWORK_MASTER_KEY_TLV,
NM_NETWORK_KEY_TLV,
NM_NETWORK_NAME_TLV,
NM_PAN_ID_TLV,
NM_PSKC_TLV,
@@ -33,7 +33,7 @@ import command
import config
import mesh_cop
import thread_cert
from pktverify.consts import MLE_CHILD_ID_RESPONSE, MLE_CHILD_UPDATE_REQUEST, MLE_DATA_RESPONSE, MLE_DATA_REQUEST, MGMT_COMMISSIONER_SET_URI, MGMT_ACTIVE_SET_URI, MGMT_PENDING_SET_URI, TLV_REQUEST_TLV, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, NETWORK_DATA_TLV, ACTIVE_TIMESTAMP_TLV, PENDING_TIMESTAMP_TLV, ACTIVE_OPERATION_DATASET_TLV, PENDING_OPERATION_DATASET_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_ACTIVE_TIMESTAMP_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_MASTER_KEY_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV, NM_DELAY_TIMER_TLV, NM_STEERING_DATA_TLV, NWD_COMMISSIONING_DATA_TLV, LEADER_ALOC
from pktverify.consts import MLE_CHILD_ID_RESPONSE, MLE_CHILD_UPDATE_REQUEST, MLE_DATA_RESPONSE, MLE_DATA_REQUEST, MGMT_COMMISSIONER_SET_URI, MGMT_ACTIVE_SET_URI, MGMT_PENDING_SET_URI, TLV_REQUEST_TLV, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, NETWORK_DATA_TLV, ACTIVE_TIMESTAMP_TLV, PENDING_TIMESTAMP_TLV, ACTIVE_OPERATION_DATASET_TLV, PENDING_OPERATION_DATASET_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_ACTIVE_TIMESTAMP_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_KEY_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV, NM_DELAY_TIMER_TLV, NM_STEERING_DATA_TLV, NWD_COMMISSIONING_DATA_TLV, LEADER_ALOC
from pktverify.packet_verifier import PacketVerifier
from pktverify.layer_fields import nullField
@@ -30,7 +30,7 @@
import unittest
import thread_cert
from pktverify.consts import MLE_CHILD_ID_RESPONSE, MLE_DATA_RESPONSE, MGMT_PENDING_SET_URI, MGMT_ACTIVE_SET_URI, MGMT_DATASET_CHANGED_URI, COAP_CODE_ACK, ACTIVE_OPERATION_DATASET_TLV, ACTIVE_TIMESTAMP_TLV, PENDING_TIMESTAMP_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MASTER_KEY_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_NETWORK_NAME_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, ACTIVE_TIMESTAMP_TLV, NETWORK_DATA_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_DELAY_TIMER_TLV, PENDING_OPERATION_DATASET_TLV
from pktverify.consts import MLE_CHILD_ID_RESPONSE, MLE_DATA_RESPONSE, MGMT_PENDING_SET_URI, MGMT_ACTIVE_SET_URI, MGMT_DATASET_CHANGED_URI, COAP_CODE_ACK, ACTIVE_OPERATION_DATASET_TLV, ACTIVE_TIMESTAMP_TLV, PENDING_TIMESTAMP_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_KEY_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_NETWORK_NAME_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, ACTIVE_TIMESTAMP_TLV, NETWORK_DATA_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_DELAY_TIMER_TLV, PENDING_OPERATION_DATASET_TLV
from pktverify.packet_verifier import PacketVerifier
PANID_INIT = 0xface
@@ -159,7 +159,7 @@ class Cert_9_2_7_DelayTimer(thread_cert.TestCase):
# Step 4: Leader MUST send a unicast MLE Child ID Response to the Router
_lpkts.filter_wpan_dst64(ROUTER).filter_mle_cmd(MLE_CHILD_ID_RESPONSE).must_next(
).must_verify(lambda p: {ACTIVE_OPERATION_DATASET_TLV, ACTIVE_TIMESTAMP_TLV} < set(p.mle.tlv.type) and {
NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MASTER_KEY_TLV,
NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_KEY_TLV,
NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_NETWORK_NAME_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV
} <= set(p.thread_meshcop.tlv.type) and p.mle.tlv.active_tstamp == LEADER_ACTIVE_TIMESTAMP)
@@ -177,7 +177,7 @@ class Cert_9_2_7_DelayTimer(thread_cert.TestCase):
# Step 10: Leader MUST send a unicast MLE Data Response to the Router
_lpkts.filter_wpan_dst64(ROUTER).filter_mle_cmd(MLE_DATA_RESPONSE).must_next(
).must_verify(lambda p: {ACTIVE_OPERATION_DATASET_TLV, ACTIVE_TIMESTAMP_TLV} < set(p.mle.tlv.type) and {
NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MASTER_KEY_TLV,
NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_KEY_TLV,
NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_NETWORK_NAME_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV
} <= set(p.thread_meshcop.tlv.type) and p.mle.tlv.active_tstamp == ROUTER_ACTIVE_TIMESTAMP)
@@ -31,7 +31,7 @@ import unittest
import config
import thread_cert
from pktverify.consts import MLE_CHILD_ID_REQUEST, MLE_CHILD_ID_RESPONSE, MLE_DATA_RESPONSE, MLE_DATA_REQUEST, MGMT_PENDING_SET_URI, MGMT_ACTIVE_SET_URI, MGMT_DATASET_CHANGED_URI, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, ACTIVE_OPERATION_DATASET_TLV, ACTIVE_TIMESTAMP_TLV, PENDING_TIMESTAMP_TLV, TLV_REQUEST_TLV, NETWORK_DATA_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_DELAY_TIMER_TLV, PENDING_OPERATION_DATASET_TLV, NWD_COMMISSIONING_DATA_TLV, LEADER_ALOC, NM_ACTIVE_TIMESTAMP_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_NETWORK_MASTER_KEY_TLV, NM_NETWORK_NAME_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV
from pktverify.consts import MLE_CHILD_ID_REQUEST, MLE_CHILD_ID_RESPONSE, MLE_DATA_RESPONSE, MLE_DATA_REQUEST, MGMT_PENDING_SET_URI, MGMT_ACTIVE_SET_URI, MGMT_DATASET_CHANGED_URI, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, ACTIVE_OPERATION_DATASET_TLV, ACTIVE_TIMESTAMP_TLV, PENDING_TIMESTAMP_TLV, TLV_REQUEST_TLV, NETWORK_DATA_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_DELAY_TIMER_TLV, PENDING_OPERATION_DATASET_TLV, NWD_COMMISSIONING_DATA_TLV, LEADER_ALOC, NM_ACTIVE_TIMESTAMP_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_NETWORK_KEY_TLV, NM_NETWORK_NAME_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV
from pktverify.packet_verifier import PacketVerifier
from pktverify.null_field import nullField
@@ -50,8 +50,8 @@ SED1 = 5
# Test Purpose and Description:
# -----------------------------
# The purpose of this test case is to confirm the DUT correctly applies
# DELAY_TIMER_DEFAULT when the master key is changed.
# The Commissioner first tries to set a master key update to happen too
# DELAY_TIMER_DEFAULT when the network key is changed.
# The Commissioner first tries to set a network key update to happen too
# soon (delay of 60s vs DELAY_TIMER_DEFAULT of 300s); the DUT is expected
# to override the short value and communicate an appropriately longer delay
# to the Router.
@@ -74,7 +74,7 @@ SED1 = 5
# Leader
class Cert_9_2_11_MasterKey(thread_cert.TestCase):
class Cert_9_2_11_NetworkKey(thread_cert.TestCase):
USE_MESSAGE_FACTORY = False
SUPPORT_NCP = False
@@ -85,7 +85,7 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
'timestamp': 10,
'panid': PANID_INIT,
'channel': CHANNEL_INIT,
'master_key': KEY1
'network_key': KEY1
},
'mode': 'rdn',
'allowlist': [LEADER]
@@ -96,7 +96,7 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
'timestamp': 10,
'panid': PANID_INIT,
'channel': CHANNEL_INIT,
'master_key': KEY1
'network_key': KEY1
},
'mode': 'rdn',
'allowlist': [COMMISSIONER, ROUTER1]
@@ -107,7 +107,7 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
'timestamp': 10,
'panid': PANID_INIT,
'channel': CHANNEL_INIT,
'master_key': KEY1
'network_key': KEY1
},
'mode': 'rdn',
'allowlist': [LEADER, ED1, SED1]
@@ -116,7 +116,7 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
'name': 'ED',
'channel': CHANNEL_INIT,
'is_mtd': True,
'masterkey': KEY1,
'networkkey': KEY1,
'mode': 'rn',
'panid': PANID_INIT,
'allowlist': [ROUTER1]
@@ -125,7 +125,7 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
'name': 'SED',
'channel': CHANNEL_INIT,
'is_mtd': True,
'masterkey': KEY1,
'networkkey': KEY1,
'mode': '-',
'panid': PANID_INIT,
'timeout': config.DEFAULT_CHILD_TIMEOUT,
@@ -163,15 +163,15 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
pending_timestamp=10,
active_timestamp=70,
delay_timer=60000,
master_key=KEY2,
network_key=KEY2,
)
self.simulator.go(310)
self.assertEqual(self.nodes[COMMISSIONER].get_masterkey(), KEY2)
self.assertEqual(self.nodes[LEADER].get_masterkey(), KEY2)
self.assertEqual(self.nodes[ROUTER1].get_masterkey(), KEY2)
self.assertEqual(self.nodes[ED1].get_masterkey(), KEY2)
self.assertEqual(self.nodes[SED1].get_masterkey(), KEY2)
self.assertEqual(self.nodes[COMMISSIONER].get_networkkey(), KEY2)
self.assertEqual(self.nodes[LEADER].get_networkkey(), KEY2)
self.assertEqual(self.nodes[ROUTER1].get_networkkey(), KEY2)
self.assertEqual(self.nodes[ED1].get_networkkey(), KEY2)
self.assertEqual(self.nodes[SED1].get_networkkey(), KEY2)
ipaddr = self.nodes[LEADER].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
self.assertTrue(self.nodes[ROUTER1].ping(ipaddr))
@@ -180,15 +180,15 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
pending_timestamp=20,
active_timestamp=30,
delay_timer=500000,
master_key=KEY1,
network_key=KEY1,
)
self.simulator.go(510)
self.assertEqual(self.nodes[COMMISSIONER].get_masterkey(), KEY1)
self.assertEqual(self.nodes[LEADER].get_masterkey(), KEY1)
self.assertEqual(self.nodes[ROUTER1].get_masterkey(), KEY1)
self.assertEqual(self.nodes[ED1].get_masterkey(), KEY1)
self.assertEqual(self.nodes[SED1].get_masterkey(), KEY1)
self.assertEqual(self.nodes[COMMISSIONER].get_networkkey(), KEY1)
self.assertEqual(self.nodes[LEADER].get_networkkey(), KEY1)
self.assertEqual(self.nodes[ROUTER1].get_networkkey(), KEY1)
self.assertEqual(self.nodes[ED1].get_networkkey(), KEY1)
self.assertEqual(self.nodes[SED1].get_networkkey(), KEY1)
ipaddr = self.nodes[LEADER].get_ip6_address(config.ADDRESS_TYPE.ML_EID)
self.assertTrue(self.nodes[ROUTER1].ping(ipaddr))
@@ -264,7 +264,7 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
# - Pending Timestamp TLV
# - Pending Operational Dataset TLV
# - Delay Timer TLV <greater than 200s>
# - Network Master Key TLV: New Master Key
# - Network Key TLV: New Network Key
# - Active Timestamp TLV <70s>
_dr_pkt = pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
filter_wpan_src64(LEADER).\
@@ -286,7 +286,7 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
).\
must_next()
# Step 8: Verify all devices now use New Master key.
# Step 8: Verify all devices now use New Network key.
# checked in test()
# Step 9: Verify new MAC key is generated and used when sending ICMPv6 Echo Reply
@@ -352,7 +352,7 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
# - Pending Operational Dataset TLV
# - Active Timestamp TLV <30s>
# - Delay Timer TLV <greater than 300s>
# - Network Master Key TLV: New Master Key
# - Network Key TLV: New Network Key
pkts.filter_mle_cmd(MLE_DATA_RESPONSE).\
filter_wpan_src64(LEADER).\
filter_wpan_dst64(ROUTER).\
@@ -375,7 +375,7 @@ class Cert_9_2_11_MasterKey(thread_cert.TestCase):
).\
must_next()
# Step 17: The DUT MUST send an ICMPv6 Echo Reply using the new Master key
# Step 17: The DUT MUST send an ICMPv6 Echo Reply using the new Network key
_pkt = pkts.filter_ping_request().\
filter_wpan_src64(ROUTER).\
filter_ipv6_dst(LEADER_MLEID).\
@@ -31,7 +31,7 @@ import unittest
import config
import thread_cert
from pktverify.consts import MLE_CHILD_ID_RESPONSE, MLE_CHILD_UPDATE_REQUEST, MLE_DATA_RESPONSE, MLE_DATA_REQUEST, MGMT_ACTIVE_SET_URI, MGMT_PENDING_SET_URI, LINK_LOCAL_ALL_NODES_MULTICAST_ADDRESS, TLV_REQUEST_TLV, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, NETWORK_DATA_TLV, ACTIVE_TIMESTAMP_TLV, PENDING_TIMESTAMP_TLV, PENDING_OPERATION_DATASET_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_ACTIVE_TIMESTAMP_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_MASTER_KEY_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV, NM_DELAY_TIMER_TLV
from pktverify.consts import MLE_CHILD_ID_RESPONSE, MLE_CHILD_UPDATE_REQUEST, MLE_DATA_RESPONSE, MLE_DATA_REQUEST, MGMT_ACTIVE_SET_URI, MGMT_PENDING_SET_URI, LINK_LOCAL_ALL_NODES_MULTICAST_ADDRESS, TLV_REQUEST_TLV, SOURCE_ADDRESS_TLV, LEADER_DATA_TLV, NETWORK_DATA_TLV, ACTIVE_TIMESTAMP_TLV, PENDING_TIMESTAMP_TLV, PENDING_OPERATION_DATASET_TLV, NM_COMMISSIONER_SESSION_ID_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_ACTIVE_TIMESTAMP_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_KEY_TLV, NM_CHANNEL_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PAN_ID_TLV, NM_PSKC_TLV, NM_SECURITY_POLICY_TLV, NM_DELAY_TIMER_TLV
from pktverify.packet_verifier import PacketVerifier
from pktverify.addrs import Ipv6Addr
@@ -60,7 +60,7 @@ class Cert_9_2_18_RollBackActiveTimestamp(thread_cert.TestCase):
'timestamp': 1,
'panid': PANID_INIT,
'channel': CHANNEL_INIT,
'master_key': KEY1
'network_key': KEY1
},
'mode': 'rdn',
'allowlist': [LEADER]
@@ -71,7 +71,7 @@ class Cert_9_2_18_RollBackActiveTimestamp(thread_cert.TestCase):
'timestamp': 1,
'panid': PANID_INIT,
'channel': CHANNEL_INIT,
'master_key': KEY1
'network_key': KEY1
},
'mode': 'rdn',
'partition_id': 0xffffffff,
@@ -83,7 +83,7 @@ class Cert_9_2_18_RollBackActiveTimestamp(thread_cert.TestCase):
'timestamp': 1,
'panid': PANID_INIT,
'channel': CHANNEL_INIT,
'master_key': KEY1
'network_key': KEY1
},
'mode': 'rdn',
'allowlist': [LEADER, ED1, SED1]
@@ -92,7 +92,7 @@ class Cert_9_2_18_RollBackActiveTimestamp(thread_cert.TestCase):
'name': 'ED',
'channel': CHANNEL_INIT,
'is_mtd': True,
'masterkey': KEY1,
'networkkey': KEY1,
'mode': 'rn',
'panid': PANID_INIT,
'allowlist': [ROUTER1]
@@ -101,7 +101,7 @@ class Cert_9_2_18_RollBackActiveTimestamp(thread_cert.TestCase):
'name': 'SED',
'channel': CHANNEL_INIT,
'is_mtd': True,
'masterkey': KEY1,
'networkkey': KEY1,
'mode': '-',
'panid': PANID_INIT,
'timeout': config.DEFAULT_CHILD_TIMEOUT,
@@ -148,15 +148,15 @@ class Cert_9_2_18_RollBackActiveTimestamp(thread_cert.TestCase):
active_timestamp=20,
delay_timer=300,
network_name='MyHouse',
master_key=KEY2,
network_key=KEY2,
)
self.simulator.go(310)
self.assertEqual(self.nodes[COMMISSIONER].get_masterkey(), KEY2)
self.assertEqual(self.nodes[LEADER].get_masterkey(), KEY2)
self.assertEqual(self.nodes[ROUTER1].get_masterkey(), KEY2)
self.assertEqual(self.nodes[ED1].get_masterkey(), KEY2)
self.assertEqual(self.nodes[SED1].get_masterkey(), KEY2)
self.assertEqual(self.nodes[COMMISSIONER].get_networkkey(), KEY2)
self.assertEqual(self.nodes[LEADER].get_networkkey(), KEY2)
self.assertEqual(self.nodes[ROUTER1].get_networkkey(), KEY2)
self.assertEqual(self.nodes[ED1].get_networkkey(), KEY2)
self.assertEqual(self.nodes[SED1].get_networkkey(), KEY2)
self.collect_rlocs()
ed_rloc = self.nodes[ED1].get_rloc()
@@ -211,7 +211,7 @@ class Cert_9_2_18_RollBackActiveTimestamp(thread_cert.TestCase):
PENDING_OPERATION_DATASET_TLV
} == set(p.mle.tlv.type) and {
NM_COMMISSIONER_SESSION_ID_TLV, NM_BORDER_AGENT_LOCATOR_TLV, NM_ACTIVE_TIMESTAMP_TLV,
NM_NETWORK_NAME_TLV, NM_NETWORK_MASTER_KEY_TLV
NM_NETWORK_NAME_TLV, NM_NETWORK_KEY_TLV
} <= set(p.thread_meshcop.tlv.type) and p.thread_nwd.tlv.stable == [0])
# Copy a pv.pkts here to filter SED related packets for potential sequence packets disorder
@@ -245,7 +245,7 @@ class Cert_9_2_18_RollBackActiveTimestamp(thread_cert.TestCase):
PENDING_OPERATION_DATASET_TLV
} <= set(p.mle.tlv.type) and {
NM_CHANNEL_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PAN_ID_TLV, NM_DELAY_TIMER_TLV,
NM_ACTIVE_TIMESTAMP_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_MASTER_KEY_TLV
NM_ACTIVE_TIMESTAMP_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_KEY_TLV
} <= set(p.thread_meshcop.tlv.type) and p.thread_meshcop.tlv.net_name == ["MyHouse"] and p.
thread_meshcop.tlv.master_key == KEY2)
@@ -31,7 +31,7 @@ import unittest
import mesh_cop
import thread_cert
from pktverify.consts import MGMT_PENDING_GET_URI, MGMT_PENDING_SET_URI, NM_CHANNEL_TLV, NM_PAN_ID_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PSKC_TLV, NM_ACTIVE_TIMESTAMP_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_MASTER_KEY_TLV, NM_SECURITY_POLICY_TLV, NM_PENDING_TIMESTAMP_TLV, NM_DELAY_TIMER_TLV, LEADER_ALOC
from pktverify.consts import MGMT_PENDING_GET_URI, MGMT_PENDING_SET_URI, NM_CHANNEL_TLV, NM_PAN_ID_TLV, NM_NETWORK_NAME_TLV, NM_NETWORK_MESH_LOCAL_PREFIX_TLV, NM_PSKC_TLV, NM_ACTIVE_TIMESTAMP_TLV, NM_CHANNEL_MASK_TLV, NM_EXTENDED_PAN_ID_TLV, NM_NETWORK_KEY_TLV, NM_SECURITY_POLICY_TLV, NM_PENDING_TIMESTAMP_TLV, NM_DELAY_TIMER_TLV, LEADER_ALOC
from pktverify.packet_verifier import PacketVerifier
from pktverify.null_field import nullField
@@ -206,7 +206,7 @@ class Cert_9_2_19_PendingDatasetGet(thread_cert.TestCase):
# Delay Timer TLV
# Extended PAN ID TLV
# Network Mesh-Local Prefix TLV
# Network Master Key TLV
# Network Key TLV
# Network Name TLV
# PAN ID TLV
# Pending Timestamp TLV
@@ -221,7 +221,7 @@ class Cert_9_2_19_PendingDatasetGet(thread_cert.TestCase):
NM_DELAY_TIMER_TLV,
NM_EXTENDED_PAN_ID_TLV,
NM_NETWORK_MESH_LOCAL_PREFIX_TLV,
NM_NETWORK_MASTER_KEY_TLV,
NM_NETWORK_KEY_TLV,
NM_NETWORK_NAME_TLV,
NM_PAN_ID_TLV,
NM_PENDING_TIMESTAMP_TLV,
+2 -2
View File
@@ -121,7 +121,7 @@ EXTRA_DIST = \
Cert_9_2_08_PersistentDatasets.py \
Cert_9_2_09_PendingPartition.py \
Cert_9_2_10_PendingPartition.py \
Cert_9_2_11_MasterKey.py \
Cert_9_2_11_NetworkKey.py \
Cert_9_2_12_Announce.py \
Cert_9_2_13_EnergyScan.py \
Cert_9_2_14_PanIdQuery.py \
@@ -328,7 +328,7 @@ check_SCRIPTS = \
Cert_9_2_08_PersistentDatasets.py \
Cert_9_2_09_PendingPartition.py \
Cert_9_2_10_PendingPartition.py \
Cert_9_2_11_MasterKey.py \
Cert_9_2_11_NetworkKey.py \
Cert_9_2_12_Announce.py \
Cert_9_2_13_EnergyScan.py \
Cert_9_2_14_PanIdQuery.py \
+16 -16
View File
@@ -83,7 +83,7 @@ ONLINK_GUA_PREFIX = '2021::/64'
# Any address starts with 'fd' are considered on-link address.
ONLINK_PREFIX_REGEX_PATTERN = '^fd'
DEFAULT_MASTER_KEY = bytearray([
DEFAULT_NETWORK_KEY = bytearray([
0x00,
0x11,
0x22,
@@ -277,15 +277,15 @@ def create_default_mle_tlvs_factories():
}
def create_default_mle_crypto_engine(master_key):
return net_crypto.CryptoEngine(crypto_material_creator=net_crypto.MleCryptoMaterialCreator(master_key))
def create_default_mle_crypto_engine(network_key):
return net_crypto.CryptoEngine(crypto_material_creator=net_crypto.MleCryptoMaterialCreator(network_key))
def create_default_mle_message_factory(master_key):
def create_default_mle_message_factory(network_key):
return mle.MleMessageFactory(
aux_sec_hdr_factory=net_crypto.AuxiliarySecurityHeaderFactory(),
mle_command_factory=mle.MleCommandFactory(tlvs_factories=create_default_mle_tlvs_factories()),
crypto_engine=create_default_mle_crypto_engine(master_key),
crypto_engine=create_default_mle_crypto_engine(network_key),
)
@@ -333,7 +333,7 @@ def create_default_mesh_cop_tlvs_factories():
mesh_cop.TlvType.EXTENDED_PANID: mesh_cop.ExtendedPanidFactory(),
mesh_cop.TlvType.NETWORK_NAME: mesh_cop.NetworkNameFactory(),
mesh_cop.TlvType.PSKC: mesh_cop.PSKcFactory(),
mesh_cop.TlvType.NETWORK_MASTER_KEY: mesh_cop.NetworkMasterKeyFactory(),
mesh_cop.TlvType.NETWORK_KEY: mesh_cop.NetworkKeyFactory(),
mesh_cop.TlvType.NETWORK_KEY_SEQUENCE_COUNTER: mesh_cop.NetworkKeySequenceCounterFactory(),
mesh_cop.TlvType.NETWORK_MESH_LOCAL_PREFIX: mesh_cop.NetworkMeshLocalPrefixFactory(),
mesh_cop.TlvType.STEERING_DATA: mesh_cop.SteeringDataFactory(),
@@ -437,8 +437,8 @@ def create_default_ipv6_hop_by_hop_options_factory():
return ipv6.HopByHopOptionsFactory(options_factories=create_default_ipv6_hop_by_hop_options_factories())
def create_default_based_on_src_dst_ports_udp_payload_factory(master_key):
mle_message_factory = create_default_mle_message_factory(master_key)
def create_default_based_on_src_dst_ports_udp_payload_factory(network_key):
mle_message_factory = create_default_mle_message_factory(network_key)
coap_message_factory = create_default_coap_message_factory()
dtls_message_factory = create_default_dtls_message_factory()
@@ -465,12 +465,12 @@ def create_default_ipv6_icmp_body_factories():
}
def create_default_ipv6_upper_layer_factories(master_key):
def create_default_ipv6_upper_layer_factories(network_key):
return {
ipv6.IPV6_NEXT_HEADER_UDP:
ipv6.UDPDatagramFactory(
udp_header_factory=ipv6.UDPHeaderFactory(),
udp_payload_factory=create_default_based_on_src_dst_ports_udp_payload_factory(master_key),
udp_payload_factory=create_default_based_on_src_dst_ports_udp_payload_factory(network_key),
),
ipv6.IPV6_NEXT_HEADER_ICMP:
ipv6.ICMPv6Factory(body_factories=create_default_ipv6_icmp_body_factories()),
@@ -491,10 +491,10 @@ def create_default_ipv6_extension_headers_factories():
}
def create_default_ipv6_packet_factory(master_key):
def create_default_ipv6_packet_factory(network_key):
return ipv6.IPv6PacketFactory(
ehf=create_default_ipv6_extension_headers_factories(),
ulpf=create_default_ipv6_upper_layer_factories(master_key),
ulpf=create_default_ipv6_upper_layer_factories(network_key),
)
@@ -514,18 +514,18 @@ def create_default_thread_context_manager():
return context_manager
def create_default_lowpan_parser(context_manager, master_key=DEFAULT_MASTER_KEY):
def create_default_lowpan_parser(context_manager, network_key=DEFAULT_NETWORK_KEY):
return lowpan.LowpanParser(
lowpan_mesh_header_factory=lowpan.LowpanMeshHeaderFactory(),
lowpan_decompressor=create_default_lowpan_decompressor(context_manager),
lowpan_fragements_buffers_manager=lowpan.LowpanFragmentsBuffersManager(),
ipv6_packet_factory=create_default_ipv6_packet_factory(master_key),
ipv6_packet_factory=create_default_ipv6_packet_factory(network_key),
)
def create_default_thread_message_factory(master_key=DEFAULT_MASTER_KEY):
def create_default_thread_message_factory(network_key=DEFAULT_NETWORK_KEY):
context_manager = create_default_thread_context_manager()
lowpan_parser = create_default_lowpan_parser(context_manager, master_key)
lowpan_parser = create_default_lowpan_parser(context_manager, network_key)
return message.MessageFactory(lowpan_parser=lowpan_parser)
+1 -1
View File
@@ -346,7 +346,7 @@ class MacFrame:
else:
message_info.source_mac_address = src_address.mac_address
sec_obj = CryptoEngine(MacCryptoMaterialCreator(config.DEFAULT_MASTER_KEY))
sec_obj = CryptoEngine(MacCryptoMaterialCreator(config.DEFAULT_NETWORK_KEY))
self.payload = MacPayload(bytearray(open_payload) + sec_obj.decrypt(private_payload, mic, message_info))
else:
+4 -4
View File
@@ -44,7 +44,7 @@ class TlvType(IntEnum):
EXTENDED_PANID = 2
NETWORK_NAME = 3
PSKC = 4
NETWORK_MASTER_KEY = 5
NETWORK_KEY = 5
NETWORK_KEY_SEQUENCE_COUNTER = 6
NETWORK_MESH_LOCAL_PREFIX = 7
STEERING_DATA = 8
@@ -213,13 +213,13 @@ class PSKcFactory(object):
raise NotImplementedError("TODO: Not implemented yet")
# NetworkMasterKey TLV (5)
class NetworkMasterKey(object):
# NetworkKey TLV (5)
class NetworkKey(object):
# TODO: Not implemented yet
pass
class NetworkMasterKeyFactory(object):
class NetworkKeyFactory(object):
# TODO: Not implemented yet
def parse(self, data, message_info):
+11 -11
View File
@@ -42,7 +42,7 @@ class CryptoEngine:
def __init__(self, crypto_material_creator):
"""
Args:
master_key (bytearray)
network_key (bytearray)
"""
self._crypto_material_creator = crypto_material_creator
@@ -94,13 +94,13 @@ class CryptoMaterialCreator(object):
_salt = b'Thread'
def __init__(self, master_key):
def __init__(self, network_key):
"""
Args:
master_key (bytearray)
network_key (bytearray)
"""
self.master_key = master_key
self.network_key = network_key
def _generate_keys(self, sequence_counter):
""" Generate MLE and MAC keys.
@@ -114,7 +114,7 @@ class CryptoMaterialCreator(object):
tuple: MLE and MAC as bytes
"""
k = self.master_key
k = self.network_key
s = struct.pack(">L", sequence_counter) + self._salt
d = hmac.new(k, s, digestmod=hashlib.sha256).digest()
@@ -132,13 +132,13 @@ class CryptoMaterialCreator(object):
class MacCryptoMaterialCreator(CryptoMaterialCreator):
def __init__(self, master_key):
def __init__(self, network_key):
"""
Args:
master_key (bytearray)
network_key (bytearray)
"""
super(MacCryptoMaterialCreator, self).__init__(master_key)
super(MacCryptoMaterialCreator, self).__init__(network_key)
def _create_nonce(self, eui64, frame_counter, security_level):
""" Create CCM Nonce required by AES-128 CCM for encryption and decryption.
@@ -196,13 +196,13 @@ class MacCryptoMaterialCreator(CryptoMaterialCreator):
class MleCryptoMaterialCreator(CryptoMaterialCreator):
def __init__(self, master_key):
def __init__(self, network_key):
"""
Args:
master_key (bytearray)
network_key (bytearray)
"""
super(MleCryptoMaterialCreator, self).__init__(master_key)
super(MleCryptoMaterialCreator, self).__init__(network_key)
def _create_nonce(self, source_eui64, frame_counter, security_level):
""" Create CCM Nonce required by AES-128 CCM for encryption and decryption.
+13 -13
View File
@@ -1255,12 +1255,12 @@ class NodeImpl:
self.send_command(cmd)
self._expect_done()
def get_masterkey(self):
self.send_command('masterkey')
def get_networkkey(self):
self.send_command('networkkey')
return self._expect_result('[0-9a-fA-F]{32}')
def set_masterkey(self, masterkey):
cmd = 'masterkey %s' % masterkey
def set_networkkey(self, networkkey):
cmd = 'networkkey %s' % networkkey
self.send_command(cmd)
self._expect_done()
@@ -1816,7 +1816,7 @@ class NodeImpl:
panid=None,
channel=None,
channel_mask=None,
master_key=None,
network_key=None,
security_policy=[],
):
self.send_command('dataset clear')
@@ -1841,8 +1841,8 @@ class NodeImpl:
self.send_command(cmd)
self._expect_done()
if master_key is not None:
cmd = 'dataset masterkey %s' % master_key
if network_key is not None:
cmd = 'dataset networkkey %s' % network_key
self.send_command(cmd)
self._expect_done()
@@ -1929,7 +1929,7 @@ class NodeImpl:
channel_mask=None,
extended_panid=None,
panid=None,
master_key=None,
network_key=None,
mesh_local=None,
network_name=None,
security_policy=None,
@@ -1952,8 +1952,8 @@ class NodeImpl:
if panid is not None:
cmd += 'panid %d ' % panid
if master_key is not None:
cmd += 'masterkey %s ' % master_key
if network_key is not None:
cmd += 'networkkey %s ' % network_key
if mesh_local is not None:
cmd += 'localprefix %s ' % mesh_local
@@ -2008,7 +2008,7 @@ class NodeImpl:
delay_timer=None,
channel=None,
panid=None,
master_key=None,
network_key=None,
mesh_local=None,
network_name=None,
):
@@ -2028,8 +2028,8 @@ class NodeImpl:
if panid is not None:
cmd += 'panid %d ' % panid
if master_key is not None:
cmd += 'masterkey %s ' % master_key
if network_key is not None:
cmd += 'networkkey %s ' % network_key
if mesh_local is not None:
cmd += 'localprefix %s ' % mesh_local
@@ -187,7 +187,7 @@ NM_PAN_ID_TLV = 1
NM_EXTENDED_PAN_ID_TLV = 2
NM_NETWORK_NAME_TLV = 3
NM_PSKC_TLV = 4
NM_NETWORK_MASTER_KEY_TLV = 5
NM_NETWORK_KEY_TLV = 5
NM_NETWORK_KEY_SEQUENCE_COUNTER_TLV = 6
NM_NETWORK_MESH_LOCAL_PREFIX_TLV = 7
NM_STEERING_DATA_TLV = 8
+12 -12
View File
@@ -36,7 +36,7 @@ import ipaddress
import common
import net_crypto
master_key = bytearray(
network_key = bytearray(
[0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff])
@@ -90,7 +90,7 @@ def any_data(length=None):
return bytearray([random.getrandbits(8) for _ in range(length)])
def any_master_key():
def any_network_key():
return bytearray([random.getrandbits(8) for _ in range(16)])
@@ -118,7 +118,7 @@ class TestCryptoEngine(unittest.TestCase):
mic = bytearray([0xe1, 0xb5, 0xa2, 0x53])
net_crypto_engine = net_crypto.CryptoEngine(net_crypto.MleCryptoMaterialCreator(master_key))
net_crypto_engine = net_crypto.CryptoEngine(net_crypto.MleCryptoMaterialCreator(network_key))
# WHEN
mle_msg = net_crypto_engine.decrypt(data, mic, message_info)
@@ -150,7 +150,7 @@ class TestCryptoEngine(unittest.TestCase):
0x0b, 0x08, 0x65, 0x5e, 0x0f, 0x83, 0x40, 0xc7, 0x83, 0x31
])
net_crypto_engine = net_crypto.CryptoEngine(net_crypto.MleCryptoMaterialCreator(master_key))
net_crypto_engine = net_crypto.CryptoEngine(net_crypto.MleCryptoMaterialCreator(network_key))
# WHEN
encrypted_data, mic = net_crypto_engine.encrypt(mle_msg, message_info)
@@ -167,7 +167,7 @@ class TestCryptoEngine(unittest.TestCase):
# GIVEN
data = any_data()
master_key = any_master_key()
network_key = any_network_key()
key_id_mode = 2
security_level = 5
@@ -184,7 +184,7 @@ class TestCryptoEngine(unittest.TestCase):
key_id=any_key_id(key_id_mode))
message_info.aux_sec_hdr_bytes = convert_aux_sec_hdr_to_bytearray(message_info.aux_sec_hdr)
net_crypto_engine = net_crypto.CryptoEngine(net_crypto.MleCryptoMaterialCreator(master_key))
net_crypto_engine = net_crypto.CryptoEngine(net_crypto.MleCryptoMaterialCreator(network_key))
# WHEN
enc_data, mic = net_crypto_engine.encrypt(data, message_info)
@@ -210,7 +210,7 @@ class TestCryptoMaterialCreator(unittest.TestCase):
# GIVEN
sequence_counter = 0
creator = net_crypto.CryptoMaterialCreator(master_key)
creator = net_crypto.CryptoMaterialCreator(network_key)
# WHEN
mle_key, mac_key = creator._generate_keys(sequence_counter)
@@ -233,7 +233,7 @@ class TestCryptoMaterialCreator(unittest.TestCase):
# GIVEN
sequence_counter = 1
creator = net_crypto.CryptoMaterialCreator(master_key)
creator = net_crypto.CryptoMaterialCreator(network_key)
# WHEN
mle_key, mac_key = creator._generate_keys(sequence_counter)
@@ -256,7 +256,7 @@ class TestCryptoMaterialCreator(unittest.TestCase):
# GIVEN
sequence_counter = 2
creator = net_crypto.CryptoMaterialCreator(master_key)
creator = net_crypto.CryptoMaterialCreator(network_key)
# WHEN
mle_key, mac_key = creator._generate_keys(sequence_counter)
@@ -280,7 +280,7 @@ class TestMleCryptoMaterialCreator(unittest.TestCase):
frame_counter = any_frame_counter()
security_level = any_security_level()
creator = net_crypto.MleCryptoMaterialCreator(master_key)
creator = net_crypto.MleCryptoMaterialCreator(network_key)
# WHEN
nonce = creator._create_nonce(source_eui64, frame_counter, security_level)
@@ -303,7 +303,7 @@ class TestMleCryptoMaterialCreator(unittest.TestCase):
destination_address = any_ip_address()
auxiliary_security_header_bytes = convert_aux_sec_hdr_to_bytearray(any_auxiliary_security_header())
creator = net_crypto.MleCryptoMaterialCreator(master_key)
creator = net_crypto.MleCryptoMaterialCreator(network_key)
# WHEN
authenticated_data = creator._create_authenticated_data(source_address, destination_address,
@@ -327,7 +327,7 @@ class TestMleCryptoMaterialCreator(unittest.TestCase):
message_info.aux_sec_hdr = any_auxiliary_security_header()
message_info.aux_sec_hdr_bytes = convert_aux_sec_hdr_to_bytearray(message_info.aux_sec_hdr)
creator = net_crypto.MleCryptoMaterialCreator(master_key)
creator = net_crypto.MleCryptoMaterialCreator(network_key)
# WHEN
key, nonce, auth_data = creator.create_key_and_nonce_and_authenticated_data(message_info)
+2 -2
View File
@@ -1723,7 +1723,7 @@ class TestMleMessageFactory(unittest.TestCase):
0x27, 0xc2, 0x96, 0xf4, 0x9c, 0x65, 0x82, 0x97, 0xcf, 0x97, 0x35, 0x89, 0xc2
])
factory = config.create_default_mle_message_factory(master_key=config.DEFAULT_MASTER_KEY)
factory = config.create_default_mle_message_factory(network_key=config.DEFAULT_NETWORK_KEY)
# WHEN
actual_mle_message = factory.parse(io.BytesIO(data), message_info)
@@ -1773,7 +1773,7 @@ class TestMleMessageFactory(unittest.TestCase):
0x94, 0x01, 0x6d, 0x20, 0xdf, 0x30, 0x82, 0xf8, 0xbb, 0x34, 0x47, 0x42, 0x50, 0xe9, 0x41, 0xa7, 0x33, 0xa5
])
factory = config.create_default_mle_message_factory(master_key=config.DEFAULT_MASTER_KEY)
factory = config.create_default_mle_message_factory(network_key=config.DEFAULT_NETWORK_KEY)
# WHEN
actual_mle_message = factory.parse(io.BytesIO(data), message_info)
@@ -57,17 +57,17 @@ class SrpAutoStartMode(thread_cert.TestCase):
TOPOLOGY = {
CLIENT: {
'name': 'SRP_CLIENT',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
SERVER1: {
'name': 'SRP_SERVER1',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
SERVER2: {
'name': 'SRP_SERVER2',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
}
@@ -58,22 +58,22 @@ class SrpAutoStartMode(thread_cert.TestCase):
TOPOLOGY = {
CLIENT: {
'name': 'SRP_CLIENT',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
SERVER1: {
'name': 'SRP_SERVER1',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rn',
},
SERVER2: {
'name': 'SRP_SERVER2',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rn',
},
SERVER3: {
'name': 'SRP_SERVER3',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rn',
},
}
+2 -2
View File
@@ -57,12 +57,12 @@ class SrpRegisterSingleService(thread_cert.TestCase):
TOPOLOGY = {
SERVER: {
'name': 'SRP_SERVER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
CLIENT: {
'name': 'SRP_CLIENT',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
}
@@ -56,17 +56,17 @@ class SrpNameConflicts(thread_cert.TestCase):
TOPOLOGY = {
SERVER: {
'name': 'SRP_SERVER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
CLIENT1: {
'name': 'SRP_CLIENT1',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
CLIENT2: {
'name': 'SRP_CLIENT2',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
}
@@ -55,12 +55,12 @@ class SrpRegisterSingleService(thread_cert.TestCase):
TOPOLOGY = {
SERVER: {
'name': 'SRP_SERVER',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
CLIENT: {
'name': 'SRP_CLIENT',
'masterkey': '00112233445566778899aabbccddeeff',
'networkkey': '00112233445566778899aabbccddeeff',
'mode': 'rdn',
},
}
+6 -6
View File
@@ -168,7 +168,7 @@ class TestCase(NcpSupportMixin, unittest.TestCase):
if node.is_host:
continue
self.nodes[i].set_masterkey(binascii.hexlify(config.DEFAULT_MASTER_KEY).decode())
self.nodes[i].set_networkkey(binascii.hexlify(config.DEFAULT_NETWORK_KEY).decode())
self.nodes[i].set_panid(params['panid'])
self.nodes[i].set_mode(params['mode'])
@@ -176,8 +176,8 @@ class TestCase(NcpSupportMixin, unittest.TestCase):
self.nodes[i].set_preferred_partition_id(params['partition_id'])
if 'channel' in params:
self.nodes[i].set_channel(params['channel'])
if 'masterkey' in params:
self.nodes[i].set_masterkey(params['masterkey'])
if 'networkkey' in params:
self.nodes[i].set_networkkey(params['networkkey'])
if 'network_name' in params:
self.nodes[i].set_network_name(params['network_name'])
@@ -197,13 +197,13 @@ class TestCase(NcpSupportMixin, unittest.TestCase):
self.nodes[i].set_timeout(params['timeout'])
if 'active_dataset' in params:
if 'master_key' not in params['active_dataset']:
params['active_dataset']['master_key'] = binascii.hexlify(config.DEFAULT_MASTER_KEY).decode()
if 'network_key' not in params['active_dataset']:
params['active_dataset']['network_key'] = binascii.hexlify(config.DEFAULT_NETWORK_KEY).decode()
self.nodes[i].set_active_dataset(params['active_dataset']['timestamp'],
panid=params['active_dataset'].get('panid'),
channel=params['active_dataset'].get('channel'),
channel_mask=params['active_dataset'].get('channel_mask'),
master_key=params['active_dataset'].get('master_key'),
network_key=params['active_dataset'].get('network_key'),
security_policy=params['active_dataset'].get('security_policy'))
if 'pending_dataset' in params:
+15 -15
View File
@@ -995,29 +995,29 @@ class OpenThreadTHCI(object):
@API
def setNetworkKey(self, key):
"""set Thread Network master key
"""set Thread network key
Args:
key: Thread Network master key used in secure the MLE/802.15.4 packet
key: Thread network key used in secure the MLE/802.15.4 packet
Returns:
True: successful to set the Thread Network master key
False: fail to set the Thread Network master key
True: successful to set the Thread network key
False: fail to set the Thread network key
"""
masterKey = ''
networkKey = ''
print('%s call setNetworkKey' % self)
print(key)
try:
if not isinstance(key, str):
masterKey = self.__convertLongToHex(key, 32)
cmd = 'masterkey %s' % masterKey
datasetCmd = 'dataset masterkey %s' % masterKey
networkKey = self.__convertLongToHex(key, 32)
cmd = 'networkkey %s' % networkKey
datasetCmd = 'dataset networkkey %s' % networkKey
else:
masterKey = key
cmd = 'masterkey %s' % masterKey
datasetCmd = 'dataset masterkey %s' % masterKey
networkKey = key
cmd = 'networkkey %s' % networkKey
datasetCmd = 'dataset networkkey %s' % networkKey
self.networkKey = masterKey
self.networkKey = networkKey
self.hasActiveDatasetToCommit = True
return self.__executeCommand(cmd)[-1] == 'Done' and self.__executeCommand(datasetCmd)[-1] == 'Done'
except Exception as e:
@@ -1811,7 +1811,7 @@ class OpenThreadTHCI(object):
@API
def setKeySequenceCounter(self, iKeySequenceValue):
""" set the Key sequence counter corresponding to Thread Network master key
""" set the Key sequence counter corresponding to Thread network key
Args:
iKeySequenceValue: key sequence value
@@ -2656,7 +2656,7 @@ class OpenThreadTHCI(object):
cmd += str(sMeshLocalPrefix)
if xMasterKey is not None:
cmd += ' masterkey '
cmd += ' networkkey '
key = self.__convertLongToHex(xMasterKey, 32)
cmd += key
@@ -2833,7 +2833,7 @@ class OpenThreadTHCI(object):
cmd += str(xPanId)
if xMasterKey is not None:
cmd += ' masterkey '
cmd += ' networkkey '
key = self.__convertLongToHex(xMasterKey, 32)
cmd += key
+17 -17
View File
@@ -993,29 +993,29 @@ class OpenThread_WpanCtl(IThci):
return globalAddrs
def setNetworkKey(self, key):
"""set Thread Network master key
"""set Thread network key
Args:
key: Thread Network master key used in secure the MLE/802.15.4 packet
key: Thread network key used in secure the MLE/802.15.4 packet
Returns:
True: successful to set the Thread Network master key
False: fail to set the Thread Network master key
True: successful to set the Thread network key
False: fail to set the Thread network key
"""
masterKey = ''
networkKey = ''
print('%s call setNetworkKey' % self.port)
try:
if not isinstance(key, str):
masterKey = self.__convertLongToHex(key, 32)
cmd = self.wpan_cmd_prefix + 'setprop Network:Key %s' % masterKey
datasetCmd = self.wpan_cmd_prefix + 'setprop Dataset:MasterKey %s' % masterKey
networkKey = self.__convertLongToHex(key, 32)
cmd = self.wpan_cmd_prefix + 'setprop Network:Key %s' % networkKey
datasetCmd = self.wpan_cmd_prefix + 'setprop Dataset:NetworkKey %s' % networkKey
else:
masterKey = key
cmd = self.wpan_cmd_prefix + 'setprop Network:Key %s' % masterKey
datasetCmd = self.wpan_cmd_prefix + 'setprop Dataset:MasterKey %s' % masterKey
networkKey = key
cmd = self.wpan_cmd_prefix + 'setprop Network:Key %s' % networkKey
datasetCmd = self.wpan_cmd_prefix + 'setprop Dataset:NetworkKey %s' % networkKey
self.networkKey = masterKey
self.networkKey = networkKey
self.hasActiveDatasetToCommit = True
return self.__sendCommand(cmd)[0] != 'Fail' and self.__sendCommand(datasetCmd)[0] != 'Fail'
except Exception as e:
@@ -1705,7 +1705,7 @@ class OpenThread_WpanCtl(IThci):
ModuleHelper.WriteIntoDebugLogger('setKeepAliveTimeOut() Error: ' + str(e))
def setKeySequenceCounter(self, iKeySequenceValue):
""" set the Key sequence counter corresponding to Thread Network master key
""" set the Key sequence counter corresponding to Thread network key
Args:
iKeySequenceValue: key sequence value
@@ -2347,8 +2347,8 @@ class OpenThread_WpanCtl(IThci):
if xMasterKey is not None:
key = self.__convertLongToHex(xMasterKey, 32)
setMasterKeyCmd = self.wpan_cmd_prefix + 'setprop Dataset:MasterKey ' + key
if self.__sendCommand(setMasterKeyCmd)[0] == 'Fail':
setNetworkKeyCmd = self.wpan_cmd_prefix + 'setprop Dataset:NetworkKey ' + key
if self.__sendCommand(setNetworkKeyCmd)[0] == 'Fail':
return False
if xPanId is not None:
@@ -2543,8 +2543,8 @@ class OpenThread_WpanCtl(IThci):
if xMasterKey is not None:
key = self.__convertLongToHex(xMasterKey, 32)
setMasterKeyCmd = self.wpan_cmd_prefix + 'setprop Dataset:MasterKey ' + key
if self.__sendCommand(setMasterKeyCmd)[0] == 'Fail':
setNetworkKeyCmd = self.wpan_cmd_prefix + 'setprop Dataset:NetworkKey ' + key
if self.__sendCommand(setNetworkKeyCmd)[0] == 'Fail':
return False
if xPanId is not None:
+1 -1
View File
@@ -24,7 +24,7 @@ node2 = otci.connect_cli_serial("/dev/ttyACM0"))
# Start node1 to become Leader
node1.dataset_init_buffer()
node1.dataset_set_buffer(network_name='test', master_key='00112233445566778899aabbccddeeff', panid=0xface, channel=11)
node1.dataset_set_buffer(network_name='test', network_key='00112233445566778899aabbccddeeff', panid=0xface, channel=11)
node1.dataset_commit_buffer('active')
node1.ifconfig_up()
+21 -21
View File
@@ -362,14 +362,14 @@ class OTCI(object):
"""Get network name."""
return self.__parse_str(self.execute_command('networkname'))
def get_master_key(self) -> str:
"""Get the network master key."""
return self.__parse_master_key(self.execute_command('masterkey'))
def get_network_key(self) -> str:
"""Get the network network key."""
return self.__parse_network_key(self.execute_command('networkkey'))
def set_master_key(self, masterkey: str):
"""Set the network master key."""
self.__validate_master_key(masterkey)
self.execute_command(f'masterkey {masterkey}')
def set_network_key(self, networkkey: str):
"""Set the network network key."""
self.__validate_network_key(networkkey)
self.execute_command(f'networkkey {networkkey}')
def get_key_sequence_counter(self) -> int:
"""Get the Thread Key Sequence Counter."""
@@ -1652,7 +1652,7 @@ class OTCI(object):
# Channel Mask: 0x07fff800
# Ext PAN ID: 5c93ae980ff22d35
# Mesh Local Prefix: fdc7:55fe:6363:bd01::/64
# Master Key: d1a8348d59fb1fac1d6c4f95007d487a
# Network Key: d1a8348d59fb1fac1d6c4f95007d487a
# Network Name: OpenThread-7caa
# PAN ID: 0x7caa
# PSKc: 167d89fd169e439ca0b8266de248090f
@@ -1674,8 +1674,8 @@ class OTCI(object):
dataset['extpanid'] = val
elif key == 'Mesh Local Prefix':
dataset['mesh_local_prefix'] = val
elif key == 'Master Key':
dataset['masterkey'] = val
elif key == 'Network Key':
dataset['networkkey'] = val
elif key == 'Network Name':
dataset['network_name'] = val
elif key == 'PAN ID':
@@ -1706,7 +1706,7 @@ class OTCI(object):
channel_mask: int = None,
extpanid: str = None,
mesh_local_prefix: str = None,
master_key: str = None,
network_key: str = None,
network_name: str = None,
panid: int = None,
pskc: str = None,
@@ -1727,8 +1727,8 @@ class OTCI(object):
if mesh_local_prefix is not None:
self.execute_command(f'dataset meshlocalprefix {mesh_local_prefix}')
if master_key is not None:
self.execute_command(f'dataset masterkey {master_key}')
if network_key is not None:
self.execute_command(f'dataset networkkey {network_key}')
if network_name is not None:
self.execute_command(f'dataset networkname {self.__escape_escapable(network_name)}')
@@ -2261,21 +2261,21 @@ class OTCI(object):
return int(output[0], base)
def __parse_master_key(self, output: List[str]) -> str:
masterkey = self.__parse_str(output)
def __parse_network_key(self, output: List[str]) -> str:
networkkey = self.__parse_str(output)
try:
self.__validate_master_key(masterkey)
self.__validate_network_key(networkkey)
except ValueError:
raise UnexpectedCommandOutput(output)
return masterkey
return networkkey
def __validate_master_key(self, masterkey: str):
if len(masterkey) != 32:
raise ValueError(masterkey)
def __validate_network_key(self, networkkey: str):
if len(networkkey) != 32:
raise ValueError(networkkey)
int(masterkey, 16)
int(networkkey, 16)
def __parse_hex64b(self, output: List[str]) -> str:
extaddr = self.__parse_str(output)
+9 -9
View File
@@ -42,7 +42,7 @@ logging.basicConfig(level=logging.DEBUG)
TEST_CHANNEL = 22
TEST_NETWORK_NAME = 'OT CI'
TEST_PANID = 0xeeee
TEST_MASTERKEY = 'ffeeddccbbaa99887766554433221100'
TEST_NETWORKKEY = 'ffeeddccbbaa99887766554433221100'
REAL_DEVICE = int(os.getenv('REAL_DEVICE', '0'))
@@ -130,7 +130,7 @@ class TestOTCI(unittest.TestCase):
logging.info('leader eui64 = %r', leader.get_eui64())
logging.info('leader extpanid = %r', leader.get_extpanid())
logging.info('leader masterkey = %r', leader.get_master_key())
logging.info('leader networkkey = %r', leader.get_network_key())
extaddr = leader.get_extaddr()
self.assertEqual(16, len(extaddr))
@@ -141,8 +141,8 @@ class TestOTCI(unittest.TestCase):
leader.set_network_name(TEST_NETWORK_NAME)
leader.set_master_key(TEST_MASTERKEY)
self.assertEqual(TEST_MASTERKEY, leader.get_master_key())
leader.set_network_key(TEST_NETWORKKEY)
self.assertEqual(TEST_NETWORKKEY, leader.get_network_key())
leader.set_panid(TEST_PANID)
self.assertEqual(TEST_PANID, leader.get_panid())
@@ -507,7 +507,7 @@ class TestOTCI(unittest.TestCase):
def _test_otci_example(self, node1, node2):
node1.dataset_init_buffer()
node1.dataset_set_buffer(network_name='test',
master_key='00112233445566778899aabbccddeeff',
network_key='00112233445566778899aabbccddeeff',
panid=0xface,
channel=11)
node1.dataset_commit_buffer('active')
@@ -540,7 +540,7 @@ class TestOTCI(unittest.TestCase):
logging.info('leader eui64 = %r', leader.get_eui64())
logging.info('leader extpanid = %r', leader.get_extpanid())
logging.info('leader masterkey = %r', leader.get_master_key())
logging.info('leader networkkey = %r', leader.get_network_key())
extaddr = leader.get_extaddr()
self.assertEqual(16, len(extaddr))
@@ -551,8 +551,8 @@ class TestOTCI(unittest.TestCase):
leader.set_network_name(TEST_NETWORK_NAME)
leader.set_master_key(TEST_MASTERKEY)
self.assertEqual(TEST_MASTERKEY, leader.get_master_key())
leader.set_network_key(TEST_NETWORKKEY)
self.assertEqual(TEST_NETWORKKEY, leader.get_network_key())
leader.set_panid(TEST_PANID)
self.assertEqual(TEST_PANID, leader.get_panid())
@@ -579,7 +579,7 @@ class TestOTCI(unittest.TestCase):
commissioner.set_panid(TEST_PANID)
commissioner.set_network_name(TEST_NETWORK_NAME)
commissioner.set_router_selection_jitter(1)
commissioner.set_master_key(TEST_MASTERKEY)
commissioner.set_network_key(TEST_NETWORKKEY)
commissioner.thread_start()
commissioner.wait(5)