From 387222c450ff292f7b5267e926eca49b3e7e04dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Tue, 23 Jun 2015 23:40:34 -0400
Subject: [PATCH] sips: disable ZRTP

Fixes a crash caused by of missing ZRTP config values.

ZRTP may be enabled back later in the daemon
but is disabled for now.

Refs #76074

Change-Id: Iab815a7394f29a08bc800a1e28386bba77c692ee
---
 .../java/cx/ring/model/SecureSipCall.java     | 35 ++++++++++---------
 .../ring/model/account/AccountDetailSrtp.java |  8 ++---
 2 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/ring-android/app/src/main/java/cx/ring/model/SecureSipCall.java b/ring-android/app/src/main/java/cx/ring/model/SecureSipCall.java
index 5f5e729af..c606cc130 100644
--- a/ring-android/app/src/main/java/cx/ring/model/SecureSipCall.java
+++ b/ring-android/app/src/main/java/cx/ring/model/SecureSipCall.java
@@ -40,7 +40,7 @@ import cx.ring.model.account.AccountDetailSrtp;
 public class SecureSipCall extends SipCall {
 
     public interface SecureLayer {
-        int ZRTP_LAYER = 0;
+        //int ZRTP_LAYER = 0;
         int SDES_LAYER = 1;
     }
 
@@ -50,7 +50,7 @@ public class SecureSipCall extends SipCall {
     public final static int DISPLAY_NONE = 3;
 
     int mSecureLayerUsed;
-    ZrtpModule mZrtpModule;
+    //ZrtpModule mZrtpModule;
     SdesModule mSdesModule;
 
     private boolean isInitialized;
@@ -59,26 +59,27 @@ public class SecureSipCall extends SipCall {
         super(call);
         isInitialized = false;
         String keyExchange = getAccount().getSrtpDetails().getDetailString(AccountDetailSrtp.CONFIG_SRTP_KEY_EXCHANGE);
-        if (keyExchange.contentEquals("zrtp")) {
+        /*if (keyExchange.contentEquals("zrtp")) {
             mSecureLayerUsed = SecureLayer.ZRTP_LAYER;
-        } else if (keyExchange.contentEquals("sdes")) {
+        } else */if (keyExchange.contentEquals("sdes")) {
             mSecureLayerUsed = SecureLayer.SDES_LAYER;
         }
 
-        mZrtpModule = new ZrtpModule();
+        //mZrtpModule = new ZrtpModule();
         mSdesModule = new SdesModule();
     }
 
     public void setSASConfirmed(boolean confirmedSAS) {
-        mZrtpModule.needSASConfirmation = !confirmedSAS;
+        //mZrtpModule.needSASConfirmation = !confirmedSAS;
     }
 
     public String getSAS() {
-        return mZrtpModule.SAS;
+        //return mZrtpModule.SAS;
+        return "";
     }
 
     public void setSAS(String SAS) {
-        mZrtpModule.SAS = SAS;
+        //mZrtpModule.SAS = SAS;
     }
 
     public SecureSipCall(Parcel in) {
@@ -86,7 +87,7 @@ public class SecureSipCall extends SipCall {
         isInitialized = in.readByte() == 1;
         mSecureLayerUsed = in.readInt();
         mSdesModule = new SdesModule(in);
-        mZrtpModule = new ZrtpModule(in);
+        //mZrtpModule = new ZrtpModule(in);
     }
 
     @Override
@@ -95,7 +96,7 @@ public class SecureSipCall extends SipCall {
         out.writeByte((byte) (isInitialized ? 1 : 0));
         out.writeInt(mSecureLayerUsed);
         mSdesModule.writeToParcel(out);
-        mZrtpModule.writeToParcel(out);
+        //mZrtpModule.writeToParcel(out);
     }
 
     public static final Parcelable.Creator<SecureSipCall> CREATOR = new Parcelable.Creator<SecureSipCall>() {
@@ -113,9 +114,9 @@ public class SecureSipCall extends SipCall {
     }
 
     public void setZrtpSupport(boolean support) {
-        mZrtpModule.zrtpIsSupported = support;
+        /*mZrtpModule.zrtpIsSupported = support;
         if (!support)
-            mZrtpModule.needSASConfirmation = false;
+            mZrtpModule.needSASConfirmation = false;*/
     }
 
     public void setInitialized() {
@@ -126,7 +127,7 @@ public class SecureSipCall extends SipCall {
     * returns what state should be visible during call
     */
     public int displayModule() {
-        if (isInitialized) {
+        /*if (isInitialized) {
             Log.i("SecureSIp", "needSASConfirmation" + mZrtpModule.needSASConfirmation);
             if (mZrtpModule.needSASConfirmation) {
                 return DISPLAY_CONFIRM_SAS;
@@ -135,16 +136,16 @@ public class SecureSipCall extends SipCall {
             } else {
                 return DISPLAY_RED_LOCK;
             }
-        }
+        }*/
         return DISPLAY_NONE;
     }
 
     public void useSecureSDES(boolean use) {
         mSdesModule.sdesIsOn = use;
-        mZrtpModule.needSASConfirmation = false;
+        //mZrtpModule.needSASConfirmation = false;
     }
 
-
+/*
     private class ZrtpModule {
         private String SAS;
         private boolean needSASConfirmation;
@@ -181,7 +182,7 @@ public class SecureSipCall extends SipCall {
             dest.writeByte((byte) (needSASConfirmation ? 1 : 0));
         }
     }
-
+*/
     private class SdesModule {
 
         private boolean sdesIsOn;
diff --git a/ring-android/app/src/main/java/cx/ring/model/account/AccountDetailSrtp.java b/ring-android/app/src/main/java/cx/ring/model/account/AccountDetailSrtp.java
index 0064aa4ce..a70942338 100644
--- a/ring-android/app/src/main/java/cx/ring/model/account/AccountDetailSrtp.java
+++ b/ring-android/app/src/main/java/cx/ring/model/account/AccountDetailSrtp.java
@@ -33,10 +33,10 @@ public class AccountDetailSrtp implements AccountDetail {
     public static final String CONFIG_SRTP_KEY_EXCHANGE = "SRTP.keyExchange";
     public static final String CONFIG_SRTP_ENCRYPTION_ALGO = "SRTP.encryptionAlgorithm"; // Provided by ccRTP,0=NULL,1=AESCM,2=AESF8
     public static final String CONFIG_SRTP_RTP_FALLBACK = "SRTP.rtpFallback";
-    public static final String CONFIG_ZRTP_HELLO_HASH = "ZRTP.helloHashEnable";
+    /*public static final String CONFIG_ZRTP_HELLO_HASH = "ZRTP.helloHashEnable";
     public static final String CONFIG_ZRTP_DISPLAY_SAS = "ZRTP.displaySAS";
     public static final String CONFIG_ZRTP_NOT_SUPP_WARNING = "ZRTP.notSuppWarning";
-    public static final String CONFIG_ZRTP_DISPLAY_SAS_ONCE = "ZRTP.displaySasOnce";
+    public static final String CONFIG_ZRTP_DISPLAY_SAS_ONCE = "ZRTP.displaySasOnce";*/
 
     private ArrayList<AccountDetail.PreferenceEntry> privateArray;
 
@@ -47,10 +47,10 @@ public class AccountDetailSrtp implements AccountDetail {
         preference.add(new PreferenceEntry(CONFIG_SRTP_KEY_EXCHANGE, false));
         preference.add(new PreferenceEntry(CONFIG_SRTP_ENCRYPTION_ALGO, true));
         preference.add(new PreferenceEntry(CONFIG_SRTP_RTP_FALLBACK, true));
-        preference.add(new PreferenceEntry(CONFIG_ZRTP_HELLO_HASH, true));
+        /*preference.add(new PreferenceEntry(CONFIG_ZRTP_HELLO_HASH, true));
         preference.add(new PreferenceEntry(CONFIG_ZRTP_DISPLAY_SAS, true));
         preference.add(new PreferenceEntry(CONFIG_ZRTP_NOT_SUPP_WARNING, true));
-        preference.add(new PreferenceEntry(CONFIG_ZRTP_DISPLAY_SAS_ONCE, true));
+        preference.add(new PreferenceEntry(CONFIG_ZRTP_DISPLAY_SAS_ONCE, true));*/
 
         return preference;
     }
-- 
GitLab