Commit 3e8778d9 authored by William Desportes's avatar William Desportes 🛠 Committed by Bastien Le Querrec

Removed 2 NPEs when having no identity

parent b3e4ea77
......@@ -119,8 +119,14 @@ public abstract class KeyScanningActivity extends PassphraseRequiredActionBarAct
}
protected void initiateDisplay() {
IntentIntegrator intentIntegrator = getIntentIntegrator();
intentIntegrator.shareText(Base64.encodeBytes(getIdentityKeyToDisplay().serialize()));
IdentityKey identityKey = getIdentityKeyToDisplay();
if (identityKey != null) {
IntentIntegrator intentIntegrator = getIntentIntegrator();
intentIntegrator.shareText(Base64.encodeBytes(identityKey.serialize()));
} else {
Toast.makeText(this, R.string.VerifyIdentityActivity_you_do_not_have_an_identity_key,
Toast.LENGTH_LONG).show();
}
}
protected void initiateShare() {
......
......@@ -23,6 +23,7 @@ import android.content.DialogInterface;
import android.os.Build;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.widget.Toast;
import org.smssecure.smssecure.R;
import org.smssecure.smssecure.crypto.SessionBuilder;
......@@ -95,11 +96,16 @@ public class KeyExchangeInitiator {
SessionBuilder sessionBuilder = new SessionBuilder(sessionStore, preKeyStore, signedPreKeyStore,
identityKeyStore, new SignalProtocolAddress(recipient.getNumber(), 1));
KeyExchangeMessage keyExchangeMessage = sessionBuilder.process();
String serializedMessage = Base64.encodeBytesWithoutPadding(keyExchangeMessage.serialize());
OutgoingKeyExchangeMessage textMessage = new OutgoingKeyExchangeMessage(recipients, serializedMessage, subscriptionId);
if (identityKeyStore.getIdentityKeyPair() != null) {
KeyExchangeMessage keyExchangeMessage = sessionBuilder.process();
String serializedMessage = Base64.encodeBytesWithoutPadding(keyExchangeMessage.serialize());
OutgoingKeyExchangeMessage textMessage = new OutgoingKeyExchangeMessage(recipients, serializedMessage, subscriptionId);
MessageSender.send(context, masterSecret, textMessage, -1, false);
MessageSender.send(context, masterSecret, textMessage, -1, false);
} else {
Toast.makeText(context, R.string.VerifyIdentityActivity_you_do_not_have_an_identity_key,
Toast.LENGTH_LONG).show();
}
}
private static boolean hasInitiatedSession(Context context, MasterSecret masterSecret,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment