diff options
author | Werner Koch <[email protected]> | 2005-07-25 14:35:04 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2005-07-25 14:35:04 +0000 |
commit | a2d1673d6622e39c41f061e1bffb5ca05c803320 (patch) | |
tree | 292c3b03237aab155753bb3dddc141235e0c1e55 /sm/call-agent.c | |
parent | * gpgsm.c (main): New options --no-log-file and --debug-none. (diff) | |
download | gnupg-a2d1673d6622e39c41f061e1bffb5ca05c803320.tar.gz gnupg-a2d1673d6622e39c41f061e1bffb5ca05c803320.zip |
* findkey.c (agent_public_key_from_file): Fixed array assignment.
This was the cause for random segvs.
* call-agent.c (gpgsm_agent_readkey): New.
Diffstat (limited to '')
-rw-r--r-- | sm/call-agent.c | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/sm/call-agent.c b/sm/call-agent.c index 92a29928c..c47f6b19a 100644 --- a/sm/call-agent.c +++ b/sm/call-agent.c @@ -1,5 +1,5 @@ /* call-agent.c - divert operations to the agent - * Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc. + * Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc. * * This file is part of GnuPG. * @@ -433,6 +433,51 @@ gpgsm_agent_genkey (ctrl_t ctrl, } +/* Call the agent to read the public key part for a given keygrip. */ +int +gpgsm_agent_readkey (ctrl_t ctrl, const char *hexkeygrip, + ksba_sexp_t *r_pubkey) +{ + int rc; + membuf_t data; + size_t len; + unsigned char *buf; + char line[ASSUAN_LINELENGTH]; + + *r_pubkey = NULL; + rc = start_agent (ctrl); + if (rc) + return rc; + + rc = assuan_transact (agent_ctx, "RESET",NULL, NULL, NULL, NULL, NULL, NULL); + if (rc) + return map_assuan_err (rc); + + snprintf (line, DIM(line)-1, "READKEY %s", hexkeygrip); + line[DIM(line)-1] = 0; + + init_membuf (&data, 1024); + rc = assuan_transact (agent_ctx, line, + membuf_data_cb, &data, + NULL, NULL, NULL, NULL); + if (rc) + { + xfree (get_membuf (&data, &len)); + return map_assuan_err (rc); + } + buf = get_membuf (&data, &len); + if (!buf) + return gpg_error (GPG_ERR_ENOMEM); + if (!gcry_sexp_canon_len (buf, len, NULL, NULL)) + { + xfree (buf); + return gpg_error (GPG_ERR_INV_SEXP); + } + *r_pubkey = buf; + return 0; +} + + /* Ask the agent whether the certificate is in the list of trusted keys */ int |