diff options
author | Werner Koch <wk@gnupg.org> | 2011-01-24 12:24:11 +0100 |
---|---|---|
committer | Werner Koch <wk@gnupg.org> | 2011-01-24 12:24:11 +0100 |
commit | c5e8a4c0fdde7f4aef2163a3710483c87bdf3161 (patch) | |
tree | ae9da511231485f5c8ba8faeb3e7db3b971fe8ff /g10/export.c | |
parent | Fix regression introduced by "editing only change". (diff) | |
parent | Remove keyserver/ from the build system. (diff) | |
download | gnupg2-c5e8a4c0fdde7f4aef2163a3710483c87bdf3161.tar.xz gnupg2-c5e8a4c0fdde7f4aef2163a3710483c87bdf3161.zip |
Merge branch 'master' into ECC-INTEGRATION-2-1
Diffstat (limited to 'g10/export.c')
-rw-r--r-- | g10/export.c | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/g10/export.c b/g10/export.c index 74a7b0c51..1eb0baa8b 100644 --- a/g10/export.c +++ b/g10/export.c @@ -114,6 +114,60 @@ export_pubkeys_stream (ctrl_t ctrl, iobuf_t out, strlist_t users, return rc; } + +/* + * Export a single key into a memory buffer. + */ +gpg_error_t +export_pubkey_buffer (ctrl_t ctrl, const char *keyspec, unsigned int options, + kbnode_t *r_keyblock, void **r_data, size_t *r_datalen) +{ + gpg_error_t err; + iobuf_t iobuf; + int any; + strlist_t helplist; + + *r_keyblock = NULL; + *r_data = NULL; + *r_datalen = 0; + + helplist = NULL; + if (!add_to_strlist_try (&helplist, keyspec)) + return gpg_error_from_syserror (); + + iobuf = iobuf_temp (); + err = do_export_stream (ctrl, iobuf, helplist, 0, r_keyblock, options, &any); + if (!err && !any) + err = gpg_error (GPG_ERR_NOT_FOUND); + if (!err) + { + const void *src; + size_t datalen; + + iobuf_flush_temp (iobuf); + src = iobuf_get_temp_buffer (iobuf); + datalen = iobuf_get_temp_length (iobuf); + if (!datalen) + err = gpg_error (GPG_ERR_NO_PUBKEY); + else if (!(*r_data = xtrymalloc (datalen))) + err = gpg_error_from_syserror (); + else + { + memcpy (*r_data, src, datalen); + *r_datalen = datalen; + } + } + iobuf_close (iobuf); + free_strlist (helplist); + if (err && *r_keyblock) + { + release_kbnode (*r_keyblock); + *r_keyblock = NULL; + } + return err; +} + + int export_seckeys (ctrl_t ctrl, strlist_t users ) { |