working version of DecryptVerifyResult

This commit is contained in:
Vincent Breitmoser
2014-09-13 19:30:10 +02:00
parent 4c636a1471
commit dbbefe2f41
6 changed files with 112 additions and 63 deletions

View File

@@ -462,32 +462,23 @@ public class OpenPgpService extends RemoteService {
.setDecryptMetadataOnly(decryptMetadataOnly)
.setNfcState(nfcDecryptedSessionKey);
DecryptVerifyResult decryptVerifyResult;
try {
// TODO: currently does not support binary signed-only content
decryptVerifyResult = builder.build().execute();
// TODO: currently does not support binary signed-only content
DecryptVerifyResult decryptVerifyResult = builder.build().execute();
// throw exceptions upwards to client with meaningful messages
} catch (PgpDecryptVerify.InvalidDataException e) {
throw new Exception(getString(R.string.error_invalid_data));
} catch (PgpDecryptVerify.KeyExtractionException e) {
throw new Exception(getString(R.string.error_could_not_extract_private_key));
} catch (PgpDecryptVerify.WrongPassphraseException e) {
throw new Exception(getString(R.string.error_wrong_passphrase));
} catch (PgpDecryptVerify.NoSecretKeyException e) {
throw new Exception(getString(R.string.error_no_secret_key_found));
} catch (PgpDecryptVerify.IntegrityCheckFailedException e) {
throw new Exception(getString(R.string.error_integrity_check_failed));
} catch (PgpDecryptVerify.NeedNfcDataException e) {
// return PendingIntent to execute NFC activity
return getNfcDecryptIntent(data, e.mPassphrase, e.mEncryptedSessionKey);
}
if (DecryptVerifyResult.RESULT_PENDING_ASYM_PASSPHRASE == decryptVerifyResult.getStatus()) {
// get PendingIntent for passphrase input, add it to given params and return to client
return getPassphraseIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded());
} else if (DecryptVerifyResult.RESULT_PENDING_SYM_PASSPHRASE == decryptVerifyResult.getStatus()) {
throw new PgpGeneralException("Decryption of symmetric content not supported by API!");
if (decryptVerifyResult.isPending()) {
switch (decryptVerifyResult.getResult()) {
case DecryptVerifyResult.RESULT_PENDING_ASYM_PASSPHRASE:
return getPassphraseIntent(data, decryptVerifyResult.getKeyIdPassphraseNeeded());
case DecryptVerifyResult.RESULT_PENDING_SYM_PASSPHRASE:
throw new PgpGeneralException(
"Decryption of symmetric content not supported by API!");
case DecryptVerifyResult.RESULT_PENDING_NFC:
// TODO get passphrase here? currently not in DecryptVerifyResult
return getNfcDecryptIntent(
data, null, decryptVerifyResult.getNfcEncryptedSessionKey());
}
throw new PgpGeneralException(
"Encountered unhandled type of pending action not supported by API!");
}
OpenPgpSignatureResult signatureResult = decryptVerifyResult.getSignatureResult();