mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-05-08 17:29:02 +01:00
Use separate PNI key distribution endpoint instead of change number.
This commit is contained in:
+10
@@ -18,6 +18,7 @@ import org.signal.libsignal.zkgroup.profiles.ExpiringProfileKeyCredential;
|
||||
import org.signal.libsignal.zkgroup.profiles.ProfileKey;
|
||||
import org.whispersystems.signalservice.api.account.AccountAttributes;
|
||||
import org.whispersystems.signalservice.api.account.ChangePhoneNumberRequest;
|
||||
import org.whispersystems.signalservice.api.account.PniKeyDistributionRequest;
|
||||
import org.whispersystems.signalservice.api.account.PreKeyUpload;
|
||||
import org.whispersystems.signalservice.api.crypto.ProfileCipher;
|
||||
import org.whispersystems.signalservice.api.crypto.ProfileCipherOutputStream;
|
||||
@@ -651,6 +652,15 @@ public class SignalServiceAccountManager {
|
||||
this.pushServiceSocket.sendProvisioningMessage(deviceIdentifier, ciphertext);
|
||||
}
|
||||
|
||||
public ServiceResponse<VerifyAccountResponse> distributePniKeys(PniKeyDistributionRequest request) {
|
||||
try {
|
||||
VerifyAccountResponse response = this.pushServiceSocket.distributePniKeys(request);
|
||||
return ServiceResponse.forResult(response, 200, null);
|
||||
} catch (IOException e) {
|
||||
return ServiceResponse.forUnknownError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<DeviceInfo> getDevices() throws IOException {
|
||||
return this.pushServiceSocket.getDevices();
|
||||
}
|
||||
|
||||
+1
-1
@@ -708,7 +708,7 @@ public class SignalServiceMessageSender {
|
||||
* @param pniChangeNumber - Linked device specific updated PNI details
|
||||
* @return Encrypted {@link OutgoingPushMessage} to be included in the change number request sent to the server
|
||||
*/
|
||||
public @Nonnull OutgoingPushMessage getEncryptedSyncPniChangeNumberMessage(int deviceId, @Nonnull SyncMessage.PniChangeNumber pniChangeNumber)
|
||||
public @Nonnull OutgoingPushMessage getEncryptedSyncPniInitializeDeviceMessage(int deviceId, @Nonnull SyncMessage.PniChangeNumber pniChangeNumber)
|
||||
throws UntrustedIdentityException, IOException, InvalidKeyException
|
||||
{
|
||||
SyncMessage.Builder syncMessage = createSyncMessageBuilder().setPniChangeNumber(pniChangeNumber);
|
||||
|
||||
+70
@@ -0,0 +1,70 @@
|
||||
package org.whispersystems.signalservice.api.account;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
|
||||
import org.signal.libsignal.protocol.IdentityKey;
|
||||
import org.whispersystems.signalservice.api.push.SignedPreKeyEntity;
|
||||
import org.whispersystems.signalservice.internal.push.KyberPreKeyEntity;
|
||||
import org.whispersystems.signalservice.internal.push.OutgoingPushMessage;
|
||||
import org.whispersystems.signalservice.internal.util.JsonUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public final class PniKeyDistributionRequest {
|
||||
@JsonProperty
|
||||
@JsonSerialize(using = JsonUtil.IdentityKeySerializer.class)
|
||||
@JsonDeserialize(using = JsonUtil.IdentityKeyDeserializer.class)
|
||||
private IdentityKey pniIdentityKey;
|
||||
|
||||
@JsonProperty
|
||||
private List<OutgoingPushMessage> deviceMessages;
|
||||
|
||||
@JsonProperty
|
||||
private Map<String, SignedPreKeyEntity> devicePniSignedPrekeys;
|
||||
|
||||
@JsonProperty("devicePniPqLastResortPrekeys")
|
||||
private Map<String, KyberPreKeyEntity> devicePniLastResortKyberPrekeys;
|
||||
|
||||
@JsonProperty
|
||||
private Map<String, Integer> pniRegistrationIds;
|
||||
|
||||
@JsonProperty
|
||||
private boolean signatureValidOnEachSignedPreKey;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
public PniKeyDistributionRequest() {}
|
||||
|
||||
public PniKeyDistributionRequest(IdentityKey pniIdentityKey,
|
||||
List<OutgoingPushMessage> deviceMessages,
|
||||
Map<String, SignedPreKeyEntity> devicePniSignedPrekeys,
|
||||
Map<String, KyberPreKeyEntity> devicePniLastResortKyberPrekeys,
|
||||
Map<String, Integer> pniRegistrationIds,
|
||||
boolean signatureValidOnEachSignedPreKey)
|
||||
{
|
||||
this.pniIdentityKey = pniIdentityKey;
|
||||
this.deviceMessages = deviceMessages;
|
||||
this.devicePniSignedPrekeys = devicePniSignedPrekeys;
|
||||
this.devicePniLastResortKyberPrekeys = devicePniLastResortKyberPrekeys;
|
||||
this.pniRegistrationIds = pniRegistrationIds;
|
||||
this.signatureValidOnEachSignedPreKey = signatureValidOnEachSignedPreKey;
|
||||
}
|
||||
|
||||
public IdentityKey getPniIdentityKey() {
|
||||
return pniIdentityKey;
|
||||
}
|
||||
|
||||
public List<OutgoingPushMessage> getDeviceMessages() {
|
||||
return deviceMessages;
|
||||
}
|
||||
|
||||
public Map<String, SignedPreKeyEntity> getDevicePniSignedPrekeys() {
|
||||
return devicePniSignedPrekeys;
|
||||
}
|
||||
|
||||
public Map<String, Integer> getPniRegistrationIds() {
|
||||
return pniRegistrationIds;
|
||||
}
|
||||
}
|
||||
+9
@@ -40,6 +40,7 @@ import org.signal.storageservice.protos.groups.GroupExternalCredential;
|
||||
import org.signal.storageservice.protos.groups.GroupJoinInfo;
|
||||
import org.whispersystems.signalservice.api.account.AccountAttributes;
|
||||
import org.whispersystems.signalservice.api.account.ChangePhoneNumberRequest;
|
||||
import org.whispersystems.signalservice.api.account.PniKeyDistributionRequest;
|
||||
import org.whispersystems.signalservice.api.account.PreKeyUpload;
|
||||
import org.whispersystems.signalservice.api.crypto.UnidentifiedAccess;
|
||||
import org.whispersystems.signalservice.api.groupsv2.CredentialResponse;
|
||||
@@ -216,6 +217,7 @@ public class PushServiceSocket {
|
||||
private static final String CHANGE_NUMBER_PATH = "/v2/accounts/number";
|
||||
private static final String IDENTIFIER_REGISTERED_PATH = "/v1/accounts/account/%s";
|
||||
private static final String REQUEST_ACCOUNT_DATA_PATH = "/v2/accounts/data_report";
|
||||
private static final String PNI_KEY_DISTRUBTION_PATH = "/v2/accounts/phone_number_identity_key_distribution";
|
||||
|
||||
private static final String PREKEY_METADATA_PATH = "/v2/keys?identity=%s";
|
||||
private static final String PREKEY_PATH = "/v2/keys?identity=%s";
|
||||
@@ -448,6 +450,13 @@ public class PushServiceSocket {
|
||||
return JsonUtil.fromJson(responseBody, VerifyAccountResponse.class);
|
||||
}
|
||||
|
||||
public VerifyAccountResponse distributePniKeys(@NonNull PniKeyDistributionRequest distributionRequest) throws IOException {
|
||||
String request = JsonUtil.toJson(distributionRequest);
|
||||
String response = makeServiceRequest(PNI_KEY_DISTRUBTION_PATH, "PUT", request);
|
||||
|
||||
return JsonUtil.fromJson(response, VerifyAccountResponse.class);
|
||||
}
|
||||
|
||||
public void setAccountAttributes(@Nonnull AccountAttributes accountAttributes)
|
||||
throws IOException
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user