mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-23 17:22:16 -05:00
Fix SIGNATURE_UNKNOWN_PUB_KEY
This commit is contained in:
parent
08399dec4b
commit
ad6ac28782
@ -27,7 +27,6 @@ import org.sufficientlysecure.keychain.util.Log;
|
||||
*/
|
||||
public class OpenPgpSignatureResultBuilder {
|
||||
// OpenPgpSignatureResult
|
||||
private int mStatus = OpenPgpSignatureResult.SIGNATURE_ERROR;
|
||||
private boolean mSignatureOnly = false;
|
||||
private String mUserId;
|
||||
private long mKeyId;
|
||||
@ -39,10 +38,6 @@ public class OpenPgpSignatureResultBuilder {
|
||||
private boolean mValidKeyBinding = false;
|
||||
private boolean mIsSignatureKeyCertified = false;
|
||||
|
||||
public void status(int status) {
|
||||
this.mStatus = status;
|
||||
}
|
||||
|
||||
public void signatureOnly(boolean signatureOnly) {
|
||||
this.mSignatureOnly = signatureOnly;
|
||||
}
|
||||
@ -80,9 +75,9 @@ public class OpenPgpSignatureResultBuilder {
|
||||
OpenPgpSignatureResult result = new OpenPgpSignatureResult();
|
||||
result.setSignatureOnly(mSignatureOnly);
|
||||
|
||||
if (mValidKeyBinding && mValidSignature) {
|
||||
// valid sig!
|
||||
if (mKnownKey) {
|
||||
// valid sig!
|
||||
if (mKnownKey) {
|
||||
if (mValidKeyBinding && mValidSignature) {
|
||||
result.setKeyId(mKeyId);
|
||||
result.setUserId(mUserId);
|
||||
|
||||
@ -94,15 +89,15 @@ public class OpenPgpSignatureResultBuilder {
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_SUCCESS_UNCERTIFIED);
|
||||
}
|
||||
} else {
|
||||
result.setKeyId(mKeyId);
|
||||
|
||||
Log.d(Constants.TAG, "SIGNATURE_UNKNOWN_PUB_KEY");
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY);
|
||||
Log.d(Constants.TAG, "Error!\nvalidKeyBinding: " + mValidKeyBinding
|
||||
+ "\nvalidSignature: " + mValidSignature);
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_ERROR);
|
||||
}
|
||||
} else {
|
||||
Log.d(Constants.TAG, "Error!\nvalidKeyBinding: " + mValidKeyBinding
|
||||
+ "\nvalidSignature: " + mValidSignature);
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_ERROR);
|
||||
result.setKeyId(mKeyId);
|
||||
|
||||
Log.d(Constants.TAG, "SIGNATURE_UNKNOWN_PUB_KEY");
|
||||
result.setStatus(OpenPgpSignatureResult.SIGNATURE_UNKNOWN_PUB_KEY);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
@ -405,8 +405,6 @@ public class PgpDecryptVerify {
|
||||
if (dataChunk instanceof PGPOnePassSignatureList) {
|
||||
updateProgress(R.string.progress_processing_signature, currentProgress, 100);
|
||||
|
||||
signatureResultBuilder.signatureAvailable(true);
|
||||
|
||||
PGPOnePassSignatureList sigList = (PGPOnePassSignatureList) dataChunk;
|
||||
|
||||
// go through all signatures
|
||||
@ -439,6 +437,7 @@ public class PgpDecryptVerify {
|
||||
// get the subkey which has been used to generate this signature
|
||||
signatureKey = publicKeyRing.getPublicKey(signature.getKeyID());
|
||||
|
||||
signatureResultBuilder.signatureAvailable(true);
|
||||
signatureResultBuilder.knownKey(true);
|
||||
// TODO: uses the first pubkey for information
|
||||
signatureResultBuilder.userId(PgpKeyHelper.getMainUserId(publicKeyRing.getPublicKey()));
|
||||
@ -458,9 +457,9 @@ public class PgpDecryptVerify {
|
||||
signatureResultBuilder.signatureKeyCertified(isSignatureKeyCertified);
|
||||
} else {
|
||||
// no key in our database -> return "unknown pub key" status including the first key id
|
||||
signatureResultBuilder.knownKey(false);
|
||||
|
||||
if (!sigList.isEmpty()) {
|
||||
signatureResultBuilder.signatureAvailable(true);
|
||||
signatureResultBuilder.knownKey(false);
|
||||
signatureResultBuilder.keyId(sigList.get(0).getKeyID());
|
||||
}
|
||||
}
|
||||
@ -606,8 +605,6 @@ public class PgpDecryptVerify {
|
||||
throw new InvalidDataException();
|
||||
}
|
||||
|
||||
signatureResultBuilder.signatureAvailable(true);
|
||||
|
||||
// go through all signatures
|
||||
// and find out for which signature we have a key in our database
|
||||
Long masterKeyId = null;
|
||||
@ -641,6 +638,7 @@ public class PgpDecryptVerify {
|
||||
// get the subkey which has been used to generate this signature
|
||||
signatureKey = publicKeyRing.getPublicKey(signature.getKeyID());
|
||||
|
||||
signatureResultBuilder.signatureAvailable(true);
|
||||
signatureResultBuilder.knownKey(true);
|
||||
// TODO: uses the first pubkey for information
|
||||
signatureResultBuilder.userId(PgpKeyHelper.getMainUserId(publicKeyRing.getPublicKey()));
|
||||
@ -660,9 +658,9 @@ public class PgpDecryptVerify {
|
||||
signatureResultBuilder.signatureKeyCertified(isSignatureKeyCertified);
|
||||
} else {
|
||||
// no key in our database -> return "unknown pub key" status including the first key id
|
||||
signatureResultBuilder.knownKey(false);
|
||||
|
||||
if (!sigList.isEmpty()) {
|
||||
signatureResultBuilder.signatureAvailable(true);
|
||||
signatureResultBuilder.knownKey(false);
|
||||
signatureResultBuilder.keyId(sigList.get(0).getKeyID());
|
||||
}
|
||||
}
|
||||
|
@ -67,19 +67,17 @@
|
||||
android:layout_toRightOf="@+id/result_signature_image"
|
||||
android:textColor="@color/white" />
|
||||
|
||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||
android:id="@+id/lookup_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="50dp"
|
||||
android:padding="4dp"
|
||||
android:text="@string/btn_lookup_key"
|
||||
bootstrapbutton:bb_icon_left="fa-download"
|
||||
bootstrapbutton:bb_type="info"
|
||||
bootstrapbutton:bb_size="small"
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_alignParentEnd="true" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<com.beardedhen.androidbootstrap.BootstrapButton
|
||||
android:id="@+id/lookup_key"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="4dp"
|
||||
android:layout_marginBottom="4dp"
|
||||
android:text="@string/btn_lookup_key"
|
||||
bootstrapbutton:bb_icon_left="fa-download"
|
||||
bootstrapbutton:bb_type="info"
|
||||
bootstrapbutton:bb_size="small" />
|
||||
|
||||
</LinearLayout>
|
Loading…
Reference in New Issue
Block a user