pass key id for check from EncryptActivity to NfcActivity

This commit is contained in:
Vincent Breitmoser 2014-09-30 02:03:17 +02:00
parent bd3f6a22cb
commit 11d0f4510b
3 changed files with 13 additions and 4 deletions

View File

@ -569,7 +569,9 @@ public class PgpSignEncrypt {
log.add(LogType.MSG_SE_PENDING_NFC, indent); log.add(LogType.MSG_SE_PENDING_NFC, indent);
SignEncryptResult result = SignEncryptResult result =
new SignEncryptResult(SignEncryptResult.RESULT_PENDING_NFC, log); new SignEncryptResult(SignEncryptResult.RESULT_PENDING_NFC, log);
result.setNfcData(e.hashToSign, e.hashAlgo, e.creationTimestamp, mSignaturePassphrase); // Note that the checked key here is the master key, not the signing key
// (although these are always the same on Yubikeys)
result.setNfcData(mSignatureMasterKeyId, e.hashToSign, e.hashAlgo, e.creationTimestamp, mSignaturePassphrase);
Log.d(Constants.TAG, "e.hashToSign"+ Hex.toHexString(e.hashToSign)); Log.d(Constants.TAG, "e.hashToSign"+ Hex.toHexString(e.hashToSign));
return result; return result;
} }

View File

@ -32,6 +32,7 @@ public class SignEncryptResult extends OperationResult {
long mKeyIdPassphraseNeeded; long mKeyIdPassphraseNeeded;
long mNfcKeyId;
byte[] mNfcHash; byte[] mNfcHash;
int mNfcAlgo; int mNfcAlgo;
Date mNfcTimestamp; Date mNfcTimestamp;
@ -45,13 +46,18 @@ public class SignEncryptResult extends OperationResult {
mKeyIdPassphraseNeeded = keyIdPassphraseNeeded; mKeyIdPassphraseNeeded = keyIdPassphraseNeeded;
} }
public void setNfcData(byte[] nfcHash, int nfcAlgo, Date nfcTimestamp, String passphrase) { public void setNfcData(long nfcKeyId, byte[] nfcHash, int nfcAlgo, Date nfcTimestamp, String passphrase) {
mNfcKeyId = nfcKeyId;
mNfcHash = nfcHash; mNfcHash = nfcHash;
mNfcAlgo = nfcAlgo; mNfcAlgo = nfcAlgo;
mNfcTimestamp = nfcTimestamp; mNfcTimestamp = nfcTimestamp;
mNfcPassphrase = passphrase; mNfcPassphrase = passphrase;
} }
public long getNfcKeyId() {
return mNfcKeyId;
}
public byte[] getNfcHash() { public byte[] getNfcHash() {
return mNfcHash; return mNfcHash;
} }

View File

@ -30,13 +30,14 @@ public abstract class EncryptActivity extends DrawerActivity {
startActivityForResult(intent, REQUEST_CODE_PASSPHRASE); startActivityForResult(intent, REQUEST_CODE_PASSPHRASE);
} }
protected void startNfcSign(String pin, byte[] hashToSign, int hashAlgo) { protected void startNfcSign(long keyId, String pin, byte[] hashToSign, int hashAlgo) {
// build PendingIntent for Yubikey NFC operations // build PendingIntent for Yubikey NFC operations
Intent intent = new Intent(this, NfcActivity.class); Intent intent = new Intent(this, NfcActivity.class);
intent.setAction(NfcActivity.ACTION_SIGN_HASH); intent.setAction(NfcActivity.ACTION_SIGN_HASH);
// 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(NfcActivity.EXTRA_DATA, new Intent()); // not used, only relevant to OpenPgpService intent.putExtra(NfcActivity.EXTRA_DATA, new Intent()); // not used, only relevant to OpenPgpService
intent.putExtra(NfcActivity.EXTRA_KEY_ID, keyId);
intent.putExtra(NfcActivity.EXTRA_PIN, pin); intent.putExtra(NfcActivity.EXTRA_PIN, pin);
intent.putExtra(NfcActivity.EXTRA_NFC_HASH_TO_SIGN, hashToSign); intent.putExtra(NfcActivity.EXTRA_NFC_HASH_TO_SIGN, hashToSign);
intent.putExtra(NfcActivity.EXTRA_NFC_HASH_ALGO, hashAlgo); intent.putExtra(NfcActivity.EXTRA_NFC_HASH_ALGO, hashAlgo);
@ -102,7 +103,7 @@ public abstract class EncryptActivity extends DrawerActivity {
SignEncryptResult.RESULT_PENDING_NFC) { SignEncryptResult.RESULT_PENDING_NFC) {
mNfcTimestamp = pgpResult.getNfcTimestamp(); mNfcTimestamp = pgpResult.getNfcTimestamp();
startNfcSign(pgpResult.getNfcPassphrase(), pgpResult.getNfcHash(), pgpResult.getNfcAlgo()); startNfcSign(pgpResult.getNfcKeyId(), pgpResult.getNfcPassphrase(), pgpResult.getNfcHash(), pgpResult.getNfcAlgo());
} else { } else {
throw new RuntimeException("Unhandled pending result!"); throw new RuntimeException("Unhandled pending result!");
} }