Fixes for nfc decrypt
This commit is contained in:
@@ -418,8 +418,7 @@ public class PgpDecryptVerify {
|
|||||||
log.add(LogType.MSG_DC_PENDING_NFC, indent +1);
|
log.add(LogType.MSG_DC_PENDING_NFC, indent +1);
|
||||||
DecryptVerifyResult result =
|
DecryptVerifyResult result =
|
||||||
new DecryptVerifyResult(DecryptVerifyResult.RESULT_PENDING_NFC, log);
|
new DecryptVerifyResult(DecryptVerifyResult.RESULT_PENDING_NFC, log);
|
||||||
result.setNfcEncryptedSessionKey(e.encryptedSessionKey);
|
result.setNfcState(e.encryptedSessionKey, mPassphrase);
|
||||||
// TODO save passphrase here?
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
encryptedData = encryptedDataAsymmetric;
|
encryptedData = encryptedDataAsymmetric;
|
||||||
|
|||||||
@@ -277,7 +277,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputData, os);
|
inputData, os
|
||||||
|
);
|
||||||
builder.setEnableAsciiArmorOutput(asciiArmor)
|
builder.setEnableAsciiArmorOutput(asciiArmor)
|
||||||
.setVersionHeader(PgpHelper.getVersionForHeader(this))
|
.setVersionHeader(PgpHelper.getVersionForHeader(this))
|
||||||
.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
|
.setSignatureHashAlgorithm(accSettings.getHashAlgorithm())
|
||||||
@@ -379,7 +380,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
inputData, os);
|
inputData, os
|
||||||
|
);
|
||||||
builder.setEnableAsciiArmorOutput(asciiArmor)
|
builder.setEnableAsciiArmorOutput(asciiArmor)
|
||||||
.setVersionHeader(PgpHelper.getVersionForHeader(this))
|
.setVersionHeader(PgpHelper.getVersionForHeader(this))
|
||||||
.setCompressionId(accSettings.getCompression())
|
.setCompressionId(accSettings.getCompression())
|
||||||
@@ -524,9 +526,8 @@ public class OpenPgpService extends RemoteService {
|
|||||||
"Decryption of symmetric content not supported by API!");
|
"Decryption of symmetric content not supported by API!");
|
||||||
} else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) ==
|
} else if ((pgpResult.getResult() & DecryptVerifyResult.RESULT_PENDING_NFC) ==
|
||||||
DecryptVerifyResult.RESULT_PENDING_NFC) {
|
DecryptVerifyResult.RESULT_PENDING_NFC) {
|
||||||
// TODO get passphrase here? currently not in DecryptVerifyResult
|
|
||||||
return getNfcDecryptIntent(
|
return getNfcDecryptIntent(
|
||||||
data, null, pgpResult.getNfcEncryptedSessionKey());
|
data, pgpResult.getNfcPassphrase(), pgpResult.getNfcEncryptedSessionKey());
|
||||||
} else {
|
} else {
|
||||||
throw new PgpGeneralException(
|
throw new PgpGeneralException(
|
||||||
"Encountered unhandled type of pending action not supported by API!");
|
"Encountered unhandled type of pending action not supported by API!");
|
||||||
|
|||||||
@@ -31,10 +31,12 @@ public class DecryptVerifyResult extends OperationResult {
|
|||||||
// fifth to sixth bit in addition indicate specific type of pending
|
// fifth to sixth bit in addition indicate specific type of pending
|
||||||
public static final int RESULT_PENDING_ASYM_PASSPHRASE = RESULT_PENDING + 16;
|
public static final int RESULT_PENDING_ASYM_PASSPHRASE = RESULT_PENDING + 16;
|
||||||
public static final int RESULT_PENDING_SYM_PASSPHRASE = RESULT_PENDING + 32;
|
public static final int RESULT_PENDING_SYM_PASSPHRASE = RESULT_PENDING + 32;
|
||||||
public static final int RESULT_PENDING_NFC = RESULT_PENDING + 48;
|
public static final int RESULT_PENDING_NFC = RESULT_PENDING + 64;
|
||||||
|
|
||||||
long mKeyIdPassphraseNeeded;
|
long mKeyIdPassphraseNeeded;
|
||||||
|
|
||||||
byte[] mNfcSessionKey;
|
byte[] mNfcSessionKey;
|
||||||
|
String mNfcPassphrase;
|
||||||
|
|
||||||
OpenPgpSignatureResult mSignatureResult;
|
OpenPgpSignatureResult mSignatureResult;
|
||||||
OpenPgpMetadata mDecryptMetadata;
|
OpenPgpMetadata mDecryptMetadata;
|
||||||
@@ -47,14 +49,19 @@ public class DecryptVerifyResult extends OperationResult {
|
|||||||
mKeyIdPassphraseNeeded = keyIdPassphraseNeeded;
|
mKeyIdPassphraseNeeded = keyIdPassphraseNeeded;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNfcEncryptedSessionKey(byte[] sessionKey) {
|
public void setNfcState(byte[] sessionKey, String passphrase) {
|
||||||
mNfcSessionKey = sessionKey;
|
mNfcSessionKey = sessionKey;
|
||||||
|
mNfcPassphrase = passphrase;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getNfcEncryptedSessionKey() {
|
public byte[] getNfcEncryptedSessionKey() {
|
||||||
return mNfcSessionKey;
|
return mNfcSessionKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getNfcPassphrase() {
|
||||||
|
return mNfcPassphrase;
|
||||||
|
}
|
||||||
|
|
||||||
public OpenPgpSignatureResult getSignatureResult() {
|
public OpenPgpSignatureResult getSignatureResult() {
|
||||||
return mSignatureResult;
|
return mSignatureResult;
|
||||||
}
|
}
|
||||||
@@ -72,7 +79,7 @@ public class DecryptVerifyResult extends OperationResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPending() {
|
public boolean isPending() {
|
||||||
return (mResult & RESULT_PENDING) != 0;
|
return (mResult & RESULT_PENDING) == RESULT_PENDING;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DecryptVerifyResult(int result, OperationLog log) {
|
public DecryptVerifyResult(int result, OperationLog log) {
|
||||||
@@ -85,6 +92,7 @@ public class DecryptVerifyResult extends OperationResult {
|
|||||||
mSignatureResult = source.readParcelable(OpenPgpSignatureResult.class.getClassLoader());
|
mSignatureResult = source.readParcelable(OpenPgpSignatureResult.class.getClassLoader());
|
||||||
mDecryptMetadata = source.readParcelable(OpenPgpMetadata.class.getClassLoader());
|
mDecryptMetadata = source.readParcelable(OpenPgpMetadata.class.getClassLoader());
|
||||||
mNfcSessionKey = source.readInt() != 0 ? source.createByteArray() : null;
|
mNfcSessionKey = source.readInt() != 0 ? source.createByteArray() : null;
|
||||||
|
mNfcPassphrase = source.readString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int describeContents() {
|
public int describeContents() {
|
||||||
@@ -102,6 +110,7 @@ public class DecryptVerifyResult extends OperationResult {
|
|||||||
} else {
|
} else {
|
||||||
dest.writeInt(0);
|
dest.writeInt(0);
|
||||||
}
|
}
|
||||||
|
dest.writeString(mNfcPassphrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Creator<DecryptVerifyResult> CREATOR = new Creator<DecryptVerifyResult>() {
|
public static final Creator<DecryptVerifyResult> CREATOR = new Creator<DecryptVerifyResult>() {
|
||||||
|
|||||||
Reference in New Issue
Block a user