Skip to content

Commit

Permalink
Add validation for input string (reflecting review comments)
Browse files Browse the repository at this point in the history
Signed-off-by: Takahiro Nagao <nagao.takahiro@fujitsu.com>
  • Loading branch information
tnagao7 committed Dec 16, 2024
1 parent a5af583 commit b2a11d9
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,16 @@ private static byte[] getIvGCM() {
byte[] ivGCM = new byte[IV_GCM_LENGTH];
SecureRandom random = null;
String useStrongRNG = PrivilegedAccessHelper.getSystemProperty(SystemProperties.SECURITY_ENCRYPTOR_USE_STRONG_RANDOM_NUMBER_GENERATOR);
if (Boolean.parseBoolean(useStrongRNG)) {
if (useStrongRNG == null || useStrongRNG.equalsIgnoreCase("false")) {
random = new SecureRandom();
} else if (useStrongRNG.equalsIgnoreCase("true")) {
try {
random = SecureRandom.getInstanceStrong();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
} else {
random = new SecureRandom();
throw ValidationException.invalidBooleanValueForProperty(useStrongRNG, SystemProperties.SECURITY_ENCRYPTOR_USE_STRONG_RANDOM_NUMBER_GENERATOR);
}
random.nextBytes(ivGCM);
return ivGCM;
Expand Down

0 comments on commit b2a11d9

Please sign in to comment.