/** * Sets forSigning etc flags based on key data. */ protected void calculateUsage() throws PGPException { int flags = getUsageFlags(); boolean canSign = (flags & PGPKeyFlags.CAN_SIGN) == PGPKeyFlags.CAN_SIGN; boolean canEncrypt = ((flags & PGPKeyFlags.CAN_ENCRYPT_COMMS) == PGPKeyFlags.CAN_ENCRYPT_COMMS) || ((flags & PGPKeyFlags.CAN_ENCRYPT_STORAGE) == PGPKeyFlags.CAN_ENCRYPT_STORAGE); forSigning = canSign && secretKey != null && !secretKey.isPrivateKeyEmpty(); forVerification = canSign; forEncryption = canEncrypt; forDecryption = canEncrypt && secretKey != null && !secretKey.isPrivateKeyEmpty(); }
static boolean isSigningKey(PGPPublicKey key) { int keyFlags = getKeyFlags(key); return (keyFlags & PGPKeyFlags.CAN_SIGN) == PGPKeyFlags.CAN_SIGN; }