diff options
author | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-02-09 16:00:16 +0900 |
---|---|---|
committer | DongHun Kwak <dh0128.kwak@samsung.com> | 2021-02-09 16:00:16 +0900 |
commit | 10fb3b7f1c67c9367ab0b15e2d8e4b5ec6abbae0 (patch) | |
tree | 09ec1445374083df61971982e5f1a51bb3ca2c4c /tools/call-dirmngr.c | |
parent | 0253adc833bb041c8a88b4d610aded01ce4e75f4 (diff) | |
download | gpg2-10fb3b7f1c67c9367ab0b15e2d8e4b5ec6abbae0.tar.gz gpg2-10fb3b7f1c67c9367ab0b15e2d8e4b5ec6abbae0.tar.bz2 gpg2-10fb3b7f1c67c9367ab0b15e2d8e4b5ec6abbae0.zip |
Imported Upstream version 2.1.17upstream/2.1.17
Diffstat (limited to 'tools/call-dirmngr.c')
-rw-r--r-- | tools/call-dirmngr.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tools/call-dirmngr.c b/tools/call-dirmngr.c index c5ee244..51f1fa1 100644 --- a/tools/call-dirmngr.c +++ b/tools/call-dirmngr.c @@ -258,3 +258,55 @@ wkd_get_policy_flags (const char *addrspec, estream_t *r_buffer) assuan_release (ctx); return err; } + + +/* Ask the dirmngr for the key for ADDRSPEC. On success a stream with + * the key is stored at R_KEY. */ +gpg_error_t +wkd_get_key (const char *addrspec, estream_t *r_key) +{ + gpg_error_t err; + assuan_context_t ctx; + struct wkd_get_parm_s parm; + char *line = NULL; + + memset (&parm, 0, sizeof parm); + *r_key = NULL; + + err = connect_dirmngr (&ctx); + if (err) + return err; + + line = es_bsprintf ("WKD_GET -- %s", addrspec); + if (!line) + { + err = gpg_error_from_syserror (); + goto leave; + } + if (strlen (line) + 2 >= ASSUAN_LINELENGTH) + { + err = gpg_error (GPG_ERR_TOO_LARGE); + goto leave; + } + + parm.memfp = es_fopenmem (0, "rwb"); + if (!parm.memfp) + { + err = gpg_error_from_syserror (); + goto leave; + } + err = assuan_transact (ctx, line, wkd_get_data_cb, &parm, + NULL, NULL, wkd_get_status_cb, &parm); + if (err) + goto leave; + + es_rewind (parm.memfp); + *r_key = parm.memfp; + parm.memfp = NULL; + + leave: + es_fclose (parm.memfp); + xfree (line); + assuan_release (ctx); + return err; +} |