aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2017-08-24 12:21:15 +0000
committerWerner Koch <[email protected]>2017-08-24 14:20:51 +0000
commit9bde9144f0c2d0087799511e9b041dc945a4cfa8 (patch)
tree768790cb29da24b343ae889d8484105e768b388c
parentgpgconf: Add more comments. (diff)
downloadgpgme-9bde9144f0c2d0087799511e9b041dc945a4cfa8.tar.gz
gpgme-9bde9144f0c2d0087799511e9b041dc945a4cfa8.zip
core: New public enum gpgme_keyorg_t.
* src/gpgme.h.in (gpgme_keyorg_t): New. * src/keylist.c (parse_keyorg): New. (keylist_colon_handler): Set key->ORIGIN. -- This finally set the key origin value form data supplied by recent gpg versions. Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--src/gpgme.h.in17
-rw-r--r--src/keylist.c23
2 files changed, 37 insertions, 3 deletions
diff --git a/src/gpgme.h.in b/src/gpgme.h.in
index 8afc276e..31a90609 100644
--- a/src/gpgme.h.in
+++ b/src/gpgme.h.in
@@ -330,6 +330,21 @@ typedef enum
gpgme_tofu_policy_t;
+/* The key origin values. */
+typedef enum
+ {
+ GPGME_KEYORG_UNKNOWN = 0,
+ GPGME_KEYORG_KS = 1,
+ GPGME_KEYORG_DANE = 3,
+ GPGME_KEYORG_WKD = 4,
+ GPGME_KEYORG_URL = 5,
+ GPGME_KEYORG_FILE = 6,
+ GPGME_KEYORG_SELF = 7,
+ GPGME_KEYORG_OTHER = 31
+ }
+gpgme_keyorg_t;
+
+
/* The available protocols. */
typedef enum
{
@@ -697,7 +712,7 @@ struct _gpgme_user_id
/* The malloced TOFU information or NULL. */
gpgme_tofu_info_t tofu;
- /* Time of the last refresh of thsi user id. 0 if unknown. */
+ /* Time of the last refresh of this user id. 0 if unknown. */
unsigned long last_update;
};
typedef struct _gpgme_user_id *gpgme_user_id_t;
diff --git a/src/keylist.c b/src/keylist.c
index 5e1c61e6..24a9b0b3 100644
--- a/src/keylist.c
+++ b/src/keylist.c
@@ -376,6 +376,25 @@ set_ownertrust (gpgme_key_t key, const char *src)
}
+static gpgme_keyorg_t
+parse_keyorg (const char *string)
+{
+ switch (atoi (string))
+ {
+ case 0: return GPGME_KEYORG_UNKNOWN;
+ case 1:
+ case 2:
+ return GPGME_KEYORG_KS;
+ case 3: return GPGME_KEYORG_DANE;
+ case 4: return GPGME_KEYORG_WKD;
+ case 5: return GPGME_KEYORG_URL;
+ case 6: return GPGME_KEYORG_FILE;
+ case 7: return GPGME_KEYORG_SELF;
+ default: return GPGME_KEYORG_OTHER;
+ }
+}
+
+
/* Parse field 15 of a secret key or subkey. This fields holds a
reference to smartcards. FIELD is the content of the field and we
are allowed to modify it. */
@@ -719,7 +738,7 @@ keylist_colon_handler (void *priv, char *line)
if (fields >= 20)
{
key->last_update = _gpgme_parse_timestamp_ul (field[18]);
- key->origin = 0; /* Fixme: Not yet defined in gpg. */
+ key->origin = parse_keyorg (field[19]);
}
break;
@@ -814,7 +833,7 @@ keylist_colon_handler (void *priv, char *line)
if (fields >= 20)
{
opd->tmp_uid->last_update = _gpgme_parse_timestamp_ul (field[18]);
- opd->tmp_uid->origin = 0; /* Fixme: Not yet defined in gpg. */
+ opd->tmp_uid->origin = parse_keyorg (field[19]);
}
}
break;