No show key button for RESULT_INVALID_SIGNATURE, Cleanup
This commit is contained in:
@@ -206,7 +206,7 @@ public class PgpSecurityConstants {
|
||||
* TODO: Ed25519
|
||||
* CITE: zooko's hash function table CITE: distinguishers on SHA-256
|
||||
*/
|
||||
public static final int DEFAULT_HASH_ALGORITHM = HashAlgorithmTags.SHA256;
|
||||
public static final int DEFAULT_HASH_ALGORITHM = HashAlgorithmTags.SHA512;
|
||||
|
||||
public interface OpenKeychainHashAlgorithmTags extends HashAlgorithmTags {
|
||||
int USE_DEFAULT = -1;
|
||||
|
||||
@@ -313,11 +313,16 @@ public class NfcOperationActivity extends BaseNfcActivity {
|
||||
}
|
||||
|
||||
private boolean shouldPutKey(byte[] fingerprint, int idx) throws IOException {
|
||||
byte[] cardFingerprint = nfcGetFingerprint(idx);
|
||||
byte[] cardFingerprint = nfcGetMasterKeyFingerprint(idx);
|
||||
|
||||
// Note: special case: This should not happen, but happens with
|
||||
// https://github.com/FluffyKaon/OpenPGP-Card, thus for now assume true
|
||||
if (cardFingerprint == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Slot is empty, or contains this key already. PUT KEY operation is safe
|
||||
if (cardFingerprint == null ||
|
||||
Arrays.equals(cardFingerprint, BLANK_FINGERPRINT) ||
|
||||
if (Arrays.equals(cardFingerprint, BLANK_FINGERPRINT) ||
|
||||
Arrays.equals(cardFingerprint, fingerprint)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -453,7 +453,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
* @return The long key id of the requested key, or null if not found.
|
||||
*/
|
||||
public Long nfcGetKeyId(int idx) throws IOException {
|
||||
byte[] fp = nfcGetFingerprint(idx);
|
||||
byte[] fp = nfcGetMasterKeyFingerprint(idx);
|
||||
if (fp == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -499,7 +499,7 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
* @param idx Index of the key to return the fingerprint from.
|
||||
* @return The fingerprint of the requested key, or null if not found.
|
||||
*/
|
||||
public byte[] nfcGetFingerprint(int idx) throws IOException {
|
||||
public byte[] nfcGetMasterKeyFingerprint(int idx) throws IOException {
|
||||
byte[] data = nfcGetFingerprints();
|
||||
if (data == null) {
|
||||
return null;
|
||||
@@ -952,8 +952,11 @@ public abstract class BaseNfcActivity extends BaseActivity {
|
||||
name = (new String(Hex.decode(name))).replace('<', ' ');
|
||||
return name;
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
Log.e(Constants.TAG, "couldn't get holder name", e);
|
||||
// try-catch for https://github.com/FluffyKaon/OpenPGP-Card
|
||||
// Note: This should not happen, but happens with
|
||||
// https://github.com/FluffyKaon/OpenPGP-Card, thus return an empty string for now!
|
||||
|
||||
Log.e(Constants.TAG, "Couldn't get holder name, returning empty string!", e);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -571,8 +571,9 @@ public class KeyFormattingUtils {
|
||||
sigIcon = R.drawable.status_signature_invalid_cutout_24dp;
|
||||
sigColor = R.color.key_flag_red;
|
||||
|
||||
sigActionText = R.string.decrypt_result_action_show;
|
||||
sigActionIcon = R.drawable.ic_vpn_key_grey_24dp;
|
||||
// won't be used, but makes compiler happy
|
||||
sigActionText = 0;
|
||||
sigActionIcon = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -584,7 +585,8 @@ public class KeyFormattingUtils {
|
||||
holder.getSignatureStatusText().setText(sigText);
|
||||
holder.getSignatureStatusText().setTextColor(sigColorRes);
|
||||
|
||||
if (signatureResult.getResult() != OpenPgpSignatureResult.RESULT_NO_SIGNATURE) {
|
||||
if (signatureResult.getResult() != OpenPgpSignatureResult.RESULT_NO_SIGNATURE
|
||||
&& signatureResult.getResult() != OpenPgpSignatureResult.RESULT_INVALID_SIGNATURE) {
|
||||
// has a signature, thus display layouts
|
||||
|
||||
holder.getSignatureLayout().setVisibility(View.VISIBLE);
|
||||
|
||||
Reference in New Issue
Block a user