Simplify access to SecureRandom

This shouldn't matter at all, but it's more "correct," and shows
my age less.
This commit is contained in:
Moxie Marlinspike
2019-03-15 15:31:52 -07:00
committed by Greyson Parrelli
parent 8aa185070b
commit a52c295a38
8 changed files with 84 additions and 114 deletions

View File

@@ -308,13 +308,9 @@ public class GroupDatabase extends Database {
public byte[] allocateGroupId() {
try {
byte[] groupId = new byte[16];
SecureRandom.getInstance("SHA1PRNG").nextBytes(groupId);
return groupId;
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
}
byte[] groupId = new byte[16];
new SecureRandom().nextBytes(groupId);
return groupId;
}
public static class Reader implements Closeable {

View File

@@ -71,7 +71,6 @@ import org.whispersystems.libsignal.util.guava.Optional;
import java.io.Closeable;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.Collections;
import java.util.HashMap;
@@ -1279,13 +1278,9 @@ public class MmsDatabase extends MessagingDatabase {
private final long threadId;
public OutgoingMessageReader(OutgoingMediaMessage message, long threadId) {
try {
this.message = message;
this.id = SecureRandom.getInstance("SHA1PRNG").nextLong();
this.threadId = threadId;
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
}
this.message = message;
this.id = new SecureRandom().nextLong();
this.threadId = threadId;
}
public MessageRecord getCurrent() {

View File

@@ -47,7 +47,6 @@ import org.thoughtcrime.securesms.util.TextSecurePreferences;
import org.whispersystems.libsignal.util.guava.Optional;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.util.LinkedList;
import java.util.List;
@@ -818,13 +817,9 @@ public class SmsDatabase extends MessagingDatabase {
private final long threadId;
public OutgoingMessageReader(OutgoingTextMessage message, long threadId) {
try {
this.message = message;
this.threadId = threadId;
this.id = SecureRandom.getInstance("SHA1PRNG").nextLong();
} catch (NoSuchAlgorithmException e) {
throw new AssertionError(e);
}
this.message = message;
this.threadId = threadId;
this.id = new SecureRandom().nextLong();
}
public MessageRecord getCurrent() {