Update libsignal-service

This commit is contained in:
AsamK 2017-08-17 21:31:07 +02:00
parent 804949ddea
commit 9b56aa6259
6 changed files with 30 additions and 57 deletions

View file

@ -19,7 +19,7 @@ repositories {
} }
dependencies { dependencies {
compile 'com.github.turasa:signal-service-java:2.5.11_unofficial_1' compile 'com.github.turasa:signal-service-java:2.5.17_unofficial_1'
compile 'org.bouncycastle:bcprov-jdk15on:1.55' compile 'org.bouncycastle:bcprov-jdk15on:1.55'
compile 'net.sourceforge.argparse4j:argparse4j:0.7.0' compile 'net.sourceforge.argparse4j:argparse4j:0.7.0'
compile 'org.freedesktop.dbus:dbus-java:2.7.0' compile 'org.freedesktop.dbus:dbus-java:2.7.0'

Binary file not shown.

View file

@ -1,6 +1,6 @@
#Sat May 20 11:26:11 CEST 2017 #Thu Aug 17 20:18:16 CEST 2017
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.0.2-bin.zip

View file

@ -1012,14 +1012,11 @@ public class Main {
} }
if (syncMessage.getVerified().isPresent()) { if (syncMessage.getVerified().isPresent()) {
System.out.println("Received sync message with verified identities:"); System.out.println("Received sync message with verified identities:");
final List<VerifiedMessage> verifiedList = syncMessage.getVerified().get(); final VerifiedMessage verifiedMessage = syncMessage.getVerified().get();
for (VerifiedMessage v : verifiedList) { System.out.println(" - " + verifiedMessage.getDestination() + ": " + verifiedMessage.getVerified());
System.out.println(" - " + v.getDestination() + ": " + v.getVerified()); String safetyNumber = formatSafetyNumber(m.computeSafetyNumber(verifiedMessage.getDestination(), verifiedMessage.getIdentityKey()));
String safetyNumber = formatSafetyNumber(m.computeSafetyNumber(v.getDestination(), v.getIdentityKey()));
System.out.println(" " + safetyNumber); System.out.println(" " + safetyNumber);
} }
}
} }
} }
} else { } else {

View file

@ -368,7 +368,7 @@ class Manager implements Signal {
} }
public void updateAccountAttributes() throws IOException { public void updateAccountAttributes() throws IOException {
accountManager.setAccountAttributes(signalingKey, signalProtocolStore.getLocalRegistrationId(), false, false, true); accountManager.setAccountAttributes(signalingKey, signalProtocolStore.getLocalRegistrationId(), true);
} }
public void unregister() throws IOException { public void unregister() throws IOException {
@ -481,24 +481,6 @@ class Manager implements Signal {
return records; return records;
} }
private PreKeyRecord getOrGenerateLastResortPreKey() {
if (signalProtocolStore.containsPreKey(Medium.MAX_VALUE)) {
try {
return signalProtocolStore.loadPreKey(Medium.MAX_VALUE);
} catch (InvalidKeyIdException e) {
signalProtocolStore.removePreKey(Medium.MAX_VALUE);
}
}
ECKeyPair keyPair = Curve.generateKeyPair();
PreKeyRecord record = new PreKeyRecord(Medium.MAX_VALUE, keyPair);
signalProtocolStore.storePreKey(Medium.MAX_VALUE, record);
save();
return record;
}
private SignedPreKeyRecord generateSignedPreKey(IdentityKeyPair identityKeyPair) { private SignedPreKeyRecord generateSignedPreKey(IdentityKeyPair identityKeyPair) {
try { try {
ECKeyPair keyPair = Curve.generateKeyPair(); ECKeyPair keyPair = Curve.generateKeyPair();
@ -518,7 +500,7 @@ class Manager implements Signal {
public void verifyAccount(String verificationCode) throws IOException { public void verifyAccount(String verificationCode) throws IOException {
verificationCode = verificationCode.replace("-", ""); verificationCode = verificationCode.replace("-", "");
signalingKey = Util.getSecret(52); signalingKey = Util.getSecret(52);
accountManager.verifyAccountWithCode(verificationCode, signalingKey, signalProtocolStore.getLocalRegistrationId(), false, false, true); accountManager.verifyAccountWithCode(verificationCode, signalingKey, signalProtocolStore.getLocalRegistrationId(), true);
//accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID))); //accountManager.setGcmId(Optional.of(GoogleCloudMessaging.getInstance(this).register(REGISTRATION_ID)));
registered = true; registered = true;
@ -529,10 +511,9 @@ class Manager implements Signal {
private void refreshPreKeys() throws IOException { private void refreshPreKeys() throws IOException {
List<PreKeyRecord> oneTimePreKeys = generatePreKeys(); List<PreKeyRecord> oneTimePreKeys = generatePreKeys();
PreKeyRecord lastResortKey = getOrGenerateLastResortPreKey();
SignedPreKeyRecord signedPreKeyRecord = generateSignedPreKey(signalProtocolStore.getIdentityKeyPair()); SignedPreKeyRecord signedPreKeyRecord = generateSignedPreKey(signalProtocolStore.getIdentityKeyPair());
accountManager.setPreKeys(signalProtocolStore.getIdentityKeyPair().getPublicKey(), lastResortKey, signedPreKeyRecord, oneTimePreKeys); accountManager.setPreKeys(signalProtocolStore.getIdentityKeyPair().getPublicKey(), signedPreKeyRecord, oneTimePreKeys);
} }
@ -1203,7 +1184,6 @@ class Manager implements Signal {
if (rm.isContactsRequest()) { if (rm.isContactsRequest()) {
try { try {
sendContacts(); sendContacts();
sendVerifiedMessage();
} catch (UntrustedIdentityException | IOException e) { } catch (UntrustedIdentityException | IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -1298,10 +1278,8 @@ class Manager implements Signal {
} }
} }
if (syncMessage.getVerified().isPresent()) { if (syncMessage.getVerified().isPresent()) {
final List<VerifiedMessage> verifiedList = syncMessage.getVerified().get(); final VerifiedMessage verifiedMessage = syncMessage.getVerified().get();
for (VerifiedMessage v : verifiedList) { signalProtocolStore.saveIdentity(verifiedMessage.getDestination(), verifiedMessage.getIdentityKey(), TrustLevel.fromVerifiedState(verifiedMessage.getVerified()));
signalProtocolStore.saveIdentity(v.getDestination(), v.getIdentityKey(), TrustLevel.fromVerifiedState(v.getVerified()));
}
} }
} }
} }
@ -1513,8 +1491,21 @@ class Manager implements Signal {
try (OutputStream fos = new FileOutputStream(contactsFile)) { try (OutputStream fos = new FileOutputStream(contactsFile)) {
DeviceContactsOutputStream out = new DeviceContactsOutputStream(fos); DeviceContactsOutputStream out = new DeviceContactsOutputStream(fos);
for (ContactInfo record : contactStore.getContacts()) { for (ContactInfo record : contactStore.getContacts()) {
VerifiedMessage verifiedMessage = null;
if (getIdentities().containsKey(record.number)) {
JsonIdentityKeyStore.Identity currentIdentity = null;
for (JsonIdentityKeyStore.Identity id : getIdentities().get(record.number)) {
if (currentIdentity == null || id.getDateAdded().after(currentIdentity.getDateAdded())) {
currentIdentity = id;
}
}
if (currentIdentity != null) {
verifiedMessage = new VerifiedMessage(record.number, currentIdentity.getIdentityKey(), currentIdentity.getTrustLevel().toVerifiedState(), currentIdentity.getDateAdded().getTime());
}
}
out.write(new DeviceContact(record.number, Optional.fromNullable(record.name), out.write(new DeviceContact(record.number, Optional.fromNullable(record.name),
createContactAvatarAttachment(record.number), Optional.fromNullable(record.color))); createContactAvatarAttachment(record.number), Optional.fromNullable(record.color), Optional.fromNullable(verifiedMessage)));
} }
} }
@ -1538,23 +1529,8 @@ class Manager implements Signal {
} }
} }
private void sendVerifiedMessage() throws IOException, UntrustedIdentityException {
List<VerifiedMessage> verifiedMessages = new LinkedList<>();
for (Map.Entry<String, List<JsonIdentityKeyStore.Identity>> x : getIdentities().entrySet()) {
final String name = x.getKey();
for (JsonIdentityKeyStore.Identity id : x.getValue()) {
if (id.getTrustLevel() == TrustLevel.TRUSTED_UNVERIFIED) {
continue;
}
VerifiedMessage verifiedMessage = new VerifiedMessage(name, id.getIdentityKey(), id.getTrustLevel().toVerifiedState());
verifiedMessages.add(verifiedMessage);
}
}
sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessages));
}
private void sendVerifiedMessage(String destination, IdentityKey identityKey, TrustLevel trustLevel) throws IOException, UntrustedIdentityException { private void sendVerifiedMessage(String destination, IdentityKey identityKey, TrustLevel trustLevel) throws IOException, UntrustedIdentityException {
VerifiedMessage verifiedMessage = new VerifiedMessage(destination, identityKey, trustLevel.toVerifiedState()); VerifiedMessage verifiedMessage = new VerifiedMessage(destination, identityKey, trustLevel.toVerifiedState(), System.currentTimeMillis());
sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessage)); sendSyncMessage(SignalServiceSyncMessage.forVerified(verifiedMessage));
} }