[java-idp-plugin-webauthn] branch main updated: Make algorithm explicit in secure random generator for userId
Phil Smart
philip.smart at jisc.ac.uk
Thu Aug 15 08:30:15 UTC 2024
This is an automated email from the git hooks/post-receive script.
philsmart pushed a commit to branch main
in repository java-idp-plugin-webauthn.
View the commit online:
http://git.shibboleth.net/view/?p=java-idp-plugin-webauthn.git;a=commit;h=77f6ff103862a7b1855ceca7a3933e97d36e1aeb
The following commit(s) were added to refs/heads/main by this push:
new 77f6ff1 Make algorithm explicit in secure random generator for userId
77f6ff1 is described below
commit 77f6ff103862a7b1855ceca7a3933e97d36e1aeb
Author: Phil Smart <philip.smart at jisc.ac.uk>
AuthorDate: Thu Aug 15 09:30:12 2024 +0100
Make algorithm explicit in secure random generator for userId
---
.../webauthn/admin/impl/RandomUserIdGenerator.java | 29 ++++++++++++++--------
1 file changed, 19 insertions(+), 10 deletions(-)
diff --git a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/RandomUserIdGenerator.java b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/RandomUserIdGenerator.java
index 773ddfb..b14ae4f 100644
--- a/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/RandomUserIdGenerator.java
+++ b/webauthn-impl/src/main/java/net/shibboleth/idp/plugin/authn/webauthn/admin/impl/RandomUserIdGenerator.java
@@ -28,24 +28,33 @@ import org.slf4j.Logger;
import net.shibboleth.shared.primitive.LoggerFactory;
/**
- * A user.id generator that generates a random 64 byte user.id. Returns {@code null} iff one can not be generated.
+ * A user.id generator that generates a random 64 byte user.id.
*/
@ThreadSafe
public final class RandomUserIdGenerator implements Function<ProfileRequestContext, byte[]>{
/** Class logger. */
@Nonnull private final Logger log = LoggerFactory.getLogger(RandomUserIdGenerator.class);
+
+ /** Secure random generator. */
+ @Nullable private final SecureRandom randomGenerator;
+
+ /** Constructor.*/
+ public RandomUserIdGenerator() {
+ try {
+ randomGenerator = SecureRandom.getInstance("SHA1PRNG");
+ } catch (final NoSuchAlgorithmException e) {
+ throw new RuntimeException("SHA1PRNG is required to be supported by the JVM but is not", e);
+ }
+ }
/** {@inheritDoc} */
@Override
- @Nullable public byte[] apply(final ProfileRequestContext input) {
- try {
- final byte[] bytes = new byte[64];
- SecureRandom.getInstanceStrong().nextBytes(bytes);
- return bytes;
- } catch (final NoSuchAlgorithmException e) {
- log.error("Unable to generate user.id", e);
- return null;
- }
+ @Nullable public byte[] apply(final ProfileRequestContext input) {
+ final SecureRandom randomGeneratorLocal = randomGenerator;
+ assert randomGeneratorLocal != null;
+ final byte[] bytes = new byte[64];
+ randomGeneratorLocal.nextBytes(bytes);
+ return bytes;
}
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list