diff options
author | Kevin McCarthy <kevin@8t8.us> | 2015-03-30 15:45:51 -0700 |
---|---|---|
committer | Kevin McCarthy <kevin@8t8.us> | 2015-03-30 15:45:51 -0700 |
commit | dedb0a6f370b413b74594c251ea83e88b6609679 (patch) | |
tree | 336f6be183249978ffab4545285e771ec5291a4e /crypt.c | |
parent | 4615a829c7dd4a2ba64683bae4c058b098f5d30a (diff) |
Pull is_numerical_keyid() into crypt.c.
A subsequent patch (re?)-introduces a call to is_numerical_keyid inside
find_keys(). Rather than duplicate the function, this patch pulls it
into crypt.c, where find_keys() and pgp_findKeys() can both call it.
Diffstat (limited to 'crypt.c')
-rw-r--r-- | crypt.c | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -997,3 +997,25 @@ const char* crypt_get_fingerprint_or_id (char *p, const char **pphint, *pps = ps; return pfcopy; } + + +/* + * Used by pgp_findKeys and find_keys to check if a crypt-hook + * value is a key id. + */ + +short crypt_is_numerical_keyid (const char *s) +{ + /* or should we require the "0x"? */ + if (strncmp (s, "0x", 2) == 0) + s += 2; + if (strlen (s) % 8) + return 0; + while (*s) + if (strchr ("0123456789ABCDEFabcdef", *s++) == NULL) + return 0; + + return 1; +} + + |