~ubuntu-branches/ubuntu/precise/gnutls28/precise

« back to all changes in this revision

Viewing changes to src/certtool-common.c

  • Committer: Package Import Robot
  • Author(s): Andreas Metzler
  • Date: 2011-09-20 19:37:06 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20110920193706-a9phjijvddzg3nkl
Tags: 3.0.3-1
* New upstream version. (Includes a fix for #640639)
* Bump shlibs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
607
607
  return pubkey;
608
608
}
609
609
 
 
610
int
 
611
get_bits (gnutls_pk_algorithm_t key_type, int info_bits, const char* info_sec_param)
 
612
{
 
613
  int bits;
 
614
 
 
615
  if (info_bits != 0)
 
616
    {
 
617
      static int warned = 0;
 
618
 
 
619
      if (warned == 0)
 
620
        {
 
621
          warned = 1;
 
622
          fprintf (stderr,
 
623
                   "** Note: Please use the --sec-param instead of --bits\n");
 
624
        }
 
625
      bits = info_bits;
 
626
    }
 
627
  else
 
628
    {
 
629
      if (info_sec_param)
 
630
        {
 
631
          bits =
 
632
            gnutls_sec_param_to_pk_bits (key_type,
 
633
                                         str_to_sec_param (info_sec_param));
 
634
        }
 
635
      else
 
636
        bits =
 
637
          gnutls_sec_param_to_pk_bits (key_type, GNUTLS_SEC_PARAM_NORMAL);
 
638
    }
 
639
 
 
640
  return bits;
 
641
}
 
642
 
 
643
gnutls_sec_param_t str_to_sec_param (const char *str)
 
644
{
 
645
  if (strcasecmp (str, "low") == 0)
 
646
    {
 
647
      return GNUTLS_SEC_PARAM_LOW;
 
648
    }
 
649
  else if (strcasecmp (str, "normal") == 0)
 
650
    {
 
651
      return GNUTLS_SEC_PARAM_NORMAL;
 
652
    }
 
653
  else if (strcasecmp (str, "high") == 0)
 
654
    {
 
655
      return GNUTLS_SEC_PARAM_HIGH;
 
656
    }
 
657
  else if (strcasecmp (str, "ultra") == 0)
 
658
    {
 
659
      return GNUTLS_SEC_PARAM_ULTRA;
 
660
    }
 
661
  else
 
662
    {
 
663
      fprintf (stderr, "Unknown security parameter string: %s\n", str);
 
664
      exit (1);
 
665
    }
 
666
 
 
667
}