~ubuntu-branches/ubuntu/quantal/gnupg2/quantal-security

« back to all changes in this revision

Viewing changes to g10/call-agent.c

  • Committer: Bazaar Package Importer
  • Author(s): Marc Deslauriers
  • Date: 2011-05-25 14:27:35 UTC
  • mfrom: (1.1.15 upstream) (7.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20110525142735-jccyw0fopnyv728q
Tags: 2.0.17-2ubuntu1
* Merge from debian unstable. Remaining changes:
  - Add udev rules to give gpg access to some smartcard readers;
    Debian #543217.
    . debian/gnupg2.dev: udev rules to set ACLs on SCM smartcard readers.
    . debian/rules: Call dh_installudev.
  - debian/control: Rename Vcs-* to XS-Debian-Vcs-*.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#ifdef HAVE_LOCALE_H
30
30
#include <locale.h>
31
31
#endif
 
32
 
 
33
#include "gpg.h"
32
34
#include <assuan.h>
33
 
 
34
 
#include "gpg.h"
35
35
#include "util.h"
36
36
#include "membuf.h"
37
37
#include "options.h"
77
77
};
78
78
 
79
79
 
80
 
static int learn_status_cb (void *opaque, const char *line);
 
80
static gpg_error_t learn_status_cb (void *opaque, const char *line);
81
81
 
82
82
 
83
83
 
230
230
 
231
231
 
232
232
/* This is a dummy data line callback.  */
233
 
static int
 
233
static gpg_error_t
234
234
dummy_data_cb (void *opaque, const void *buffer, size_t length)
235
235
{
236
236
  (void)opaque;
240
240
}
241
241
 
242
242
/* A simple callback used to return the serialnumber of a card.  */
243
 
static int
 
243
static gpg_error_t
244
244
get_serialno_cb (void *opaque, const char *line)
245
245
{
246
246
  char **serialno = opaque;
274
274
 
275
275
/* This is the default inquiry callback.  It mainly handles the
276
276
   Pinentry notifications.  */
277
 
static int
 
277
static gpg_error_t
278
278
default_inq_cb (void *opaque, const char *line)
279
279
{
280
280
  (void)opaque;
312
312
  info->fpr1valid = info->fpr2valid = info->fpr3valid = 0;
313
313
}
314
314
 
315
 
static int
 
315
static gpg_error_t
316
316
learn_status_cb (void *opaque, const char *line)
317
317
{
318
318
  struct agent_card_info_s *parm = opaque;
597
597
/* Handle a CERTDATA inquiry.  Note, we only send the data,
598
598
   assuan_transact takes care of flushing and writing the END
599
599
   command. */
600
 
static int
 
600
static gpg_error_t
601
601
inq_writecert_parms (void *opaque, const char *line)
602
602
{
603
603
  int rc;
645
645
 
646
646
/* Handle a KEYDATA inquiry.  Note, we only send the data,
647
647
   assuan_transact takes care of flushing and writing the end */
648
 
static int
 
648
static gpg_error_t
649
649
inq_writekey_parms (void *opaque, const char *line)
650
650
{
651
651
  int rc;
695
695
 
696
696
 
697
697
/* Status callback for the SCD GENKEY command. */
698
 
static int
 
698
static gpg_error_t
699
699
scd_genkey_cb (void *opaque, const char *line)
700
700
{
701
701
  struct agent_card_genkey_s *parm = opaque;
882
882
 
883
883
 
884
884
 
885
 
static int
 
885
static gpg_error_t
886
886
membuf_data_cb (void *opaque, const void *buffer, size_t length)
887
887
{
888
888
  membuf_t *data = opaque;
892
892
  return 0;
893
893
}
894
894
  
 
895
 
 
896
/* Helper returning a command option to describe the used hash
 
897
   algorithm.  See scd/command.c:cmd_pksign.  */
 
898
static const char *
 
899
hash_algo_option (int algo)
 
900
{
 
901
  switch (algo)
 
902
    {
 
903
    case GCRY_MD_RMD160: return "--hash=rmd160";
 
904
    case GCRY_MD_SHA1  : return "--hash=sha1";
 
905
    case GCRY_MD_SHA224: return "--hash=sha224";
 
906
    case GCRY_MD_SHA256: return "--hash=sha256";
 
907
    case GCRY_MD_SHA384: return "--hash=sha384";
 
908
    case GCRY_MD_SHA512: return "--hash=sha512";
 
909
    case GCRY_MD_MD5   : return "--hash=md5";
 
910
    default:             return "";
 
911
    }
 
912
}
 
913
 
895
914
/* Send a sign command to the scdaemon via gpg-agent's pass thru
896
915
   mechanism. */
897
916
int
937
956
    snprintf (line, DIM(line)-1, "SCD PKAUTH %s", serialno);
938
957
  else
939
958
#endif
940
 
    snprintf (line, DIM(line)-1, "SCD PKSIGN %s%s",
941
 
              hashalgo == GCRY_MD_RMD160? "--hash=rmd160 " : "",
942
 
              serialno);
 
959
    snprintf (line, DIM(line)-1, "SCD PKSIGN %s %s",
 
960
              hash_algo_option (hashalgo), serialno);
943
961
  line[DIM(line)-1] = 0;
944
962
  rc = assuan_transact (agent_ctx, line, membuf_data_cb, &data,
945
963
                        default_inq_cb, NULL, NULL, NULL);