]> nmode's Git Repositories - signal-cli/commitdiff
Update libsignal
authorAsamK <asamk@gmx.de>
Mon, 21 Dec 2020 09:25:36 +0000 (10:25 +0100)
committerAsamK <asamk@gmx.de>
Sat, 23 Jan 2021 11:59:47 +0000 (12:59 +0100)
CHANGELOG.md
build.gradle
src/main/java/org/asamk/signal/ReceiveMessageHandler.java
src/main/java/org/asamk/signal/manager/Manager.java
src/main/java/org/asamk/signal/manager/ProvisioningManager.java
src/main/java/org/asamk/signal/manager/RegistrationManager.java
src/main/java/org/asamk/signal/manager/ServiceConfig.java
src/main/java/org/asamk/signal/manager/helper/PinHelper.java
src/main/java/org/asamk/signal/manager/storage/protocol/JsonIdentityKeyStore.java

index 9092711d501d477ac47a99486da51a680d14ae7e..ef4d240bf4e032812445ecfb612057ecef670fc4 100644 (file)
@@ -1,6 +1,8 @@
 # Changelog
 
 ## [Unreleased]
+**Attention**: For all functionality an additional native library is now required: [libsignal-client](https://github.com/signalapp/libsignal-client/).
+See https://github.com/AsamK/signal-cli/wiki/Provide-native-lib-for-libsignal for more information.
 
 ## [0.7.4] - 2021-01-19
 ### Changed
index 764ad99e3f246e5b886c69c3b6c55d8bdb96b4ad..9eaf7b8ad83d261c089ee8f7217e19d76f66d8d5 100644 (file)
@@ -17,7 +17,8 @@ repositories {
 }
 
 dependencies {
-    implementation 'com.github.turasa:signal-service-java:2.15.3_unofficial_17'
+    implementation 'com.google.protobuf:protobuf-javalite:3.10.0'
+    implementation 'com.github.turasa:signal-service-java:2.15.3_unofficial_18'
     implementation 'org.bouncycastle:bcprov-jdk15on:1.68'
     implementation 'net.sourceforge.argparse4j:argparse4j:0.8.1'
     implementation 'com.github.hypfvieh:dbus-java:3.2.4'
index 0bb2e01230b4c127272b154233c9d2c995d9d581..da1be2715ff3b90f493aafa5e197b69a29b87410 100644 (file)
@@ -318,6 +318,9 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
                     if (receiptMessage.isReadReceipt()) {
                         System.out.println(" - Is read receipt");
                     }
+                    if (receiptMessage.isViewedReceipt()) {
+                        System.out.println(" - Is viewed receipt");
+                    }
                     System.out.println(" - Timestamps:");
                     for (long timestamp : receiptMessage.getTimestamps()) {
                         System.out.println("    " + DateUtils.formatTimestamp(timestamp));
@@ -397,6 +400,11 @@ public class ReceiveMessageHandler implements Manager.ReceiveMessageHandler {
                 System.out.println("  Has signed group change: " + groupInfo.hasSignedGroupChange());
             }
         }
+        if (message.getGroupCallUpdate().isPresent()) {
+            final SignalServiceDataMessage.GroupCallUpdate groupCallUpdate = message.getGroupCallUpdate().get();
+            System.out.println("Group call update:");
+            System.out.println(" - Era id: " + groupCallUpdate.getEraId());
+        }
         if (message.getPreviews().isPresent()) {
             final List<SignalServiceDataMessage.Preview> previews = message.getPreviews().get();
             System.out.println("Previews:");
index 96dbe21212bda15a62690bd844c8e68a51d58d15..c4f32460d97692d75262be1d3cd08ba6450a5510 100644 (file)
@@ -219,6 +219,7 @@ public class Manager implements Closeable {
                         account.getDeviceId()),
                 userAgent,
                 groupsV2Operations,
+                ServiceConfig.AUTOMATIC_NETWORK_RETRY,
                 timer);
         this.groupsV2Api = accountManager.getGroupsV2Api();
         final KeyBackupService keyBackupService = ServiceConfig.createKeyBackupService(accountManager);
@@ -234,7 +235,8 @@ public class Manager implements Closeable {
                 userAgent,
                 null,
                 timer,
-                clientZkProfileOperations);
+                clientZkProfileOperations,
+                ServiceConfig.AUTOMATIC_NETWORK_RETRY);
 
         this.account.setResolver(this::resolveSignalServiceAddress);
 
@@ -352,10 +354,19 @@ public class Manager implements Closeable {
      *               if it's Optional.absent(), the avatar will be removed
      */
     public void setProfile(String name, Optional<File> avatar) throws IOException {
+        // TODO
+        String about = null;
+        String aboutEmoji = null;
+
         try (final StreamDetails streamDetails = avatar == null
                 ? avatarStore.retrieveProfileAvatar(getSelfAddress())
                 : avatar.isPresent() ? Utils.createStreamDetailsFromFile(avatar.get()) : null) {
-            accountManager.setVersionedProfile(account.getUuid(), account.getProfileKey(), name, streamDetails);
+            accountManager.setVersionedProfile(account.getUuid(),
+                    account.getProfileKey(),
+                    name,
+                    about,
+                    aboutEmoji,
+                    streamDetails);
         }
 
         if (avatar != null) {
@@ -378,6 +389,7 @@ public class Manager implements Closeable {
         // If this is the master device, other users can't send messages to this number anymore.
         // If this is a linked device, other users can still send messages, but this device doesn't receive them anymore.
         accountManager.setGcmId(Optional.absent());
+        accountManager.deleteAccount();
 
         account.setRegistered(false);
         account.save();
@@ -499,7 +511,8 @@ public class Manager implements Closeable {
                 Optional.absent(),
                 clientZkProfileOperations,
                 executor,
-                ServiceConfig.MAX_ENVELOPE_SIZE);
+                ServiceConfig.MAX_ENVELOPE_SIZE,
+                ServiceConfig.AUTOMATIC_NETWORK_RETRY);
     }
 
     private SignalProfile getRecipientProfile(
@@ -1250,7 +1263,7 @@ public class Manager implements Closeable {
     private Map<String, UUID> getRegisteredUsers(final Set<String> numbersMissingUuid) throws IOException {
         try {
             return accountManager.getRegisteredUsers(getIasKeyStore(), numbersMissingUuid, CDS_MRENCLAVE);
-        } catch (Quote.InvalidQuoteFormatException | UnauthenticatedQuoteException | SignatureException | UnauthenticatedResponseException e) {
+        } catch (Quote.InvalidQuoteFormatException | UnauthenticatedQuoteException | SignatureException | UnauthenticatedResponseException | InvalidKeyException e) {
             throw new IOException(e);
         }
     }
@@ -1391,10 +1404,13 @@ public class Manager implements Closeable {
             if (e.getCause() instanceof org.whispersystems.libsignal.UntrustedIdentityException) {
                 org.whispersystems.libsignal.UntrustedIdentityException identityException = (org.whispersystems.libsignal.UntrustedIdentityException) e
                         .getCause();
-                account.getSignalProtocolStore()
-                        .saveIdentity(resolveSignalServiceAddress(identityException.getName()),
-                                identityException.getUntrustedIdentity(),
-                                TrustLevel.UNTRUSTED);
+                final IdentityKey untrustedIdentity = identityException.getUntrustedIdentity();
+                if (untrustedIdentity != null) {
+                    account.getSignalProtocolStore()
+                            .saveIdentity(resolveSignalServiceAddress(identityException.getName()),
+                                    untrustedIdentity,
+                                    TrustLevel.UNTRUSTED);
+                }
                 throw identityException;
             }
             throw new AssertionError(e);
index 535cecc6fc950bf9059b4af99e27a7b782bb0fc3..0c26cf77964ffe4ebed3a1994ed402d62ff846a8 100644 (file)
@@ -70,6 +70,7 @@ public class ProvisioningManager {
                 new DynamicCredentialsProvider(null, null, password, null, SignalServiceAddress.DEFAULT_DEVICE_ID),
                 userAgent,
                 groupsV2Operations,
+                ServiceConfig.AUTOMATIC_NETWORK_RETRY,
                 timer);
     }
 
index d6bf78b13a012c6e129681de5bf4355052c8f246..506948badde039f026bf58f94deb1445faaa2fa8 100644 (file)
@@ -70,7 +70,7 @@ public class RegistrationManager implements Closeable {
                 account.getUsername(),
                 account.getPassword(),
                 account.getSignalingKey(),
-                SignalServiceAddress.DEFAULT_DEVICE_ID), userAgent, null, timer);
+                SignalServiceAddress.DEFAULT_DEVICE_ID), userAgent, null, ServiceConfig.AUTOMATIC_NETWORK_RETRY, timer);
         final KeyBackupService keyBackupService = ServiceConfig.createKeyBackupService(accountManager);
         this.pinHelper = new PinHelper(keyBackupService);
     }
index b6d4f4fd9b0be29637e80cfb41ccd9f895669de6..c68e57731dfe90ba0a1a4bdfcc06baaa1b8a488a 100644 (file)
@@ -36,8 +36,9 @@ public class ServiceConfig {
     final static int PREKEY_MINIMUM_COUNT = 20;
     final static int PREKEY_BATCH_SIZE = 100;
     final static int MAX_ATTACHMENT_SIZE = 150 * 1024 * 1024;
-    final static int MAX_ENVELOPE_SIZE = 0;
+    final static long MAX_ENVELOPE_SIZE = 0;
     final static long AVATAR_DOWNLOAD_FAILSAFE_MAX_SIZE = 10 * 1024 * 1024;
+    final static boolean AUTOMATIC_NETWORK_RETRY = true;
 
     final static String CDS_MRENCLAVE = "c98e00a4e3ff977a56afefe7362a27e4961e4f19e211febfbb19b897e6b80b15";
 
index b4fa04c45bc0089b79a4c91970737758ea62b9f6..090b20b63e914f97b920215a53db8e7dc2579c01 100644 (file)
@@ -1,6 +1,7 @@
 package org.asamk.signal.manager.helper;
 
 import org.asamk.signal.manager.util.PinHashing;
+import org.whispersystems.libsignal.InvalidKeyException;
 import org.whispersystems.signalservice.api.KbsPinData;
 import org.whispersystems.signalservice.api.KeyBackupService;
 import org.whispersystems.signalservice.api.KeyBackupServicePinException;
@@ -82,7 +83,7 @@ public class PinHelper {
                 throw new AssertionError("Null not expected");
             }
             return kbsData;
-        } catch (UnauthenticatedResponseException e) {
+        } catch (UnauthenticatedResponseException | InvalidKeyException e) {
             throw new IOException(e);
         }
     }
index 28d64cbf9729ba7e52d1a12fde93666835717df9..9f01b719f8f72ef74df86eb6973249e4d7f9c5e8 100644 (file)
@@ -194,47 +194,43 @@ public class JsonIdentityKeyStore implements IdentityKeyStore {
         ) throws IOException {
             JsonNode node = jsonParser.getCodec().readTree(jsonParser);
 
-            try {
-                int localRegistrationId = node.get("registrationId").asInt();
-                IdentityKeyPair identityKeyPair = new IdentityKeyPair(Base64.getDecoder()
-                        .decode(node.get("identityKey").asText()));
-
-                JsonIdentityKeyStore keyStore = new JsonIdentityKeyStore(identityKeyPair, localRegistrationId);
-
-                JsonNode trustedKeysNode = node.get("trustedKeys");
-                if (trustedKeysNode.isArray()) {
-                    for (JsonNode trustedKey : trustedKeysNode) {
-                        String trustedKeyName = trustedKey.hasNonNull("name") ? trustedKey.get("name").asText() : null;
-
-                        if (UuidUtil.isUuid(trustedKeyName)) {
-                            // Ignore identities that were incorrectly created with UUIDs as name
-                            continue;
-                        }
-
-                        UUID uuid = trustedKey.hasNonNull("uuid") ? UuidUtil.parseOrNull(trustedKey.get("uuid")
-                                .asText()) : null;
-                        final SignalServiceAddress serviceAddress = uuid == null
-                                ? Utils.getSignalServiceAddressFromIdentifier(trustedKeyName)
-                                : new SignalServiceAddress(uuid, trustedKeyName);
-                        try {
-                            IdentityKey id = new IdentityKey(Base64.getDecoder()
-                                    .decode(trustedKey.get("identityKey").asText()), 0);
-                            TrustLevel trustLevel = trustedKey.hasNonNull("trustLevel")
-                                    ? TrustLevel.fromInt(trustedKey.get("trustLevel").asInt())
-                                    : TrustLevel.TRUSTED_UNVERIFIED;
-                            Date added = trustedKey.hasNonNull("addedTimestamp") ? new Date(trustedKey.get(
-                                    "addedTimestamp").asLong()) : new Date();
-                            keyStore.saveIdentity(serviceAddress, id, trustLevel, added);
-                        } catch (InvalidKeyException e) {
-                            logger.warn("Error while decoding key for {}: {}", trustedKeyName, e.getMessage());
-                        }
+            int localRegistrationId = node.get("registrationId").asInt();
+            IdentityKeyPair identityKeyPair = new IdentityKeyPair(Base64.getDecoder()
+                    .decode(node.get("identityKey").asText()));
+
+            JsonIdentityKeyStore keyStore = new JsonIdentityKeyStore(identityKeyPair, localRegistrationId);
+
+            JsonNode trustedKeysNode = node.get("trustedKeys");
+            if (trustedKeysNode.isArray()) {
+                for (JsonNode trustedKey : trustedKeysNode) {
+                    String trustedKeyName = trustedKey.hasNonNull("name") ? trustedKey.get("name").asText() : null;
+
+                    if (UuidUtil.isUuid(trustedKeyName)) {
+                        // Ignore identities that were incorrectly created with UUIDs as name
+                        continue;
                     }
-                }
 
-                return keyStore;
-            } catch (InvalidKeyException e) {
-                throw new IOException(e);
+                    UUID uuid = trustedKey.hasNonNull("uuid")
+                            ? UuidUtil.parseOrNull(trustedKey.get("uuid").asText())
+                            : null;
+                    final SignalServiceAddress serviceAddress = uuid == null
+                            ? Utils.getSignalServiceAddressFromIdentifier(trustedKeyName)
+                            : new SignalServiceAddress(uuid, trustedKeyName);
+                    try {
+                        IdentityKey id = new IdentityKey(Base64.getDecoder()
+                                .decode(trustedKey.get("identityKey").asText()), 0);
+                        TrustLevel trustLevel = trustedKey.hasNonNull("trustLevel") ? TrustLevel.fromInt(trustedKey.get(
+                                "trustLevel").asInt()) : TrustLevel.TRUSTED_UNVERIFIED;
+                        Date added = trustedKey.hasNonNull("addedTimestamp") ? new Date(trustedKey.get("addedTimestamp")
+                                .asLong()) : new Date();
+                        keyStore.saveIdentity(serviceAddress, id, trustLevel, added);
+                    } catch (InvalidKeyException e) {
+                        logger.warn("Error while decoding key for {}: {}", trustedKeyName, e.getMessage());
+                    }
+                }
             }
+
+            return keyStore;
         }
     }