Class NetworkKey
java.lang.Object
org.openremote.agent.protocol.bluetooth.mesh.NetworkKey
- All Implemented Interfaces:
Cloneable
Wrapper class for network key
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNetworkKey
(int keyIndex, @jakarta.validation.constraints.NotNull byte[] key) Constructs a NetworkKey object with a given key index and network key -
Method Summary
Modifier and TypeMethodDescriptionclone()
protected boolean
distributeKey
(@jakarta.validation.constraints.NotNull byte[] newKey) boolean
Returns the derivatives from the network keyint
getId()
byte[]
Returns the identity key derived from the current keybyte[]
getKey()
Returns the application keyint
Returns the application key indexReturns the meshUuid of the Mesh networkgetName()
Returns a friendly name of the application keyprotected byte[]
Returns the derivatives from the old network keybyte[]
Returns the identity key derived from the Old Keybyte[]
Returns the old app keyprotected byte[]
int
getPhase()
Returns the key refresh phase of the network keyReturns the current phase descriptionlong
Returns the timestamp of the phase changeReturns the NetworkKey based on the key refresh procedure phase.byte[]
Returns the NetworkKey based on the key refresh procedure phase.boolean
Uses min securityprotected boolean
Revokes old key by switching the phase to {KEY_DISTRIBUTION or USING_NEW_KEYS}void
setId
(int id) void
setKey
(@jakarta.validation.constraints.NotNull byte[] key) Sets a network key.void
setKeyIndex
(int keyIndex) Sets the key index of network keyvoid
setMeshUuid
(String meshUuid) Sets the meshUuid of the mesh network to this application keyvoid
setMinSecurity
(boolean minSecurity) Sets the minimum security.void
Sets a friendly name of the application keyvoid
setOldKey
(byte[] oldKey) Set the old keyvoid
setPhase
(int phase) void
setTimestamp
(long timestamp) Set the timestamp when the the phase change happenedprotected boolean
Switch to New Key.protected boolean
valid
(@jakarta.validation.constraints.NotNull byte[] key)
-
Field Details
-
NORMAL_OPERATION
public static final int NORMAL_OPERATION- See Also:
-
KEY_DISTRIBUTION
public static final int KEY_DISTRIBUTION- See Also:
-
USING_NEW_KEYS
public static final int USING_NEW_KEYS- See Also:
-
USE_NEW_KEYS
public static final int USE_NEW_KEYS- See Also:
-
REVOKE_OLD_KEYS
public static final int REVOKE_OLD_KEYS- See Also:
-
id
protected int id -
meshUuid
-
keyIndex
protected int keyIndex -
name
-
key
protected byte[] key -
oldKey
protected byte[] oldKey
-
-
Constructor Details
-
NetworkKey
public NetworkKey(int keyIndex, @NotNull @jakarta.validation.constraints.NotNull byte[] key) Constructs a NetworkKey object with a given key index and network key- Parameters:
keyIndex
- 12-bit network key indexkey
- 16-byte network key
-
-
Method Details
-
getPhase
public int getPhase()Returns the key refresh phase of the network key- Returns:
- int phase
-
setPhase
public void setPhase(int phase) -
setKey
public void setKey(@NotNull @jakarta.validation.constraints.NotNull byte[] key) Sets a network key.In order to change the key call
BaseMeshNetwork.updateNetKey(NetworkKey, String)
orBaseMeshNetwork.updateAppKey(ApplicationKey, String)
)}}- Parameters:
key
- 16-byte network key
-
setOldKey
public void setOldKey(byte[] oldKey) Set the old key- Parameters:
oldKey
- old app key
-
getTxNetworkKey
public byte[] getTxNetworkKey()Returns the NetworkKey based on the key refresh procedure phase.- Returns:
- key
-
getTxDerivatives
Returns the NetworkKey based on the key refresh procedure phase.- Returns:
- key
-
isMinSecurity
public boolean isMinSecurity()Uses min security- Returns:
- true if minimum security or false otherwise
-
setMinSecurity
public void setMinSecurity(boolean minSecurity) Sets the minimum security.- Parameters:
minSecurity
- true if minimum security or false if insecure.
-
getIdentityKey
public byte[] getIdentityKey()Returns the identity key derived from the current key -
getOldIdentityKey
public byte[] getOldIdentityKey()Returns the identity key derived from the Old Key -
getTimestamp
public long getTimestamp()Returns the timestamp of the phase change- Returns:
- timestamp
-
getPhaseDescription
Returns the current phase description -
setTimestamp
public void setTimestamp(long timestamp) Set the timestamp when the the phase change happened- Parameters:
timestamp
- timestamp
-
clone
- Throws:
CloneNotSupportedException
-
distributeKey
protected boolean distributeKey(@NotNull @jakarta.validation.constraints.NotNull byte[] newKey) throws IllegalArgumentException - Parameters:
newKey
- New NetworkKey value- Returns:
- true if successful or false otherwise
- Throws:
IllegalArgumentException
- if a NetworkKey distribution is attempted twice with different key values during a single Key refresh procedure
-
switchToNewKey
protected boolean switchToNewKey()Switch to New Key.- Returns:
- true if successful or false otherwise.
-
revokeOldKey
protected boolean revokeOldKey()Revokes old key by switching the phase to {KEY_DISTRIBUTION or USING_NEW_KEYS}- Returns:
- true if successful or false otherwise.
-
getNetworkId
protected byte[] getNetworkId() -
getOldNetworkId
protected byte[] getOldNetworkId() -
getDerivatives
Returns the derivatives from the network key- Returns:
SecureUtils.K2Output
-
getOldDerivatives
Returns the derivatives from the old network key- Returns:
SecureUtils.K2Output
-
getId
public int getId() -
setId
public void setId(int id) -
getMeshUuid
Returns the meshUuid of the Mesh network- Returns:
- String meshUuid
-
setMeshUuid
Sets the meshUuid of the mesh network to this application key- Parameters:
meshUuid
- mesh network meshUuid
-
getName
Returns a friendly name of the application key- Returns:
- string containing the name
-
setName
Sets a friendly name of the application key- Parameters:
name
- friendly name for the application key- Throws:
IllegalArgumentException
-
getKey
public byte[] getKey()Returns the application key- Returns:
- 16 byte application key
-
getKeyIndex
public int getKeyIndex()Returns the application key index- Returns:
- key index
-
setKeyIndex
public void setKeyIndex(int keyIndex) Sets the key index of network key- Parameters:
keyIndex
- index
-
getOldKey
public byte[] getOldKey()Returns the old app key- Returns:
- old key
-
equals
-
valid
protected boolean valid(@NotNull @jakarta.validation.constraints.NotNull byte[] key)
-