mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-12-22 22:45:04 +01:00
Update AesKeyProducer.java (#4211)
This commit is contained in:
parent
3fa35b2cb9
commit
6b67e43f84
1 changed files with 9 additions and 8 deletions
|
@ -55,19 +55,20 @@ public final class AesKeyProducer implements KeyProducer {
|
||||||
}
|
}
|
||||||
|
|
||||||
private SecureRandom secureRandom() throws NoSuchAlgorithmException {
|
private SecureRandom secureRandom() throws NoSuchAlgorithmException {
|
||||||
|
try {
|
||||||
// use Windows-PRNG for windows (default impl is SHA1PRNG)
|
// use Windows-PRNG for windows (default impl is SHA1PRNG)
|
||||||
if (System.getProperty("os.name").startsWith("Windows")) {
|
if (System.getProperty("os.name").startsWith("Windows")) {
|
||||||
return SecureRandom.getInstance("Windows-PRNG");
|
return SecureRandom.getInstance("Windows-PRNG");
|
||||||
} else {
|
} else {
|
||||||
try {
|
|
||||||
// NativePRNG (which should be the default on unix-systems) can still block your
|
// NativePRNG (which should be the default on unix-systems) can still block your
|
||||||
// system. Even though it isn't as bad as NativePRNGBlocking, we still try to
|
// system. Even though it isn't as bad as NativePRNGBlocking, we still try to
|
||||||
// prevent that if possible
|
// prevent that if possible
|
||||||
return SecureRandom.getInstance("NativePRNGNonBlocking");
|
return SecureRandom.getInstance("NativePRNGNonBlocking");
|
||||||
|
|
||||||
|
}
|
||||||
} catch (NoSuchAlgorithmException ignored) {
|
} catch (NoSuchAlgorithmException ignored) {
|
||||||
// at this point we just have to go with the default impl even if it blocks
|
// Fall back to the default impl as we couldn't load any others
|
||||||
return new SecureRandom();
|
return new SecureRandom();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue