-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ELY-2731 Use SecureRandom instead of ThreadLocalRandom #2119
Conversation
password/impl/src/test/java/org/wildfly/security/password/impl/PasswordUtilTest.java
Show resolved
Hide resolved
password/impl/src/main/java/org/wildfly/security/password/impl/PasswordUtil.java
Outdated
Show resolved
Hide resolved
password/impl/src/main/java/org/wildfly/security/password/impl/PasswordUtil.java
Outdated
Show resolved
Hide resolved
@TomasHofman Can you make the requested changes? Thanks! |
Sorry, lost track of this. I updated the PR. One thing - I'm looking at the wildfly-common
and then the
It looks to me the printed message is wrong, and prints the opposite of the expected value. In the Or maybe it's just to early for me. |
Looking at the JavaDoc for SecureRandom, yes the class itself is thread safe and can be accessed by multiple threads concurrently: https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/security/SecureRandom.html BUT if the underlying Provider does not declare it is thread safe it will introduce locking.on accessing the provider. I don't know if it will be better or worse but I wonder if Elytron could have it's on ThreadLocalSecureRandom - the reason for the ThreadLocal model is you know your instance is only going to be accessed by a single thread so you are not waiting on locks held by other threads. The down side being you end up with one SecureRandom per thread but is this an issue? |
73d1a8b
to
0dd3c62
Compare
I updated the PR - added a publicly accessible ThreadLocalSecureRandom class. I guess since the ThreadLocal model was there in the first place, it's probably safer to stick to it. I think you are able to asses the performance implication better than me. My feeling originally was that the random bytes generation in practice would not be as heavily used for this to cause performance issues, but whether that's true or not, there's no reason to introduce bottlenecks that do not need to be there. |
password/impl/src/main/java/org/wildfly/security/password/impl/ThreadLocalSecureRandom.java
Outdated
Show resolved
Hide resolved
@ivassile if you can add a review I think with one more change from @TomasHofman I can merge today |
0dd3c62
to
6917c62
Compare
I have replaced this with #2189 to get us some better CI results. |
Issue: https://issues.redhat.com/browse/ELY-2731