mirror of
https://github.com/signalapp/Signal-Server.git
synced 2026-12-01 16:06:47 +00:00
Apparently I'm behind the times on this constructor
// FREEBIE
This commit is contained in:
1 parent
6fce69bbac
commit
54f25358eb
9 files changed
+26
-46
No files matched your search
@@ -38,12 +38,8 @@ public class AuthenticationCredentials {
|
||||
}
|
||||
|
||||
public AuthenticationCredentials(String authenticationToken) {
|
||||
try {
|
||||
this.salt = Math.abs(SecureRandom.getInstance("SHA1PRNG").nextInt()) + "";
|
||||
this.hashedAuthenticationToken = getHashedValue(salt, authenticationToken);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
this.salt = Math.abs(new SecureRandom().nextInt()) + "";
|
||||
this.hashedAuthenticationToken = getHashedValue(salt, authenticationToken);
|
||||
}
|
||||
|
||||
public String getHashedAuthenticationToken() {
|
||||
|
||||
@@ -25,7 +25,7 @@ public class TurnTokenGenerator {
|
||||
try {
|
||||
Mac mac = Mac.getInstance("HmacSHA1");
|
||||
long validUntilSeconds = (System.currentTimeMillis() + TimeUnit.DAYS.toMillis(1)) / 1000;
|
||||
long user = Math.abs(SecureRandom.getInstance("SHA1PRNG").nextInt());
|
||||
long user = Math.abs(new SecureRandom().nextInt());
|
||||
String userTime = validUntilSeconds + ":" + user;
|
||||
|
||||
mac.init(new SecretKeySpec(key, "HmacSHA1"));
|
||||
|
||||
@@ -360,16 +360,12 @@ public class AccountController {
|
||||
}
|
||||
|
||||
@VisibleForTesting protected VerificationCode generateVerificationCode(String number) {
|
||||
try {
|
||||
if (testDevices.containsKey(number)) {
|
||||
return new VerificationCode(testDevices.get(number));
|
||||
}
|
||||
|
||||
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||
int randomInt = 100000 + random.nextInt(900000);
|
||||
return new VerificationCode(randomInt);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
if (testDevices.containsKey(number)) {
|
||||
return new VerificationCode(testDevices.get(number));
|
||||
}
|
||||
|
||||
SecureRandom random = new SecureRandom();
|
||||
int randomInt = 100000 + random.nextInt(900000);
|
||||
return new VerificationCode(randomInt);
|
||||
}
|
||||
}
|
||||
+4
-8
@@ -103,14 +103,10 @@ public class AttachmentController {
|
||||
}
|
||||
|
||||
private long generateAttachmentId() {
|
||||
try {
|
||||
byte[] attachmentBytes = new byte[8];
|
||||
SecureRandom.getInstance("SHA1PRNG").nextBytes(attachmentBytes);
|
||||
byte[] attachmentBytes = new byte[8];
|
||||
new SecureRandom().nextBytes(attachmentBytes);
|
||||
|
||||
attachmentBytes[0] = (byte)(attachmentBytes[0] & 0x7F);
|
||||
return Conversions.byteArrayToLong(attachmentBytes);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new AssertionError(nsae);
|
||||
}
|
||||
attachmentBytes[0] = (byte)(attachmentBytes[0] & 0x7F);
|
||||
return Conversions.byteArrayToLong(attachmentBytes);
|
||||
}
|
||||
}
|
||||
@@ -205,12 +205,8 @@ public class DeviceController {
|
||||
}
|
||||
|
||||
@VisibleForTesting protected VerificationCode generateVerificationCode() {
|
||||
try {
|
||||
SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
|
||||
int randomInt = 100000 + random.nextInt(900000);
|
||||
return new VerificationCode(randomInt);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
SecureRandom random = new SecureRandom();
|
||||
int randomInt = 100000 + random.nextInt(900000);
|
||||
return new VerificationCode(randomInt);
|
||||
}
|
||||
}
|
||||
@@ -222,7 +222,7 @@ public class FederatedClient {
|
||||
trustManagerFactory.init(initializeTrustStore(peer.getName(), peer.getCertificate()));
|
||||
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, trustManagerFactory.getTrustManagers(), SecureRandom.getInstance("SHA1PRNG"));
|
||||
sslContext.init(null, trustManagerFactory.getTrustManagers(), new SecureRandom());
|
||||
|
||||
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(sslContext, new DefaultHostnameVerifier());
|
||||
Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register("https", sslConnectionSocketFactory).build();
|
||||
|
||||
@@ -22,11 +22,11 @@ public class ProvisioningAddress extends WebsocketAddress {
|
||||
public static ProvisioningAddress generate() {
|
||||
try {
|
||||
byte[] random = new byte[16];
|
||||
SecureRandom.getInstance("SHA1PRNG").nextBytes(random);
|
||||
new SecureRandom().nextBytes(random);
|
||||
|
||||
return new ProvisioningAddress(Base64.encodeBytesWithoutPadding(random)
|
||||
.replace('+', '-').replace('/', '_'), 0);
|
||||
} catch (NoSuchAlgorithmException | InvalidWebsocketAddressException e) {
|
||||
} catch (InvalidWebsocketAddressException e) {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class DeleteUserCommand extends EnvironmentCommand<WhisperServerConfigura
|
||||
|
||||
if (device.isPresent()) {
|
||||
byte[] random = new byte[16];
|
||||
SecureRandom.getInstance("SHA1PRNG").nextBytes(random);
|
||||
new SecureRandom().nextBytes(random);
|
||||
|
||||
device.get().setGcmId(null);
|
||||
device.get().setFetchesMessages(false);
|
||||
|
||||
Reference in new issue
Block a user