Class SecureUtils
java.lang.Object
org.openremote.agent.protocol.bluetooth.mesh.utils.SecureUtils
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Output mask for K4static final byte[]
K2 Master inputstatic final Logger
protected static final byte[]
static int
static final byte[]
Used to calculate the confirmation keystatic final byte[]
Used to calculate the device keystatic final byte[]
Used to calculate the session keystatic final byte[]
Used to calculate the session nonceprotected static final byte[]
static final byte[]
Salt input for K2static final byte[]
Salt input for K3static final byte[]
Input for K3 datastatic final byte[]
Salt input for K4static final byte[]
Input for K4 data -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]
calculateAuthValueSecureNetBeacon
(byte[] n, int flags, byte[] networkId, int ivIndex) Calculates the authentication value of secure network beaconstatic byte[]
calculateBeaconKey
(byte[] n) Calculates the beacon keystatic byte[]
calculateCMAC
(byte[] data, byte[] key) static byte[]
calculateHash
(byte[] identityKey, byte[] random, byte[] src) Calculates hash value for advertising with node idstatic byte[]
calculateIdentityKey
(byte[] n) Calculates the identity keystatic byte[]
calculateK1
(byte[] ecdh, byte[] confirmationSalt, byte[] text) static SecureUtils.K2Output
calculateK2
(byte[] data, byte[] p) Calculate k2static byte[]
calculateK3
(byte[] n) Calculate k3static byte
calculateK4
(byte[] n) Calculate k4static byte[]
calculateSalt
(byte[] data) static byte[]
calculateSecureNetworkBeacon
(byte[] n, int beaconType, int flags, byte[] networkId, int ivIndex) Calculates the secure network beaconstatic SecureNetworkBeacon
createSecureNetworkBeacon
(byte[] n, int flags, byte[] networkId, int ivIndex) Creates the secure network beaconstatic byte[]
decryptCCM
(@jakarta.validation.constraints.NotNull byte[] data, @jakarta.validation.constraints.NotNull byte[] key, @jakarta.validation.constraints.NotNull byte[] nonce, @jakarta.validation.constraints.NotNull byte[] additionalData, int micSize) static byte[]
decryptCCM
(@jakarta.validation.constraints.NotNull byte[] data, @jakarta.validation.constraints.NotNull byte[] key, @jakarta.validation.constraints.NotNull byte[] nonce, int micSize) static byte[]
encryptCCM
(@jakarta.validation.constraints.NotNull byte[] data, @jakarta.validation.constraints.NotNull byte[] key, @jakarta.validation.constraints.NotNull byte[] nonce, @jakarta.validation.constraints.NotNull byte[] additionalData, int micSize) static byte[]
encryptCCM
(@jakarta.validation.constraints.NotNull byte[] data, @jakarta.validation.constraints.NotNull byte[] key, @jakarta.validation.constraints.NotNull byte[] nonce, int micSize) static byte[]
encryptWithAES
(byte[] data, byte[] key) static String
static String
static byte[]
static int
getNetMicLength
(int ctl) static int
getTransMicLength
(int aszmic) Gets the transport MIC length based on the aszmic value
-
Field Details
-
LOG
-
PRCK
public static final byte[] PRCKUsed to calculate the confirmation key -
PRSK
public static final byte[] PRSKUsed to calculate the session key -
PRSN
public static final byte[] PRSNUsed to calculate the session nonce -
PRDK
public static final byte[] PRDKUsed to calculate the device key -
K2_MASTER_INPUT
public static final byte[] K2_MASTER_INPUTK2 Master input -
SMK2
public static final byte[] SMK2Salt input for K2 -
SMK3
public static final byte[] SMK3Salt input for K3 -
SMK3_DATA
public static final byte[] SMK3_DATAInput for K3 data -
SMK4
public static final byte[] SMK4Salt input for K4 -
SMK4_DATA
public static final byte[] SMK4_DATAInput for K4 data -
ENC_K4_OUTPUT_MASK
public static final int ENC_K4_OUTPUT_MASKOutput mask for K4- See Also:
-
SALT_KEY
protected static final byte[] SALT_KEY -
NONCE_PADDING
protected static final byte[] NONCE_PADDING -
NRF_MESH_KEY_SIZE
public static int NRF_MESH_KEY_SIZE
-
-
Constructor Details
-
SecureUtils
public SecureUtils()
-
-
Method Details
-
generateRandomNumber
public static byte[] generateRandomNumber() -
generateRandomNetworkKey
-
generateRandomApplicationKey
-
calculateSalt
public static byte[] calculateSalt(byte[] data) -
calculateCMAC
public static byte[] calculateCMAC(byte[] data, byte[] key) -
encryptCCM
public static byte[] encryptCCM(@NotNull @jakarta.validation.constraints.NotNull byte[] data, @NotNull @jakarta.validation.constraints.NotNull byte[] key, @NotNull @jakarta.validation.constraints.NotNull byte[] nonce, int micSize) -
encryptCCM
public static byte[] encryptCCM(@NotNull @jakarta.validation.constraints.NotNull byte[] data, @NotNull @jakarta.validation.constraints.NotNull byte[] key, @NotNull @jakarta.validation.constraints.NotNull byte[] nonce, @NotNull @jakarta.validation.constraints.NotNull byte[] additionalData, int micSize) -
decryptCCM
public static byte[] decryptCCM(@NotNull @jakarta.validation.constraints.NotNull byte[] data, @NotNull @jakarta.validation.constraints.NotNull byte[] key, @NotNull @jakarta.validation.constraints.NotNull byte[] nonce, int micSize) throws org.bouncycastle.crypto.InvalidCipherTextException - Throws:
org.bouncycastle.crypto.InvalidCipherTextException
-
decryptCCM
public static byte[] decryptCCM(@NotNull @jakarta.validation.constraints.NotNull byte[] data, @NotNull @jakarta.validation.constraints.NotNull byte[] key, @NotNull @jakarta.validation.constraints.NotNull byte[] nonce, @NotNull @jakarta.validation.constraints.NotNull byte[] additionalData, int micSize) throws org.bouncycastle.crypto.InvalidCipherTextException - Throws:
org.bouncycastle.crypto.InvalidCipherTextException
-
calculateK1
public static byte[] calculateK1(byte[] ecdh, byte[] confirmationSalt, byte[] text) -
calculateK2
Calculate k2- Parameters:
data
- network keyp
- master input
-
calculateK3
public static byte[] calculateK3(byte[] n) Calculate k3- Parameters:
n
- network key
-
calculateK4
public static byte calculateK4(byte[] n) Calculate k4- Parameters:
n
- key
-
calculateIdentityKey
public static byte[] calculateIdentityKey(byte[] n) Calculates the identity key- Parameters:
n
- network key- Returns:
- hash value
-
calculateBeaconKey
public static byte[] calculateBeaconKey(byte[] n) Calculates the beacon key- Parameters:
n
- network key- Returns:
- hash value
-
calculateAuthValueSecureNetBeacon
public static byte[] calculateAuthValueSecureNetBeacon(byte[] n, int flags, byte[] networkId, int ivIndex) Calculates the authentication value of secure network beacon- Parameters:
n
- network keyflags
- flagsnetworkId
- network id of the networkivIndex
- ivindex of the network
-
createSecureNetworkBeacon
public static SecureNetworkBeacon createSecureNetworkBeacon(byte[] n, int flags, byte[] networkId, int ivIndex) Creates the secure network beacon- Parameters:
n
- network keyflags
- network flags, this represents the current state of hte network if key refresh/iv update is ongoing or completenetworkId
- unique id of the networkivIndex
- iv index of the network
-
calculateSecureNetworkBeacon
public static byte[] calculateSecureNetworkBeacon(byte[] n, int beaconType, int flags, byte[] networkId, int ivIndex) Calculates the secure network beacon- Parameters:
n
- network keyflags
- network flags, this represents the current state of hte network if key refresh/iv update is ongoing or completenetworkId
- unique id of the networkivIndex
- iv index of the network
-
calculateHash
public static byte[] calculateHash(byte[] identityKey, byte[] random, byte[] src) Calculates hash value for advertising with node id- Parameters:
identityKey
- resolving identity keyrandom
- 64-bit random valuesrc
- unicast address of the node- Returns:
- hash value
-
encryptWithAES
public static byte[] encryptWithAES(byte[] data, byte[] key) -
getNetMicLength
public static int getNetMicLength(int ctl) -
getTransMicLength
public static int getTransMicLength(int aszmic) Gets the transport MIC length based on the aszmic value- Parameters:
aszmic
- application size message integrity check
-