mirror of
https://github.com/AsamK/signal-cli
synced 2025-08-29 18:40:39 +00:00
Use custom SecureRandom instance
- Use NativePRNG algorithm instead of using SHA1PRNG if available - Register a custom security provider to use the same SecureRandom everywhere
This commit is contained in:
parent
cf972e5b6c
commit
5f2190713a
4 changed files with 88 additions and 14 deletions
|
@ -1,10 +1,8 @@
|
|||
package org.asamk.signal.manager;
|
||||
|
||||
import org.asamk.signal.util.RandomUtils;
|
||||
import org.whispersystems.signalservice.internal.util.Base64;
|
||||
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
|
||||
class KeyUtils {
|
||||
|
||||
private KeyUtils() {
|
||||
|
@ -33,15 +31,7 @@ class KeyUtils {
|
|||
|
||||
private static byte[] getSecretBytes(int size) {
|
||||
byte[] secret = new byte[size];
|
||||
getSecureRandom().nextBytes(secret);
|
||||
RandomUtils.getSecureRandom().nextBytes(secret);
|
||||
return secret;
|
||||
}
|
||||
|
||||
private static SecureRandom getSecureRandom() {
|
||||
try {
|
||||
return SecureRandom.getInstance("SHA1PRNG");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue