From 8131daa6380ed752c4d31cd6a40650d9ac5b9817 Mon Sep 17 00:00:00 2001 From: Vincent Breitmoser Date: Sun, 28 Sep 2014 14:40:49 +0200 Subject: move can.*() methods to CanonicalizedPublicKey, where they belong --- .../keychain/pgp/UncachedPublicKey.java | 72 ---------------------- 1 file changed, 72 deletions(-) (limited to 'OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java') diff --git a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java index 74af9fc97..345c00579 100644 --- a/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java +++ b/OpenKeychain/src/main/java/org/sufficientlysecure/keychain/pgp/UncachedPublicKey.java @@ -39,7 +39,6 @@ import java.util.Iterator; public class UncachedPublicKey { protected final PGPPublicKey mPublicKey; - private Integer mCacheUsage = null; public UncachedPublicKey(PGPPublicKey key) { mPublicKey = key; @@ -228,77 +227,6 @@ public class UncachedPublicKey { return getAlgorithm() == PGPPublicKey.ECDH || getAlgorithm() == PGPPublicKey.ECDSA; } - /** - * Get all key usage flags. - * If at least one key flag subpacket is present return these. - * If no subpacket is present it returns null. - */ - @SuppressWarnings("unchecked") - public Integer getKeyUsage() { - if (mCacheUsage == null) { - for (PGPSignature sig : new IterableIterator(mPublicKey.getSignatures())) { - if (mPublicKey.isMasterKey() && sig.getKeyID() != mPublicKey.getKeyID()) { - continue; - } - - PGPSignatureSubpacketVector hashed = sig.getHashedSubPackets(); - if (hashed != null && hashed.getSubpacket(SignatureSubpacketTags.KEY_FLAGS) != null) { - // init if at least one key flag subpacket has been found - if (mCacheUsage == null) { - mCacheUsage = 0; - } - mCacheUsage |= hashed.getKeyFlags(); - } - } - } - return mCacheUsage; - } - - public boolean canCertify() { - // if key flags subpacket is available, honor it! - if (getKeyUsage() != null) { - return (getKeyUsage() & KeyFlags.CERTIFY_OTHER) != 0; - } - - return false; - } - - public boolean canSign() { - // if key flags subpacket is available, honor it! - if (getKeyUsage() != null) { - return (getKeyUsage() & KeyFlags.SIGN_DATA) != 0; - } - - if (UncachedKeyRing.isSigningAlgo(mPublicKey.getAlgorithm())) { - return true; - } - - return false; - } - - public boolean canEncrypt() { - // if key flags subpacket is available, honor it! - if (getKeyUsage() != null) { - return (getKeyUsage() & (KeyFlags.ENCRYPT_COMMS | KeyFlags.ENCRYPT_STORAGE)) != 0; - } - - // RSA_GENERAL, RSA_ENCRYPT, ELGAMAL_ENCRYPT, ELGAMAL_GENERAL, ECDH - if (UncachedKeyRing.isEncryptionAlgo(mPublicKey.getAlgorithm())) { - return true; - } - - return false; - } - - public boolean canAuthenticate() { - // if key flags subpacket is available, honor it! - if (getKeyUsage() != null) { - return (getKeyUsage() & KeyFlags.AUTHENTICATION) != 0; - } - - return false; - } - public byte[] getFingerprint() { return mPublicKey.getFingerprint(); } -- cgit v1.2.3