aboutsummaryrefslogtreecommitdiffstats
path: root/g10/getkey.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2013-03-15 14:46:03 +0000
committerWerner Koch <[email protected]>2013-03-19 16:26:42 +0000
commit4bde12206c5bf199dc6e12a74af8da4558ba41bf (patch)
tree23175bfae00ac2838223a853430956c0873ed588 /g10/getkey.c
parentscd: ccid-driver supporting larger APDU. (diff)
downloadgnupg-4bde12206c5bf199dc6e12a74af8da4558ba41bf.tar.gz
gnupg-4bde12206c5bf199dc6e12a74af8da4558ba41bf.zip
gpg: Distinguish between missing and cleared key flags.
* include/cipher.h (PUBKEY_USAGE_NONE): New. * g10/getkey.c (parse_key_usage): Set new flag. -- We do not want to use the default capabilities (derived from the algorithm) if any key flags are given in a signature. Thus if key flags are used in any way, the default key capabilities are never used. This allows to create a key with key flags set to all zero so it can't be used. This better reflects common sense.
Diffstat (limited to '')
-rw-r--r--g10/getkey.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/g10/getkey.c b/g10/getkey.c
index 929427302..8cc560100 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -1276,13 +1276,19 @@ parse_key_usage (PKT_signature * sig)
if (flags)
key_usage |= PUBKEY_USAGE_UNKNOWN;
+
+ if (!key_usage)
+ key_usage |= PUBKEY_USAGE_NONE;
}
+ else if (p) /* Key flags of length zero. */
+ key_usage |= PUBKEY_USAGE_NONE;
/* We set PUBKEY_USAGE_UNKNOWN to indicate that this key has a
capability that we do not handle. This serves to distinguish
between a zero key usage which we handle as the default
capabilities for that algorithm, and a usage that we do not
- handle. */
+ handle. Likewise we use PUBKEY_USAGE_NONE to indicate that
+ key_flags have been given but they do not specify any usage. */
return key_usage;
}