From 5650f448ece63135b6e385e7146ee91430473911 Mon Sep 17 00:00:00 2001 From: Michele Balistreri Date: Thu, 22 Oct 2020 16:21:48 +0200 Subject: [PATCH] improve wrong pairing password handling --- .../status/keycard/connect/card/OpenSecureChannelCommand.kt | 6 +++++- .../java/im/status/keycard/connect/ui/ChangePINActivity.kt | 1 - .../java/im/status/keycard/connect/ui/ChangePUKActivity.kt | 1 - .../keycard/connect/ui/ChangePairingPasswordActivity.kt | 2 -- .../main/java/im/status/keycard/connect/ui/InitActivity.kt | 1 - .../java/im/status/keycard/connect/ui/LoadKeyActivity.kt | 1 - .../main/java/im/status/keycard/connect/ui/PINActivity.kt | 1 - .../main/java/im/status/keycard/connect/ui/PUKActivity.kt | 1 - .../java/im/status/keycard/connect/ui/PairingActivity.kt | 1 - .../java/im/status/keycard/connect/ui/ReinstallActivity.kt | 1 - .../im/status/keycard/connect/ui/ShowMnemonicActivity.kt | 1 - .../im/status/keycard/connect/ui/SignMessageActivity.kt | 1 - .../im/status/keycard/connect/ui/SignTransactionActivity.kt | 1 - 13 files changed, 5 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/im/status/keycard/connect/card/OpenSecureChannelCommand.kt b/app/src/main/java/im/status/keycard/connect/card/OpenSecureChannelCommand.kt index 39cdfcd..58d0434 100644 --- a/app/src/main/java/im/status/keycard/connect/card/OpenSecureChannelCommand.kt +++ b/app/src/main/java/im/status/keycard/connect/card/OpenSecureChannelCommand.kt @@ -7,6 +7,7 @@ import im.status.keycard.connect.Registry import im.status.keycard.connect.data.PAIRING_ACTIVITY_PASSWORD import im.status.keycard.connect.data.REQ_INTERACTIVE_SCRIPT import im.status.keycard.connect.ui.PairingActivity +import java.lang.Exception class OpenSecureChannelCommand : CardCommand { private var pairingPassword: String? = null @@ -19,10 +20,13 @@ class OpenSecureChannelCommand : CardCommand { private fun pair(activity: Activity, cmdSet: KeycardCommandSet): CardCommand.Result { if (pairingPassword != null) { - val res = runOnCard { + val res = try { cmdSet.autoPair(pairingPassword) Registry.pairingManager.putPairing(cmdSet.applicationInfo.instanceUID, cmdSet.pairing) cmdSet.autoOpenSecureChannel() + CardCommand.Result.OK + } catch(e: Exception) { + CardCommand.Result.RETRY } pairingPassword = null diff --git a/app/src/main/java/im/status/keycard/connect/ui/ChangePINActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/ChangePINActivity.kt index b031fed..fef3812 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/ChangePINActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/ChangePINActivity.kt @@ -5,7 +5,6 @@ import android.os.Bundle import android.view.View import android.widget.Button import android.widget.EditText -import androidx.appcompat.app.AppCompatActivity import androidx.core.widget.doAfterTextChanged import im.status.keycard.connect.R import im.status.keycard.connect.Registry diff --git a/app/src/main/java/im/status/keycard/connect/ui/ChangePUKActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/ChangePUKActivity.kt index d311033..245e7d1 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/ChangePUKActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/ChangePUKActivity.kt @@ -5,7 +5,6 @@ import android.os.Bundle import android.view.View import android.widget.Button import android.widget.EditText -import androidx.appcompat.app.AppCompatActivity import androidx.core.widget.doAfterTextChanged import im.status.keycard.connect.R import im.status.keycard.connect.Registry diff --git a/app/src/main/java/im/status/keycard/connect/ui/ChangePairingPasswordActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/ChangePairingPasswordActivity.kt index 1c8dfee..8b7c1d3 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/ChangePairingPasswordActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/ChangePairingPasswordActivity.kt @@ -5,13 +5,11 @@ import android.os.Bundle import android.view.View import android.widget.Button import android.widget.EditText -import androidx.appcompat.app.AppCompatActivity import androidx.core.widget.doAfterTextChanged import im.status.keycard.connect.R import im.status.keycard.connect.Registry import im.status.keycard.connect.card.ChangePairingPasswordCommand import im.status.keycard.connect.card.scriptWithAuthentication -import im.status.keycard.connect.data.isValidPUK class ChangePairingPasswordActivity : NoNFCActivity() { override fun onCreate(savedInstanceState: Bundle?) { diff --git a/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt index 5fbcdb0..2766dce 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/InitActivity.kt @@ -9,7 +9,6 @@ import android.util.Base64.NO_PADDING import android.util.Base64.NO_WRAP import android.view.View import android.widget.TextView -import androidx.appcompat.app.AppCompatActivity import im.status.keycard.connect.R import im.status.keycard.connect.data.INIT_ACTIVITY_PAIRING import im.status.keycard.connect.data.INIT_ACTIVITY_PIN diff --git a/app/src/main/java/im/status/keycard/connect/ui/LoadKeyActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/LoadKeyActivity.kt index d7be176..a9fd1ff 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/LoadKeyActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/LoadKeyActivity.kt @@ -6,7 +6,6 @@ import android.content.pm.ActivityInfo import android.os.Bundle import android.view.View import android.widget.EditText -import androidx.appcompat.app.AppCompatActivity import im.status.keycard.connect.R import im.status.keycard.connect.data.* import java.util.* diff --git a/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt index 9c664cf..31b167f 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/PINActivity.kt @@ -7,7 +7,6 @@ import android.view.View import android.widget.Button import android.widget.EditText import android.widget.TextView -import androidx.appcompat.app.AppCompatActivity import androidx.core.widget.doAfterTextChanged import im.status.keycard.connect.R import im.status.keycard.connect.Registry diff --git a/app/src/main/java/im/status/keycard/connect/ui/PUKActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/PUKActivity.kt index 0f93c05..2da02b1 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/PUKActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/PUKActivity.kt @@ -7,7 +7,6 @@ import android.view.View import android.widget.Button import android.widget.EditText import android.widget.TextView -import androidx.appcompat.app.AppCompatActivity import androidx.core.widget.doAfterTextChanged import im.status.keycard.connect.R import im.status.keycard.connect.Registry diff --git a/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt index 87f1ecc..960c731 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/PairingActivity.kt @@ -7,7 +7,6 @@ import android.os.Bundle import android.view.View import android.widget.Button import android.widget.EditText -import androidx.appcompat.app.AppCompatActivity import androidx.core.widget.doAfterTextChanged import im.status.keycard.connect.R import im.status.keycard.connect.data.PAIRING_ACTIVITY_PASSWORD diff --git a/app/src/main/java/im/status/keycard/connect/ui/ReinstallActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/ReinstallActivity.kt index d687c37..b3e0649 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/ReinstallActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/ReinstallActivity.kt @@ -5,7 +5,6 @@ import android.content.pm.ActivityInfo import android.os.Bundle import android.view.View import android.widget.CheckBox -import androidx.appcompat.app.AppCompatActivity import im.status.keycard.connect.R import im.status.keycard.connect.Registry import im.status.keycard.connect.card.ReinstallCommand diff --git a/app/src/main/java/im/status/keycard/connect/ui/ShowMnemonicActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/ShowMnemonicActivity.kt index e1aa94a..d46f883 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/ShowMnemonicActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/ShowMnemonicActivity.kt @@ -4,7 +4,6 @@ import android.content.pm.ActivityInfo import android.os.Bundle import android.view.View import android.widget.TextView -import androidx.appcompat.app.AppCompatActivity import im.status.keycard.connect.R import im.status.keycard.connect.data.MNEMONIC_PHRASE diff --git a/app/src/main/java/im/status/keycard/connect/ui/SignMessageActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/SignMessageActivity.kt index e164fe6..894da83 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/SignMessageActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/SignMessageActivity.kt @@ -5,7 +5,6 @@ import android.content.pm.ActivityInfo import android.os.Bundle import android.view.View import android.widget.TextView -import androidx.appcompat.app.AppCompatActivity import im.status.keycard.connect.R import im.status.keycard.connect.data.SIGN_TEXT_MESSAGE diff --git a/app/src/main/java/im/status/keycard/connect/ui/SignTransactionActivity.kt b/app/src/main/java/im/status/keycard/connect/ui/SignTransactionActivity.kt index bb47de1..5c7355e 100644 --- a/app/src/main/java/im/status/keycard/connect/ui/SignTransactionActivity.kt +++ b/app/src/main/java/im/status/keycard/connect/ui/SignTransactionActivity.kt @@ -5,7 +5,6 @@ import android.content.pm.ActivityInfo import android.os.Bundle import android.view.View import android.widget.TextView -import androidx.appcompat.app.AppCompatActivity import im.status.keycard.connect.R import im.status.keycard.connect.data.SIGN_TX_AMOUNT import im.status.keycard.connect.data.SIGN_TX_CURRENCY