Search in sources :

Example 1 with PrimaryProvisioningCipher

use of org.whispersystems.signalservice.internal.crypto.PrimaryProvisioningCipher in project Signal-Android by signalapp.

the class SignalServiceAccountManager method addDevice.

public void addDevice(String deviceIdentifier, ECPublicKey deviceKey, IdentityKeyPair aciIdentityKeyPair, IdentityKeyPair pniIdentityKeyPair, ProfileKey profileKey, String code) throws InvalidKeyException, IOException {
    String e164 = credentials.getE164();
    ACI aci = credentials.getAci();
    PNI pni = credentials.getPni();
    Preconditions.checkArgument(e164 != null, "Missing e164!");
    Preconditions.checkArgument(aci != null, "Missing ACI!");
    Preconditions.checkArgument(pni != null, "Missing PNI!");
    PrimaryProvisioningCipher cipher = new PrimaryProvisioningCipher(deviceKey);
    ProvisionMessage.Builder message = ProvisionMessage.newBuilder().setAciIdentityKeyPublic(ByteString.copyFrom(aciIdentityKeyPair.getPublicKey().serialize())).setAciIdentityKeyPrivate(ByteString.copyFrom(aciIdentityKeyPair.getPrivateKey().serialize())).setPniIdentityKeyPublic(ByteString.copyFrom(pniIdentityKeyPair.getPublicKey().serialize())).setPniIdentityKeyPrivate(ByteString.copyFrom(pniIdentityKeyPair.getPrivateKey().serialize())).setAci(aci.toString()).setPni(pni.toString()).setNumber(e164).setProfileKey(ByteString.copyFrom(profileKey.serialize())).setProvisioningCode(code).setProvisioningVersion(ProvisioningVersion.CURRENT_VALUE);
    byte[] ciphertext = cipher.encrypt(message.build());
    this.pushServiceSocket.sendProvisioningMessage(deviceIdentifier, ciphertext);
}
Also used : ProvisionMessage(org.whispersystems.signalservice.internal.push.ProvisioningProtos.ProvisionMessage) PrimaryProvisioningCipher(org.whispersystems.signalservice.internal.crypto.PrimaryProvisioningCipher) ACI(org.whispersystems.signalservice.api.push.ACI) PNI(org.whispersystems.signalservice.api.push.PNI) ByteString(com.google.protobuf.ByteString)

Example 2 with PrimaryProvisioningCipher

use of org.whispersystems.signalservice.internal.crypto.PrimaryProvisioningCipher in project Signal-Android by WhisperSystems.

the class SignalServiceAccountManager method addDevice.

public void addDevice(String deviceIdentifier, ECPublicKey deviceKey, IdentityKeyPair aciIdentityKeyPair, IdentityKeyPair pniIdentityKeyPair, ProfileKey profileKey, String code) throws InvalidKeyException, IOException {
    String e164 = credentials.getE164();
    ACI aci = credentials.getAci();
    PNI pni = credentials.getPni();
    Preconditions.checkArgument(e164 != null, "Missing e164!");
    Preconditions.checkArgument(aci != null, "Missing ACI!");
    Preconditions.checkArgument(pni != null, "Missing PNI!");
    PrimaryProvisioningCipher cipher = new PrimaryProvisioningCipher(deviceKey);
    ProvisionMessage.Builder message = ProvisionMessage.newBuilder().setAciIdentityKeyPublic(ByteString.copyFrom(aciIdentityKeyPair.getPublicKey().serialize())).setAciIdentityKeyPrivate(ByteString.copyFrom(aciIdentityKeyPair.getPrivateKey().serialize())).setPniIdentityKeyPublic(ByteString.copyFrom(pniIdentityKeyPair.getPublicKey().serialize())).setPniIdentityKeyPrivate(ByteString.copyFrom(pniIdentityKeyPair.getPrivateKey().serialize())).setAci(aci.toString()).setPni(pni.toString()).setNumber(e164).setProfileKey(ByteString.copyFrom(profileKey.serialize())).setProvisioningCode(code).setProvisioningVersion(ProvisioningVersion.CURRENT_VALUE);
    byte[] ciphertext = cipher.encrypt(message.build());
    this.pushServiceSocket.sendProvisioningMessage(deviceIdentifier, ciphertext);
}
Also used : ProvisionMessage(org.whispersystems.signalservice.internal.push.ProvisioningProtos.ProvisionMessage) PrimaryProvisioningCipher(org.whispersystems.signalservice.internal.crypto.PrimaryProvisioningCipher) ACI(org.whispersystems.signalservice.api.push.ACI) PNI(org.whispersystems.signalservice.api.push.PNI) ByteString(com.google.protobuf.ByteString)

Aggregations

ByteString (com.google.protobuf.ByteString)2 ACI (org.whispersystems.signalservice.api.push.ACI)2 PNI (org.whispersystems.signalservice.api.push.PNI)2 PrimaryProvisioningCipher (org.whispersystems.signalservice.internal.crypto.PrimaryProvisioningCipher)2 ProvisionMessage (org.whispersystems.signalservice.internal.push.ProvisioningProtos.ProvisionMessage)2