java.lang.Object
org.openremote.agent.protocol.bluetooth.mesh.NetworkKey
All Implemented Interfaces:
Cloneable

public final class NetworkKey extends Object
Wrapper class for network 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

      protected String meshUuid
    • keyIndex

      protected int keyIndex
    • name

      protected String 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 index
      key - 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)
      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

      public SecureUtils.K2Output 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

      public String 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

      public NetworkKey clone() throws CloneNotSupportedException
      Throws:
      CloneNotSupportedException
    • distributeKey

      protected boolean distributeKey(@NotNull @jakarta.validation.constraints.NotNull byte[] newKey) throws IllegalArgumentException
      Updates the currently used key with the newKey and sets the currently used key as the oldKey
      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

      public SecureUtils.K2Output getDerivatives()
      Returns the derivatives from the network key
      Returns:
      SecureUtils.K2Output
    • getOldDerivatives

      public 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

      public String getMeshUuid()
      Returns the meshUuid of the Mesh network
      Returns:
      String meshUuid
    • setMeshUuid

      public void setMeshUuid(String meshUuid)
      Sets the meshUuid of the mesh network to this application key
      Parameters:
      meshUuid - mesh network meshUuid
    • getName

      public String getName()
      Returns a friendly name of the application key
      Returns:
      string containing the name
    • setName

      public void setName(@NotNull @NotNull String name) throws IllegalArgumentException
      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

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • valid

      protected boolean valid(@NotNull @jakarta.validation.constraints.NotNull byte[] key)