You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@santuario.apache.org by co...@apache.org on 2022/07/08 05:42:49 UTC
[santuario-xml-security-java] branch master updated: SANTUARIO-589 - Enable configurable RNG in initialization of XMlSecurityConstants
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/santuario-xml-security-java.git
The following commit(s) were added to refs/heads/master by this push:
new 507b34e1 SANTUARIO-589 - Enable configurable RNG in initialization of XMlSecurityConstants
507b34e1 is described below
commit 507b34e1dd455a1347131fd574394c81dd2f0e38
Author: Isaac Jensen <is...@outlook.com>
AuthorDate: Thu Jul 7 22:42:44 2022 -0700
SANTUARIO-589 - Enable configurable RNG in initialization of XMlSecurityConstants
---
.../org/apache/xml/security/stax/ext/XMLSecurityConstants.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityConstants.java b/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityConstants.java
index bcacb7c3..7e2965bd 100644
--- a/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityConstants.java
+++ b/src/main/java/org/apache/xml/security/stax/ext/XMLSecurityConstants.java
@@ -43,12 +43,14 @@ public class XMLSecurityConstants {
public static final XMLOutputFactory xmlOutputFactoryNonRepairingNs;
private static final SecureRandom SECURE_RANDOM;
+ private static final String RANDOM_ALGORITHM_KEY = "org.apache.xml.security.securerandom.algorithm";
private static JAXBContext jaxbContext;
private static Schema schema;
static {
try {
- SECURE_RANDOM = SecureRandom.getInstance("SHA1PRNG");
+ String PrngAlgorithm = System.getProperty(RANDOM_ALGORITHM_KEY, SecureRandom.getInstanceStrong().getAlgorithm());
+ SECURE_RANDOM = SecureRandom.getInstance(PrngAlgorithm);
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException(e);
}
@@ -70,7 +72,8 @@ public class XMLSecurityConstants {
}
/**
- * Generate bytes of the given length using the SHA1PRNG algorithm. The SecureRandom
+ * Generate bytes of the given length using the supplied algorithm in RANDOM_ALGORITHM_KEY or,
+ * if not specified, use SecureRandom.getInstanceStrong(). The SecureRandom
* instance that backs this method is cached for efficiency.
*
* @return a byte array of the given length