~ubuntu-branches/ubuntu/natty/gnupg2/natty-security

« back to all changes in this revision

Viewing changes to sm/call-agent.c

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Urlichs
  • Date: 2005-12-08 22:13:21 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20051208221321-4rvs2vu835iam5wv
Tags: 1.9.19-2
* Convert debian/changelog to UTF-8.
* Put gnupg-agent and gpgsm lintian overrides in the respectively
  right package.  Closes: #335066
* Added debhelper tokens to maintainer scripts.
* xsession fixes:
  o Added host name to gpg-agent PID file name.  Closes: #312717
  o Fixed xsession script to be able to run under zsh.  Closes: #308516
  o Don't run gpg-agent if one is already running.  Closes: #336480
* debian/control:
  o Fixed package description of gpgsm package.  Closes: #299842
  o Added mention of gpg-agent to description of gnupg-agent package.
    Closes: #304355
* Thanks to Peter Eisentraut <petere@debian.org> for all of the above.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* call-agent.c - divert operations to the agent
2
 
 *      Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
 
2
 *      Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
3
3
 *
4
4
 * This file is part of GnuPG.
5
5
 *
39
39
#include "../common/membuf.h"
40
40
 
41
41
 
42
 
static ASSUAN_CONTEXT agent_ctx = NULL;
 
42
static assuan_context_t agent_ctx = NULL;
43
43
static int force_pipe_server = 0;
44
44
 
45
 
struct cipher_parm_s {
46
 
  ASSUAN_CONTEXT ctx;
47
 
  const char *ciphertext;
 
45
struct cipher_parm_s
 
46
{
 
47
  assuan_context_t ctx;
 
48
  const unsigned char *ciphertext;
48
49
  size_t ciphertextlen;
49
50
};
50
51
 
51
 
struct genkey_parm_s {
52
 
  ASSUAN_CONTEXT ctx;
53
 
  const char *sexp;
 
52
struct genkey_parm_s
 
53
{
 
54
  assuan_context_t ctx;
 
55
  const unsigned char *sexp;
54
56
  size_t sexplen;
55
57
};
56
58
 
57
 
struct learn_parm_s {
 
59
struct learn_parm_s
 
60
{
58
61
  int error;
59
 
  ASSUAN_CONTEXT ctx;
 
62
  assuan_context_t ctx;
60
63
  membuf_t *data;
61
64
};
62
65
 
144
147
        }
145
148
      *p++ = 0;
146
149
      pid = atoi (p);
147
 
      while (*p && *p != ':')
 
150
      while (*p && *p != PATHSEP_C)
148
151
        p++;
149
152
      prot = *p? atoi (p+1) : 0;
150
153
      if (prot != 1)
204
207
int
205
208
gpgsm_agent_pksign (ctrl_t ctrl, const char *keygrip, const char *desc,
206
209
                    unsigned char *digest, size_t digestlen, int digestalgo,
207
 
                    char **r_buf, size_t *r_buflen )
 
210
                    unsigned char **r_buf, size_t *r_buflen )
208
211
{
209
212
  int rc, i;
210
213
  char *p, line[ASSUAN_LINELENGTH];
392
395
  struct genkey_parm_s gk_parm;
393
396
  membuf_t data;
394
397
  size_t len;
395
 
  char *buf;
 
398
  unsigned char *buf;
396
399
 
397
400
  *r_pubkey = NULL;
398
401
  rc = start_agent (ctrl);
430
433
}
431
434
 
432
435
 
 
436
/* Call the agent to read the public key part for a given keygrip.  */
 
437
int
 
438
gpgsm_agent_readkey (ctrl_t ctrl, const char *hexkeygrip,
 
439
                     ksba_sexp_t *r_pubkey)
 
440
{
 
441
  int rc;
 
442
  membuf_t data;
 
443
  size_t len;
 
444
  unsigned char *buf;
 
445
  char line[ASSUAN_LINELENGTH];
 
446
 
 
447
  *r_pubkey = NULL;
 
448
  rc = start_agent (ctrl);
 
449
  if (rc)
 
450
    return rc;
 
451
 
 
452
  rc = assuan_transact (agent_ctx, "RESET",NULL, NULL, NULL, NULL, NULL, NULL);
 
453
  if (rc)
 
454
    return map_assuan_err (rc);
 
455
 
 
456
  snprintf (line, DIM(line)-1, "READKEY %s", hexkeygrip);
 
457
  line[DIM(line)-1] = 0;
 
458
 
 
459
  init_membuf (&data, 1024);
 
460
  rc = assuan_transact (agent_ctx, line,
 
461
                        membuf_data_cb, &data, 
 
462
                        NULL, NULL, NULL, NULL);
 
463
  if (rc)
 
464
    {
 
465
      xfree (get_membuf (&data, &len));
 
466
      return map_assuan_err (rc);
 
467
    }
 
468
  buf = get_membuf (&data, &len);
 
469
  if (!buf)
 
470
    return gpg_error (GPG_ERR_ENOMEM);
 
471
  if (!gcry_sexp_canon_len (buf, len, NULL, NULL))
 
472
    {
 
473
      xfree (buf);
 
474
      return gpg_error (GPG_ERR_INV_SEXP);
 
475
    }
 
476
  *r_pubkey = buf;
 
477
  return 0;
 
478
}
 
479
 
 
480
 
433
481
/* Ask the agent whether the certificate is in the list of trusted
434
482
   keys */
435
483
int