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

« back to all changes in this revision

Viewing changes to scd/app-p15.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:
2363
2363
  for (; certinfo; certinfo = certinfo->next)
2364
2364
    {
2365
2365
      char *buf, *p;
2366
 
      int i;
2367
2366
 
2368
2367
      buf = xtrymalloc (9 + certinfo->objidlen*2 + 1);
2369
2368
      if (!buf)
2375
2374
          p += 5;
2376
2375
        }
2377
2376
      p = stpcpy (p, ".");
2378
 
      for (i=0; i < certinfo->objidlen; i++)
2379
 
        {
2380
 
          sprintf (p, "%02X", certinfo->objid[i]);
2381
 
          p += 2;
2382
 
        }
 
2377
      bin2hex (certinfo->objid, certinfo->objidlen, p);
2383
2378
 
2384
2379
      send_status_info (ctrl, "CERTINFO",
2385
2380
                        certtype, strlen (certtype),
2458
2453
    {
2459
2454
      char gripstr[40+1];
2460
2455
      char *buf, *p;
2461
 
      int i, j;
 
2456
      int j;
2462
2457
 
2463
2458
      buf = xtrymalloc (9 + keyinfo->objidlen*2 + 1);
2464
2459
      if (!buf)
2470
2465
          p += 5;
2471
2466
        }
2472
2467
      p = stpcpy (p, ".");
2473
 
      for (i=0; i < keyinfo->objidlen; i++)
2474
 
        {
2475
 
          sprintf (p, "%02X", keyinfo->objid[i]);
2476
 
          p += 2;
2477
 
        }
 
2468
      bin2hex (keyinfo->objid, keyinfo->objidlen, p);
2478
2469
 
2479
2470
      err = keygripstr_from_prkdf (app, keyinfo, gripstr);
2480
2471
      if (err)
2669
2660
do_getattr (app_t app, ctrl_t ctrl, const char *name)
2670
2661
{
2671
2662
  gpg_error_t err;
2672
 
  int i;
2673
2663
 
2674
2664
  if (!strcmp (name, "$AUTHKEYID"))
2675
2665
    {
2694
2684
              p += 5;
2695
2685
            }
2696
2686
          p = stpcpy (p, ".");
2697
 
          for (i=0; i < prkdf->objidlen; i++)
2698
 
            {
2699
 
              sprintf (p, "%02X", prkdf->objid[i]);
2700
 
              p += 2;
2701
 
            }
 
2687
          bin2hex (prkdf->objid, prkdf->objidlen, p);
2702
2688
 
2703
2689
          send_status_info (ctrl, name, buf, strlen (buf), NULL, 0);
2704
2690
          xfree (buf);
2948
2934
      
2949
2935
      mse[0] = 4;    /* Length of the template. */
2950
2936
      mse[1] = 0x80; /* Algorithm reference tag. */
2951
 
      if (hashalgo == GCRY_MD_USER_TLS_MD5SHA1)
 
2937
      if (hashalgo == MD_USER_TLS_MD5SHA1)
2952
2938
        mse[2] = 0x01; /* Let card do pkcs#1 0xFF padding. */
2953
2939
      else
2954
2940
        mse[2] = 0x02; /* RSASSA-PKCS1-v1.5 using SHA1. */
3124
3110
  if (indatalen == 36)
3125
3111
    {
3126
3112
      /* No ASN.1 container used. */
3127
 
      if (hashalgo != GCRY_MD_USER_TLS_MD5SHA1)
 
3113
      if (hashalgo != MD_USER_TLS_MD5SHA1)
3128
3114
        return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM);
3129
3115
      memcpy (data, indata, indatalen);
3130
3116
    }
3187
3173
      return err;
3188
3174
    }
3189
3175
 
3190
 
  if (hashalgo == GCRY_MD_USER_TLS_MD5SHA1)
 
3176
  if (hashalgo == MD_USER_TLS_MD5SHA1)
3191
3177
    err = iso7816_compute_ds (app->slot, data, 36, outdata, outdatalen);
3192
3178
  else if (no_data_padding)
3193
3179
    err = iso7816_compute_ds (app->slot, data+15, 20, outdata, outdatalen);
3226
3212
      return gpg_error (GPG_ERR_WRONG_KEY_USAGE);
3227
3213
    }
3228
3214
 
3229
 
  algo = indatalen == 36? GCRY_MD_USER_TLS_MD5SHA1 : GCRY_MD_SHA1;
 
3215
  algo = indatalen == 36? MD_USER_TLS_MD5SHA1 : GCRY_MD_SHA1;
3230
3216
  return do_sign (app, keyidstr, algo, pincb, pincb_arg, 
3231
3217
                  indata, indatalen, outdata, outdatalen);
3232
3218
}