~ubuntu-branches/ubuntu/raring/gnupg2/raring-proposed

« back to all changes in this revision

Viewing changes to sm/decrypt.c

  • Committer: Bazaar Package Importer
  • Author(s): Eric Dorland
  • Date: 2010-01-09 21:15:18 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20100109211518-jy03kb8hv1a12gfz
Tags: 2.0.14-1
* New upstream release.
* debian/control: Build depend on libreadline-dev instead of
  libreadline5-dev, since libreadline6-dev is out. (Closes: #548922)
* debian/source/format, debian/source/options,
  debian/source/patch-header: Convert to v3 quilt format, with
  single-debian-patch.
* debian/control: Tighten dependency on gnupg-agent. (Closes: #551792)

Show diffs side-by-side

added added

removed removed

Lines of Context:
253
253
 
254
254
  memset (&dfparm, 0, sizeof dfparm);
255
255
 
 
256
  audit_set_type (ctrl->audit, AUDIT_TYPE_DECRYPT);
 
257
 
256
258
  kh = keydb_new (0);
257
259
  if (!kh)
258
260
    {
296
298
      goto leave;
297
299
    }
298
300
 
 
301
  audit_log (ctrl->audit, AUDIT_SETUP_READY);
 
302
 
299
303
  /* Parser loop. */
300
304
  do 
301
305
    {
313
317
          const char *algoid;
314
318
          int any_key = 0;
315
319
          
 
320
          audit_log (ctrl->audit, AUDIT_GOT_DATA);
 
321
 
316
322
          algoid = ksba_cms_get_content_oid (cms, 2/* encryption algo*/);
317
323
          algo = gcry_cipher_map_name (algoid);
318
324
          mode = gcry_cipher_mode_from_oid (algoid);
330
336
                sprintf (numbuf, "%d", rc);
331
337
                gpgsm_status2 (ctrl, STATUS_ERROR, "decrypt.algorithm",
332
338
                               numbuf, algoid?algoid:"?", NULL);
 
339
                audit_log_s (ctrl->audit, AUDIT_BAD_DATA_CIPHER_ALGO, algoid);
333
340
              }
334
341
 
335
342
              /* If it seems that this is not an encrypted message we
339
346
 
340
347
              goto leave;
341
348
            }
 
349
 
 
350
          audit_log_i (ctrl->audit, AUDIT_DATA_CIPHER_ALGO, algo);
342
351
          dfparm.algo = algo;
343
352
          dfparm.mode = mode;
344
353
          dfparm.blklen = gcry_cipher_get_algo_blklen (algo);
369
378
              rc = ksba_cms_get_issuer_serial (cms, recp, &issuer, &serial);
370
379
              if (rc == -1 && recp)
371
380
                break; /* no more recipients */
 
381
              audit_log_i (ctrl->audit, AUDIT_NEW_RECP, recp);
372
382
              if (rc)
373
383
                log_error ("recp %d - error getting info: %s\n",
374
384
                           recp, gpg_strerror (rc));
382
392
                  gpgsm_dump_serial (serial);
383
393
                  log_printf ("\n");
384
394
 
 
395
                  if (ctrl->audit)
 
396
                    {
 
397
                      char *tmpstr = gpgsm_format_sn_issuer (serial, issuer);
 
398
                      audit_log_s (ctrl->audit, AUDIT_RECP_NAME, tmpstr);
 
399
                      xfree (tmpstr);
 
400
                    }
 
401
 
385
402
                  keydb_search_reset (kh);
386
403
                  rc = keydb_search_issuer_sn (kh, issuer, serial);
387
404
                  if (rc)
415
432
                                   kidbuf, "0", "0", NULL);
416
433
                  }
417
434
 
 
435
                  /* Put the certificate into the audit log.  */
 
436
                  audit_log_cert (ctrl->audit, AUDIT_SAVE_CERT, cert, 0);
418
437
 
419
438
                  /* Just in case there is a problem with the own
420
439
                     certificate we print this message - should never
462
481
                                              decrypt_filter,
463
482
                                              &dfparm);
464
483
                    }
 
484
                  audit_log_ok (ctrl->audit, AUDIT_RECP_RESULT, rc);
465
485
                }
466
486
              xfree (hexkeygrip);
467
487
              xfree (desc);
468
488
            }
 
489
 
 
490
          /* If we write an audit log add the unused recipients to the
 
491
             log as well.  */
 
492
          if (ctrl->audit && any_key)
 
493
            {
 
494
              for (;; recp++)
 
495
                {
 
496
                  char *issuer;
 
497
                  ksba_sexp_t serial;
 
498
                  int tmp_rc;
 
499
 
 
500
                  tmp_rc = ksba_cms_get_issuer_serial (cms, recp,
 
501
                                                       &issuer, &serial);
 
502
                  if (tmp_rc == -1)
 
503
                    break; /* no more recipients */
 
504
                  audit_log_i (ctrl->audit, AUDIT_NEW_RECP, recp);
 
505
                  if (tmp_rc)
 
506
                    log_error ("recp %d - error getting info: %s\n",
 
507
                               recp, gpg_strerror (rc));
 
508
                  else
 
509
                    {
 
510
                      char *tmpstr = gpgsm_format_sn_issuer (serial, issuer);
 
511
                      audit_log_s (ctrl->audit, AUDIT_RECP_NAME, tmpstr);
 
512
                      xfree (tmpstr);
 
513
                      xfree (issuer);
 
514
                      xfree (serial);
 
515
                    }
 
516
                }
 
517
            }
 
518
 
469
519
          if (!any_key)
470
520
            {
471
521
              rc = gpg_error (GPG_ERR_NO_SECKEY);
488
538
                                      dfparm.lastblock, 
489
539
                                      dfparm.blklen - npadding);
490
540
              if (rc)
491
 
                  goto leave;
 
541
                goto leave;
492
542
 
493
543
              for (i=dfparm.blklen - npadding; i < dfparm.blklen; i++)
494
544
                {
515
565
 
516
566
 
517
567
 leave:
 
568
  audit_log_ok (ctrl->audit, AUDIT_DECRYPTION_RESULT, rc);
518
569
  if (rc)
519
570
    {
520
571
      gpgsm_status (ctrl, STATUS_DECRYPTION_FAILED, NULL);