diff options
author | Ashley Hughes <spirit.returned@gmail.com> | 2014-02-03 00:05:45 +0000 |
---|---|---|
committer | Ashley Hughes <spirit.returned@gmail.com> | 2014-02-03 00:05:45 +0000 |
commit | fd308a671d571b3d8c58d294cda8f6add5832054 (patch) | |
tree | 9aeb6917b3f74c67d21e0c2c66350c91a813f6bf /OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp | |
parent | a90b748611126cd122e39ef944f4c268798419f0 (diff) | |
download | open-keychain-fd308a671d571b3d8c58d294cda8f6add5832054.tar.gz open-keychain-fd308a671d571b3d8c58d294cda8f6add5832054.tar.bz2 open-keychain-fd308a671d571b3d8c58d294cda8f6add5832054.zip |
include authentication keys
Diffstat (limited to 'OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp')
-rw-r--r-- | OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java index 3fc63cda1..bef41ce64 100644 --- a/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java +++ b/OpenPGP-Keychain/src/main/java/org/sufficientlysecure/keychain/pgp/PgpKeyHelper.java @@ -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()); } |