3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-04 15:20:09 +01:00

Another attempt to fix key generation

Dieser Commit ist enthalten in:
Tim203 2021-04-03 19:49:44 +02:00
Ursprung a5a849c059
Commit 23c3db28ef
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 064EE9F5BF7C3EE8

Datei anzeigen

@ -31,7 +31,6 @@ import javax.crypto.SecretKey;
import javax.crypto.spec.SecretKeySpec;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Locale;
public final class AesKeyProducer implements KeyProducer {
public static int KEY_SIZE = 128;
@ -58,11 +57,18 @@ public final class AesKeyProducer implements KeyProducer {
private SecureRandom getSecureRandom() throws NoSuchAlgorithmException {
// use Windows-PRNG for windows (default impl is SHA1PRNG)
// default impl for unix-like systems is NativePRNG.
if (System.getProperty("os.name").startsWith("Windows")) {
return SecureRandom.getInstance("Windows-PRNG");
} else {
return new SecureRandom();
try {
// 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
// prevent that if possible
return SecureRandom.getInstance("NativePRNGNonBlocking");
} catch (NoSuchAlgorithmException ignored) {
// at this point we just have to go with the default impl even if it blocks
return new SecureRandom();
}
}
}
}