Пример #1
0
static void
import_openpgp (const char *filename)
{
  gpg_error_t err;
  char *buffer;
  size_t buflen, nparsed;
  unsigned char *p;
  struct _keybox_openpgp_info info;

  buffer = read_file (filename, &buflen);
  if (!buffer)
    return;
  p = (unsigned char *)buffer;
  for (;;)
    {
      err = _keybox_parse_openpgp (p, buflen, &nparsed, &info);
      assert (nparsed <= buflen);
      if (err)
        {
          if (gpg_err_code (err) == GPG_ERR_NO_DATA)
            break;
          log_info ("%s: failed to parse OpenPGP keyblock: %s\n",
                    filename, gpg_strerror (err));
        }
      else
        {
          dump_openpgp_key (&info, p);
          _keybox_destroy_openpgp_info (&info);
        }
      p += nparsed;
      buflen -= nparsed;
    }
  xfree (buffer);
}
Пример #2
0
static void
import_openpgp (const char *filename)
{
  gpg_error_t err;
  char *buffer;
  size_t buflen, nparsed;
  unsigned char *p;
  struct _keybox_openpgp_info info;

  buffer = read_file (filename, &buflen);
  if (!buffer)
    return;
  p = (unsigned char *)buffer;
  for (;;)
    {
      err = _keybox_parse_openpgp (p, buflen, &nparsed, &info);
      assert (nparsed <= buflen);
      if (err)
        {
          if (gpg_err_code (err) == GPG_ERR_NO_DATA)
            break;
          if (gpg_err_code (err) == GPG_ERR_UNSUPPORTED_ALGORITHM)
            {
              /* This is likely a v3 key packet with a non-RSA
                 algorithm.  These are keys from very early versions
                 of GnuPG (pre-OpenPGP).  */
            }
          else
            {
              fflush (stdout);
              log_info ("%s: failed to parse OpenPGP keyblock: %s\n",
                        filename, gpg_strerror (err));
            }
        }
      else
        {
          dump_openpgp_key (&info, p);
          _keybox_destroy_openpgp_info (&info);
        }
      p += nparsed;
      buflen -= nparsed;
    }
  xfree (buffer);
}