1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

* findkey.c (agent_public_key_from_file): Fixed array assignment.

This was the cause for random segvs.

* call-agent.c (gpgsm_agent_readkey): New.
This commit is contained in:
Werner Koch 2005-07-25 14:35:04 +00:00
parent 99f403b015
commit a2d1673d66
8 changed files with 91 additions and 24 deletions

View file

@ -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.
*
@ -432,6 +432,51 @@ gpgsm_agent_genkey (ctrl_t ctrl,
return 0;
}
/* 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 */