aboutsummaryrefslogtreecommitdiff
path: root/java/android
diff options
context:
space:
mode:
authorylecollen <ylecollen@amdocs.com>2017-01-04 09:07:12 +0100
committerylecollen <ylecollen@amdocs.com>2017-01-04 09:07:12 +0100
commit570e8bbe939f04abc31a78eb99e5e0d3c461728f (patch)
tree846caaf8b44347bee5a26dd0c269803a1df01b67 /java/android
parentce9f67d5beb4cc46ded3f374afee6b737e505ff4 (diff)
use secureRandom in getRandomKey
Diffstat (limited to 'java/android')
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java16
1 files changed, 5 insertions, 11 deletions
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
index 287a9d2..d3c185f 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
@@ -20,7 +20,7 @@ package org.matrix.olm;
import android.text.TextUtils;
import android.util.Log;
-import java.util.Random;
+import java.security.SecureRandom;
/**
* Olm SDK helper class.
@@ -138,16 +138,10 @@ public class OlmUtility {
* @return string containing randoms integer values
*/
public static String getRandomKey() {
- String keyRetValue;
- Random rand = new Random();
- StringBuilder strBuilder = new StringBuilder();
-
- for(int i = 0; i< RANDOM_KEY_SIZE; i++) {
- strBuilder.append(rand.nextInt(RANDOM_RANGE));
- }
- keyRetValue = strBuilder.toString();
-
- return keyRetValue;
+ SecureRandom secureRandom = new SecureRandom();
+ byte[] buffer = new byte[RANDOM_KEY_SIZE];
+ secureRandom.nextBytes(buffer);
+ return new String(buffer);
}
/**