[PATCH 2/3] Check whether the card has a RNG.

Werner Koch wk at gnupg.org
Tue Apr 5 15:54:25 CEST 2016


On Tue, 29 Mar 2016 16:44, dgouttegattat at incenp.org said:

> +  else if (keywordlen == 6 && !memcmp (keyword, "EXTCAP", keywordlen))
> +    {
> +      /* FIXME: Should we parse the line properly instead of assuming
> +         that the gc capability will always be at the beginning? */
> +      sscanf (line, "gc=%d", &(parm->rng_available));


Yes, please.  Here is a snippet from GnuPG which does this.  I grant you
the right to use this under "GPLv2+ with exception for Mozilla" as used
by Scute.

--8<---------------cut here---------------start------------->8---
  else if (keywordlen == 6 && !memcmp (keyword, "EXTCAP", keywordlen))
    {
      char *p, *p2, *buf;
      int abool;

      buf = p = unescape_status_string (line);
      if (buf)
        {
          for (p = strtok (buf, " "); p; p = strtok (NULL, " "))
            {
              p2 = strchr (p, '=');
              if (p2)
                {
                  *p2++ = 0;
                  abool = (*p2 == '1');
                  if (!strcmp (p, "ki"))
                    parm->extcap.ki = abool;
                  else if (!strcmp (p, "aac"))
                    parm->extcap.aac = abool;
                  else if (!strcmp (p, "si"))
                    parm->status_indicator = strtoul (p2, NULL, 10);
                }
            }
          xfree (buf);
        }
    }
--8<---------------cut here---------------end--------------->8---


Salam-Shalom,

   Werner


-- 
Die Gedanken sind frei.  Ausnahmen regelt ein Bundesgesetz.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 180 bytes
Desc: not available
URL: </pipermail/attachments/20160405/aa1974e3/attachment.sig>


More information about the Gnupg-devel mailing list