mirror of
https://github.com/moparisthebest/open-keychain
synced 2024-11-06 17:25:05 -05:00
include authentication keys
This commit is contained in:
parent
a90b748611
commit
fd308a671d
@ -397,6 +397,36 @@ public class PgpKeyHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isAuthenticationKey(PGPSecretKey key) {
|
||||
return isAuthenticationKey(key.getPublicKey());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static boolean isAuthenticationKey(PGPPublicKey key) {
|
||||
if (key.getVersion() <= 3) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (PGPSignature sig : new IterableIterator<PGPSignature>(key.getSignatures())) {
|
||||
if (key.isMasterKey() && sig.getKeyID() != key.getKeyID()) {
|
||||
continue;
|
||||
}
|
||||
PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets();
|
||||
|
||||
if (hashed != null && (hashed.getKeyFlags() & KeyFlags.AUTHENTICATION) != 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
PGPSignatureSubpacketVector unhashed = sig.getUnhashedSubPackets();
|
||||
|
||||
if (unhashed != null && (unhashed.getKeyFlags() & KeyFlags.AUTHENTICATION) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean isCertificationKey(PGPSecretKey key) {
|
||||
return isCertificationKey(key.getPublicKey());
|
||||
}
|
||||
|
@ -194,6 +194,7 @@ public class KeyEditor extends LinearLayout implements Editor, OnClickListener {
|
||||
mChkCertify.setChecked(PgpKeyHelper.isCertificationKey(key));
|
||||
mChkSign.setChecked(PgpKeyHelper.isSigningKey(key));
|
||||
mChkEncrypt.setChecked(PgpKeyHelper.isEncryptionKey(key));
|
||||
mChkAuthenticate.setChecked(PgpKeyHelper.isAuthenticationKey(key));
|
||||
// TODO: use usage argument?
|
||||
|
||||
for (int i = 0; i < choices.size(); ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user