diff options
author | Werner Koch <[email protected]> | 2016-08-13 17:27:28 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2016-08-13 17:40:32 +0000 |
commit | 700920640211168ae1c97d0adef74ba8615d90bb (patch) | |
tree | 0561a5a22deaef82d15dae360e3cb83bbc443740 /g13/call-syshelp.c | |
parent | g13: Move some function around. (diff) | |
download | gnupg-700920640211168ae1c97d0adef74ba8615d90bb.tar.gz gnupg-700920640211168ae1c97d0adef74ba8615d90bb.zip |
g13: Consider g13tab for a mount command.
* g13/sh-cmd.c (cmd_getkeyblob): New.
(register_commands): Register it.
* g13/call-syshelp.c (getkeyblob_data_cb): New.
(call_syshelp_get_keyblob): New.
* g13/mount.c: Include callsyshelp.h.
(g13_mount_container): Ask syshelp whether the filename is managed by
g13tab. Call syshelp to get the encrypted keyblob in this case.
Signed-off-by: Werner Koch <[email protected]>
Diffstat (limited to 'g13/call-syshelp.c')
-rw-r--r-- | g13/call-syshelp.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/g13/call-syshelp.c b/g13/call-syshelp.c index d0f1b0070..952d8de77 100644 --- a/g13/call-syshelp.c +++ b/g13/call-syshelp.c @@ -235,6 +235,52 @@ call_syshelp_find_device (ctrl_t ctrl, const char *name, char **r_blockdev) +static gpg_error_t +getkeyblob_data_cb (void *opaque, const void *data, size_t datalen) +{ + membuf_t *mb = opaque; + + if (data) + put_membuf (mb, data, datalen); + + return 0; +} + + +/* Send the GTEKEYBLOB command to the syshelper. On success the + * encrypted keyblpob is stored at (R_ENCKEYBLOB,R_ENCKEYBLOBLEN). */ +gpg_error_t +call_syshelp_get_keyblob (ctrl_t ctrl, + void **r_enckeyblob, size_t *r_enckeybloblen) +{ + gpg_error_t err; + assuan_context_t ctx; + membuf_t mb; + + *r_enckeyblob = NULL; + *r_enckeybloblen = 0; + init_membuf (&mb, 512); + + err = start_syshelp (ctrl, &ctx); + if (err) + goto leave; + + err = assuan_transact (ctx, "GETKEYBLOB", + getkeyblob_data_cb, &mb, + NULL, NULL, NULL, NULL); + if (err) + goto leave; + *r_enckeyblob = get_membuf (&mb, r_enckeybloblen); + if (!*r_enckeyblob) + err = gpg_error_from_syserror (); + + leave: + xfree (get_membuf (&mb, NULL)); + return err; +} + + + /* Send the DEVICE command to the syshelper. FNAME is the name of the device. */ gpg_error_t |