Add experimental support for yubikey PINs, remove caching of empty passphrases

This commit is contained in:
Dominik Schürmann
2014-09-05 20:04:07 +02:00
parent fa9bbdd60c
commit 6e3973e26a
3 changed files with 34 additions and 15 deletions

View File

@@ -213,15 +213,13 @@ public class PassphraseCacheService extends Service {
SecretKeyType keyType = keyRing.getSecretKeyType(subKeyId);
switch (keyType) {
// TODO: HACK for yubikeys
case DIVERT_TO_CARD:
return "123456";
case PASSPHRASE_EMPTY:
try {
addCachedPassphrase(this, subKeyId, "", keyRing.getPrimaryUserIdWithFallback());
} catch (PgpGeneralException e) {
Log.d(Constants.TAG, "PgpGeneralException occured");
if (Preferences.getPreferences(this).useDefaultYubikeyPin()) {
return "123456"; // default Yubikey PIN, see http://www.yubico.com/2012/12/yubikey-neo-openpgp/
} else {
break;
}
case PASSPHRASE_EMPTY:
return "";
case UNAVAILABLE:
throw new NotFoundException("secret key for this subkey is not available");