Skip to content

Commit

Permalink
Change random key generator to use secure random generator (zsmartsys…
Browse files Browse the repository at this point in the history
…tems#1408)

Signed-off-by: Chris Jackson <[email protected]>
  • Loading branch information
cdjackson authored and charbopassman committed Jul 26, 2024
1 parent 6e0018d commit 2f0c31f
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/
package com.zsmartsystems.zigbee.security;

import java.security.SecureRandom;
import java.util.Arrays;

import com.zsmartsystems.zigbee.IeeeAddress;
Expand Down Expand Up @@ -245,9 +246,10 @@ public String toString() {
* @return {@link ZigBeeKey} containing a random 128 bit key
*/
public static ZigBeeKey createRandom() {
SecureRandom secureRandom = new SecureRandom();
int key[] = new int[16];
for (int cnt = 0; cnt < 16; cnt++) {
key[cnt] = (int) Math.floor((Math.random() * 255));
key[cnt] = secureRandom.nextInt(256);
}

return new ZigBeeKey(key);
Expand Down

0 comments on commit 2f0c31f

Please sign in to comment.