Fix YubiKey naming, cleanup

This commit is contained in:
Dominik Schürmann 2015-04-15 10:02:41 +02:00
parent f41758261f
commit 3668c8897d
11 changed files with 59 additions and 67 deletions

View file

@ -167,7 +167,7 @@ public class OpenPgpService extends RemoteService {
switch (requiredInput.mType) { switch (requiredInput.mType) {
case NFC_DECRYPT: case NFC_DECRYPT:
case NFC_SIGN: { case NFC_SIGN: {
// build PendingIntent for Yubikey NFC operations // build PendingIntent for YubiKey NFC operations
Intent intent = new Intent(context, NfcOperationActivity.class); Intent intent = new Intent(context, NfcOperationActivity.class);
// pass params through to activity that it can be returned again later to repeat pgp operation // pass params through to activity that it can be returned again later to repeat pgp operation
intent.putExtra(NfcOperationActivity.EXTRA_SERVICE_INTENT, data); intent.putExtra(NfcOperationActivity.EXTRA_SERVICE_INTENT, data);

View file

@ -245,11 +245,11 @@ public class PassphraseCacheService extends Service {
switch (keyType) { switch (keyType) {
case DIVERT_TO_CARD: case DIVERT_TO_CARD:
if (Preferences.getPreferences(this).useDefaultYubikeyPin()) { if (Preferences.getPreferences(this).useDefaultYubiKeyPin()) {
Log.d(Constants.TAG, "PassphraseCacheService: Using default Yubikey PIN: 123456"); Log.d(Constants.TAG, "PassphraseCacheService: Using default YubiKey PIN: 123456");
return new Passphrase("123456"); // default Yubikey PIN, see http://www.yubico.com/2012/12/yubikey-neo-openpgp/ return new Passphrase("123456"); // default YubiKey PIN, see http://www.yubico.com/2012/12/yubikey-neo-openpgp/
} else { } else {
Log.d(Constants.TAG, "PassphraseCacheService: NOT using default Yubikey PIN"); Log.d(Constants.TAG, "PassphraseCacheService: NOT using default YubiKey PIN");
break; break;
} }
case PASSPHRASE_EMPTY: case PASSPHRASE_EMPTY:

View file

@ -85,25 +85,6 @@ public abstract class DecryptFragment extends CryptoOperationFragment {
startActivity(viewKeyIntent); startActivity(viewKeyIntent);
} }
// protected void startPassphraseDialog(long subkeyId) {
// Intent intent = new Intent(getActivity(), PassphraseDialogActivity.class);
// intent.putExtra(PassphraseDialogActivity.EXTRA_SUBKEY_ID, subkeyId);
// startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
// }
//
// protected void startNfcDecrypt(long subKeyId, Passphrase pin, byte[] encryptedSessionKey) {
// // build PendingIntent for Yubikey NFC operations
// Intent intent = new Intent(getActivity(), NfcActivity.class);
// intent.setAction(NfcActivity.ACTION_DECRYPT_SESSION_KEY);
// intent.putExtra(NfcActivity.EXTRA_SERVICE_INTENT, new Intent()); // not used, only relevant to OpenPgpService
// intent.putExtra(NfcActivity.EXTRA_KEY_ID, subKeyId);
// intent.putExtra(NfcActivity.EXTRA_PIN, pin);
//
// intent.putExtra(NfcActivity.EXTRA_NFC_ENC_SESSION_KEY, encryptedSessionKey);
//
// startActivityForResult(intent, REQUEST_CODE_NFC_DECRYPT);
// }
/** /**
* *
* @return returns false if signature is invalid, key is revoked or expired. * @return returns false if signature is invalid, key is revoked or expired.

View file

@ -6,9 +6,7 @@
package org.sufficientlysecure.keychain.ui; package org.sufficientlysecure.keychain.ui;
import android.annotation.TargetApi;
import android.content.Intent; import android.content.Intent;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.view.WindowManager; import android.view.WindowManager;
@ -56,7 +54,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
mServiceIntent = data.getParcelable(EXTRA_SERVICE_INTENT); mServiceIntent = data.getParcelable(EXTRA_SERVICE_INTENT);
// obtain passphrase for this subkey // obtain passphrase for this subkey
obtainYubikeyPin(RequiredInputParcel.createRequiredPassphrase(mRequiredInput)); obtainYubiKeyPin(RequiredInputParcel.createRequiredPassphrase(mRequiredInput));
} }
@Override @Override
@ -106,7 +104,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
// avoid a loop // avoid a loop
Preferences prefs = Preferences.getPreferences(this); Preferences prefs = Preferences.getPreferences(this);
if (prefs.useDefaultYubikeyPin()) { if (prefs.useDefaultYubiKeyPin()) {
toast(getString(R.string.error_pin_nodefault)); toast(getString(R.string.error_pin_nodefault));
setResult(RESULT_CANCELED); setResult(RESULT_CANCELED);
finish(); finish();
@ -117,7 +115,7 @@ public class NfcOperationActivity extends BaseNfcActivity {
PassphraseCacheService.clearCachedPassphrase( PassphraseCacheService.clearCachedPassphrase(
this, mRequiredInput.getMasterKeyId(), mRequiredInput.getSubKeyId()); this, mRequiredInput.getMasterKeyId(), mRequiredInput.getSubKeyId());
obtainYubikeyPin(RequiredInputParcel.createRequiredPassphrase(mRequiredInput)); obtainYubiKeyPin(RequiredInputParcel.createRequiredPassphrase(mRequiredInput));
} }
} }

View file

@ -314,7 +314,7 @@ public class PassphraseDialogActivity extends FragmentActivity {
mPassphraseEditText.setImeActionLabel(getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE); mPassphraseEditText.setImeActionLabel(getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE);
mPassphraseEditText.setOnEditorActionListener(this); mPassphraseEditText.setOnEditorActionListener(this);
if (keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD && Preferences.getPreferences(activity).useNumKeypadForYubikeyPin()) { if (keyType == CanonicalizedSecretKey.SecretKeyType.DIVERT_TO_CARD && Preferences.getPreferences(activity).useNumKeypadForYubiKeyPin()) {
mPassphraseEditText.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_PASSWORD); mPassphraseEditText.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_PASSWORD);
} else if (keyType == CanonicalizedSecretKey.SecretKeyType.PIN) { } else if (keyType == CanonicalizedSecretKey.SecretKeyType.PIN) {
mPassphraseEditText.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_PASSWORD); mPassphraseEditText.setRawInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_TEXT_VARIATION_PASSWORD);

View file

@ -107,10 +107,10 @@ public class SettingsActivity extends PreferenceActivity {
values[i] = "" + valueIds[i]; values[i] = "" + valueIds[i];
} }
initializeUseDefaultYubikeyPin( initializeUseDefaultYubiKeyPin(
(CheckBoxPreference) findPreference(Constants.Pref.USE_DEFAULT_YUBIKEY_PIN)); (CheckBoxPreference) findPreference(Constants.Pref.USE_DEFAULT_YUBIKEY_PIN));
initializeUseNumKeypadForYubikeyPin( initializeUseNumKeypadForYubiKeyPin(
(CheckBoxPreference) findPreference(Constants.Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN)); (CheckBoxPreference) findPreference(Constants.Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN));
} }
@ -262,10 +262,10 @@ public class SettingsActivity extends PreferenceActivity {
values[i] = "" + valueIds[i]; values[i] = "" + valueIds[i];
} }
initializeUseDefaultYubikeyPin( initializeUseDefaultYubiKeyPin(
(CheckBoxPreference) findPreference(Constants.Pref.USE_DEFAULT_YUBIKEY_PIN)); (CheckBoxPreference) findPreference(Constants.Pref.USE_DEFAULT_YUBIKEY_PIN));
initializeUseNumKeypadForYubikeyPin( initializeUseNumKeypadForYubiKeyPin(
(CheckBoxPreference) findPreference(Constants.Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN)); (CheckBoxPreference) findPreference(Constants.Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN));
} }
} }
@ -335,23 +335,23 @@ public class SettingsActivity extends PreferenceActivity {
return serverSummary + "; " + context.getString(R.string.label_preferred) + ": " + sPreferences.getPreferredKeyserver(); return serverSummary + "; " + context.getString(R.string.label_preferred) + ": " + sPreferences.getPreferredKeyserver();
} }
private static void initializeUseDefaultYubikeyPin(final CheckBoxPreference mUseDefaultYubikeyPin) { private static void initializeUseDefaultYubiKeyPin(final CheckBoxPreference mUseDefaultYubiKeyPin) {
mUseDefaultYubikeyPin.setChecked(sPreferences.useDefaultYubikeyPin()); mUseDefaultYubiKeyPin.setChecked(sPreferences.useDefaultYubiKeyPin());
mUseDefaultYubikeyPin.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { mUseDefaultYubiKeyPin.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
mUseDefaultYubikeyPin.setChecked((Boolean) newValue); mUseDefaultYubiKeyPin.setChecked((Boolean) newValue);
sPreferences.setUseDefaultYubikeyPin((Boolean) newValue); sPreferences.setUseDefaultYubiKeyPin((Boolean) newValue);
return false; return false;
} }
}); });
} }
private static void initializeUseNumKeypadForYubikeyPin(final CheckBoxPreference mUseNumKeypadForYubikeyPin) { private static void initializeUseNumKeypadForYubiKeyPin(final CheckBoxPreference mUseNumKeypadForYubiKeyPin) {
mUseNumKeypadForYubikeyPin.setChecked(sPreferences.useNumKeypadForYubikeyPin()); mUseNumKeypadForYubiKeyPin.setChecked(sPreferences.useNumKeypadForYubiKeyPin());
mUseNumKeypadForYubikeyPin.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() { mUseNumKeypadForYubiKeyPin.setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
public boolean onPreferenceChange(Preference preference, Object newValue) { public boolean onPreferenceChange(Preference preference, Object newValue) {
mUseNumKeypadForYubikeyPin.setChecked((Boolean) newValue); mUseNumKeypadForYubiKeyPin.setChecked((Boolean) newValue);
sPreferences.setUseNumKeypadForYubikeyPin((Boolean) newValue); sPreferences.setUseNumKeypadForYubiKeyPin((Boolean) newValue);
return false; return false;
} }
}); });

View file

@ -281,7 +281,7 @@ public class ViewKeyActivity extends BaseNfcActivity implements
byte[] nfcFingerprints = intent.getByteArrayExtra(EXTRA_NFC_FINGERPRINTS); byte[] nfcFingerprints = intent.getByteArrayExtra(EXTRA_NFC_FINGERPRINTS);
String nfcUserId = intent.getStringExtra(EXTRA_NFC_USER_ID); String nfcUserId = intent.getStringExtra(EXTRA_NFC_USER_ID);
byte[] nfcAid = intent.getByteArrayExtra(EXTRA_NFC_AID); byte[] nfcAid = intent.getByteArrayExtra(EXTRA_NFC_AID);
showYubikeyFragment(nfcFingerprints, nfcUserId, nfcAid); showYubiKeyFragment(nfcFingerprints, nfcUserId, nfcAid);
} }
} }
@ -593,12 +593,12 @@ public class ViewKeyActivity extends BaseNfcActivity implements
} }
} }
showYubikeyFragment(nfcFingerprints, nfcUserId, nfcAid); showYubiKeyFragment(nfcFingerprints, nfcUserId, nfcAid);
} }
public void showYubikeyFragment(byte[] nfcFingerprints, String nfcUserId, byte[] nfcAid) { public void showYubiKeyFragment(byte[] nfcFingerprints, String nfcUserId, byte[] nfcAid) {
ViewKeyYubikeyFragment frag = ViewKeyYubikeyFragment.newInstance( ViewKeyYubiKeyFragment frag = ViewKeyYubiKeyFragment.newInstance(
nfcFingerprints, nfcUserId, nfcAid); nfcFingerprints, nfcUserId, nfcAid);
FragmentManager manager = getSupportFragmentManager(); FragmentManager manager = getSupportFragmentManager();

View file

@ -4,7 +4,6 @@ package org.sufficientlysecure.keychain.ui;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.util.Arrays; import java.util.Arrays;
import android.app.ProgressDialog;
import android.content.Intent; import android.content.Intent;
import android.database.Cursor; import android.database.Cursor;
import android.os.Bundle; import android.os.Bundle;
@ -29,11 +28,10 @@ import org.sufficientlysecure.keychain.pgp.CanonicalizedSecretKey.SecretKeyType;
import org.sufficientlysecure.keychain.provider.KeychainContract.Keys; import org.sufficientlysecure.keychain.provider.KeychainContract.Keys;
import org.sufficientlysecure.keychain.service.KeychainIntentService; import org.sufficientlysecure.keychain.service.KeychainIntentService;
import org.sufficientlysecure.keychain.service.ServiceProgressHandler; import org.sufficientlysecure.keychain.service.ServiceProgressHandler;
import org.sufficientlysecure.keychain.ui.dialog.ProgressDialogFragment;
import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils; import org.sufficientlysecure.keychain.ui.util.KeyFormattingUtils;
public class ViewKeyYubikeyFragment extends Fragment public class ViewKeyYubiKeyFragment extends Fragment
implements LoaderCallbacks<Cursor> { implements LoaderCallbacks<Cursor> {
public static final String ARG_FINGERPRINT = "fingerprint"; public static final String ARG_FINGERPRINT = "fingerprint";
@ -46,9 +44,9 @@ public class ViewKeyYubikeyFragment extends Fragment
private Button vButton; private Button vButton;
private TextView vStatus; private TextView vStatus;
public static ViewKeyYubikeyFragment newInstance(byte[] fingerprints, String userId, byte[] aid) { public static ViewKeyYubiKeyFragment newInstance(byte[] fingerprints, String userId, byte[] aid) {
ViewKeyYubikeyFragment frag = new ViewKeyYubikeyFragment(); ViewKeyYubiKeyFragment frag = new ViewKeyYubiKeyFragment();
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putByteArray(ARG_FINGERPRINT, fingerprints); args.putByteArray(ARG_FINGERPRINT, fingerprints);

View file

@ -1,5 +1,21 @@
package org.sufficientlysecure.keychain.ui.base; /*
* Copyright (C) 2014-2015 Dominik Schürmann <dominik@dominikschuermann.de>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.sufficientlysecure.keychain.ui.base;
import java.io.IOException; import java.io.IOException;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
@ -35,7 +51,6 @@ import org.sufficientlysecure.keychain.util.Log;
import org.sufficientlysecure.keychain.util.Passphrase; import org.sufficientlysecure.keychain.util.Passphrase;
import org.sufficientlysecure.keychain.util.Preferences; import org.sufficientlysecure.keychain.util.Preferences;
public abstract class BaseNfcActivity extends BaseActivity { public abstract class BaseNfcActivity extends BaseActivity {
public static final int REQUEST_CODE_PASSPHRASE = 1; public static final int REQUEST_CODE_PASSPHRASE = 1;
@ -108,10 +123,10 @@ public abstract class BaseNfcActivity extends BaseActivity {
enableNfcForegroundDispatch(); enableNfcForegroundDispatch();
} }
protected void obtainYubikeyPin(RequiredInputParcel requiredInput) { protected void obtainYubiKeyPin(RequiredInputParcel requiredInput) {
Preferences prefs = Preferences.getPreferences(this); Preferences prefs = Preferences.getPreferences(this);
if (prefs.useDefaultYubikeyPin()) { if (prefs.useDefaultYubiKeyPin()) {
mPin = new Passphrase("123456"); mPin = new Passphrase("123456");
return; return;
} }
@ -123,7 +138,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
} }
protected void setYubikeyPin(Passphrase pin) { protected void setYubiKeyPin(Passphrase pin) {
mPin = pin; mPin = pin;
} }

View file

@ -109,21 +109,21 @@ public class Preferences {
return mSharedPreferences.getBoolean(Constants.Pref.FIRST_TIME, true); return mSharedPreferences.getBoolean(Constants.Pref.FIRST_TIME, true);
} }
public boolean useDefaultYubikeyPin() { public boolean useDefaultYubiKeyPin() {
return mSharedPreferences.getBoolean(Pref.USE_DEFAULT_YUBIKEY_PIN, false); return mSharedPreferences.getBoolean(Pref.USE_DEFAULT_YUBIKEY_PIN, false);
} }
public void setUseDefaultYubikeyPin(boolean useDefaultYubikeyPin) { public void setUseDefaultYubiKeyPin(boolean useDefaultYubikeyPin) {
SharedPreferences.Editor editor = mSharedPreferences.edit(); SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putBoolean(Pref.USE_DEFAULT_YUBIKEY_PIN, useDefaultYubikeyPin); editor.putBoolean(Pref.USE_DEFAULT_YUBIKEY_PIN, useDefaultYubikeyPin);
editor.commit(); editor.commit();
} }
public boolean useNumKeypadForYubikeyPin() { public boolean useNumKeypadForYubiKeyPin() {
return mSharedPreferences.getBoolean(Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN, true); return mSharedPreferences.getBoolean(Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN, true);
} }
public void setUseNumKeypadForYubikeyPin(boolean useNumKeypadForYubikeyPin) { public void setUseNumKeypadForYubiKeyPin(boolean useNumKeypadForYubikeyPin) {
SharedPreferences.Editor editor = mSharedPreferences.edit(); SharedPreferences.Editor editor = mSharedPreferences.edit();
editor.putBoolean(Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN, useNumKeypadForYubikeyPin); editor.putBoolean(Pref.USE_NUMKEYPAD_FOR_YUBIKEY_PIN, useNumKeypadForYubikeyPin);
editor.commit(); editor.commit();

View file

@ -35,7 +35,7 @@
* Redesigned decrypt screen * Redesigned decrypt screen
* New icon usage and colors * New icon usage and colors
* Fix import of secret keys from Symantec Encryption Desktop * Fix import of secret keys from Symantec Encryption Desktop
* Subkey IDs on Yubikeys are now checked correctly * Subkey IDs on YubiKeys are now checked correctly
## 3.0.1 ## 3.0.1
@ -46,7 +46,7 @@
## 3.0 ## 3.0
* Full support for Yubikey signature generation and decryption! * Full support for YubiKey signature generation and decryption!
* Propose installable compatible apps in apps list * Propose installable compatible apps in apps list
* New design for decryption screens * New design for decryption screens
* Many fixes for key import, also fixes stripped keys * Many fixes for key import, also fixes stripped keys
@ -60,7 +60,7 @@
## 2.9.2 ## 2.9.2
* Fix keys broken in 2.9.1 * Fix keys broken in 2.9.1
* Yubikey decryption now working via API * YubiKey decryption now working via API
## 2.9.1 ## 2.9.1
@ -69,7 +69,7 @@
* Fix key flags handling (now supporting Mailvelope 0.7 keys) * Fix key flags handling (now supporting Mailvelope 0.7 keys)
* Improved passphrase handling * Improved passphrase handling
* Key sharing via SafeSlinger * Key sharing via SafeSlinger
* Yubikey: preference to allow other PINs, currently only signing via the OpenPGP API works, not inside of OpenKeychain * YubiKey: preference to allow other PINs, currently only signing via the OpenPGP API works, not inside of OpenKeychain
* Fix usage of stripped keys * Fix usage of stripped keys
* SHA256 as default for compatibility * SHA256 as default for compatibility
* Intent API has changed, see https://github.com/open-keychain/open-keychain/wiki/Intent-API * Intent API has changed, see https://github.com/open-keychain/open-keychain/wiki/Intent-API
@ -80,7 +80,7 @@
* Fixing crashes introduced in v2.8 * Fixing crashes introduced in v2.8
* Experimental ECC support * Experimental ECC support
* Experimental Yubikey support (signing-only with imported keys) * Experimental YubiKey support (signing-only with imported keys)
## 2.8 ## 2.8