Skip to content
This repository was archived by the owner on Apr 10, 2025. It is now read-only.

Commit 8c4f64b

Browse files
authored
SecurityAPICommons change SecureRandom to a non blocking one (#42)
1 parent e21f714 commit 8c4f64b

File tree

1 file changed

+9
-17
lines changed

1 file changed

+9
-17
lines changed

SecurityAPICommons/src/main/java/com/genexus/securityapicommons/keys/SymmetricKeyGenerator.java

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.genexus.securityapicommons.keys;
22

3-
import java.security.NoSuchAlgorithmException;
43
import java.security.SecureRandom;
54

65
import com.genexus.securityapicommons.commons.SecurityAPIObject;
@@ -20,10 +19,8 @@ public SymmetricKeyGenerator() {
2019
/******** EXTERNAL OBJECT PUBLIC METHODS - BEGIN ********/
2120

2221
/**
23-
* @param symmetricKeyType
24-
* String
25-
* @param length
26-
* result key length
22+
* @param symmetricKeyType String
23+
* @param length result key length
2724
* @return String Hexa fixed length secure random generated key
2825
*/
2926
public String doGenerateKey(String symmetricKeyType, int length) {
@@ -36,10 +33,8 @@ public String doGenerateKey(String symmetricKeyType, int length) {
3633
}
3734

3835
/**
39-
* @param symmetricKeyType
40-
* String
41-
* @param length
42-
* result IV length
36+
* @param symmetricKeyType String
37+
* @param length result IV length
4338
*
4439
* @return String Hexa fixed length secure random generated IV
4540
*/
@@ -49,10 +44,8 @@ public String doGenerateIV(String symmetricKeyType, int length) {
4944
}
5045

5146
/**
52-
* @param symmetricKeyType
53-
* String
54-
* @param length
55-
* result nonce length
47+
* @param symmetricKeyType String
48+
* @param length result nonce length
5649
* @return String Hexa fixed length secure random generated nonce
5750
*/
5851
public String doGenerateNonce(String symmetricKeyType, int length) {
@@ -62,16 +55,15 @@ public String doGenerateNonce(String symmetricKeyType, int length) {
6255
/******** EXTERNAL OBJECT PUBLIC METHODS - END ********/
6356

6457
/**
65-
* @param length
66-
* int bits result key length on bits
58+
* @param length int bits result key length on bits
6759
* @return String Hexa fixed length secure random generated key
6860
*/
6961
private String genericKeyGenerator(int length) {
7062

7163
SecureRandom random = null;
7264
try {
73-
random = SecureRandom.getInstanceStrong();
74-
} catch (NoSuchAlgorithmException e) {
65+
random = new SecureRandom();
66+
} catch (Exception e) {
7567
this.error.setError("SK004", "Key generation error");
7668
e.printStackTrace();
7769
}

0 commit comments

Comments
 (0)