~ubuntu-branches/ubuntu/precise/gnupg2/precise-proposed

« back to all changes in this revision

Viewing changes to sm/call-agent.c

  • Committer: Bazaar Package Importer
  • Author(s): Eric Dorland
  • Date: 2009-03-08 22:46:47 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20090308224647-gq17gatcl71lrc2k
Tags: 2.0.11-1
* New upstream release. (Closes: #496663)
* debian/control: Make the description a little more distinctive than
  gnupg v1's. Thanks Jari Aalto. (Closes: #496323)

Show diffs side-by-side

added added

removed removed

Lines of Context:
232
232
  unsigned char *sigbuf;
233
233
  size_t sigbuflen;
234
234
 
 
235
  (void)desc;
 
236
 
235
237
  *r_buf = NULL;
236
238
 
237
239
  switch(digestalgo)
328
330
{
329
331
  int rc;
330
332
  char line[ASSUAN_LINELENGTH];
331
 
  membuf_t data;
 
333
   membuf_t data;
332
334
  struct cipher_parm_s cipher_parm;
333
335
  size_t n, len;
334
336
  char *p, *buf, *endp;
558
560
 
559
561
 
560
562
/* Ask the agent whether the certificate is in the list of trusted
561
 
   keys.  ROOTCA_FLAGS is guaranteed to be cleared on error. */
 
563
   keys.  The certificate is either specified by the CERT object or by
 
564
   the fingerprint HEXFPR.  ROOTCA_FLAGS is guaranteed to be cleared
 
565
   on error. */
562
566
int
563
 
gpgsm_agent_istrusted (ctrl_t ctrl, ksba_cert_t cert,
 
567
gpgsm_agent_istrusted (ctrl_t ctrl, ksba_cert_t cert, const char *hexfpr,
564
568
                       struct rootca_flags_s *rootca_flags)
565
569
{
566
570
  int rc;
567
 
  char *fpr;
568
571
  char line[ASSUAN_LINELENGTH];
569
572
 
570
573
  memset (rootca_flags, 0, sizeof *rootca_flags);
571
574
 
 
575
  if (cert && hexfpr)
 
576
    return gpg_error (GPG_ERR_INV_ARG);
 
577
 
572
578
  rc = start_agent (ctrl);
573
579
  if (rc)
574
580
    return rc;
575
581
 
576
 
  fpr = gpgsm_get_fingerprint_hexstring (cert, GCRY_MD_SHA1);
577
 
  if (!fpr)
 
582
  if (hexfpr)
578
583
    {
579
 
      log_error ("error getting the fingerprint\n");
580
 
      return gpg_error (GPG_ERR_GENERAL);
 
584
      snprintf (line, DIM(line)-1, "ISTRUSTED %s", hexfpr);
 
585
      line[DIM(line)-1] = 0;
581
586
    }
 
587
  else
 
588
    {
 
589
      char *fpr;
582
590
 
583
 
  snprintf (line, DIM(line)-1, "ISTRUSTED %s", fpr);
584
 
  line[DIM(line)-1] = 0;
585
 
  xfree (fpr);
 
591
      fpr = gpgsm_get_fingerprint_hexstring (cert, GCRY_MD_SHA1);
 
592
      if (!fpr)
 
593
        {
 
594
          log_error ("error getting the fingerprint\n");
 
595
          return gpg_error (GPG_ERR_GENERAL);
 
596
        }
 
597
      
 
598
      snprintf (line, DIM(line)-1, "ISTRUSTED %s", fpr);
 
599
      line[DIM(line)-1] = 0;
 
600
      xfree (fpr);
 
601
    }
586
602
 
587
603
  rc = assuan_transact (agent_ctx, line, NULL, NULL, NULL, NULL,
588
604
                        istrusted_status_cb, rootca_flags);
802
818
                        default_inq_cb, ctrl, NULL, NULL);
803
819
  return rc;
804
820
}
 
821
 
 
822
 
 
823
 
 
824
/* Return 0 if the agent is alive.  This is useful to make sure that
 
825
   an agent has been started. */
 
826
gpg_error_t
 
827
gpgsm_agent_send_nop (ctrl_t ctrl)
 
828
{
 
829
  int rc;
 
830
 
 
831
  rc = start_agent (ctrl);
 
832
  if (!rc)
 
833
    rc = assuan_transact (agent_ctx, "NOP",
 
834
                          NULL, NULL, NULL, NULL, NULL, NULL);
 
835
  return rc;
 
836
}
 
837
 
 
838