/[winpt]/trunk/Src/wptGPGUtil.cpp
ViewVC logotype

Diff of /trunk/Src/wptGPGUtil.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 32 by twoaday, Mon Oct 24 08:03:48 2005 UTC revision 33 by twoaday, Tue Oct 25 07:46:20 2005 UTC
# Line 207  create_tmpfile (const char *name) Line 207  create_tmpfile (const char *name)
207      sattr.lpSecurityDescriptor = NULL;      sattr.lpSecurityDescriptor = NULL;
208      sattr.nLength = sizeof sattr;      sattr.nLength = sizeof sattr;
209    
210      GetTempPath (sizeof (tmp)-1 - 64, tmp);      GetTempPath (sizeof (tmp)-1 - strlen (name)-1, tmp);
211      strcat (tmp, name);      strcat (tmp, name);
212      out = CreateFile (tmp, GENERIC_READ|GENERIC_WRITE,      out = CreateFile (tmp, GENERIC_READ|GENERIC_WRITE,
213                        FILE_SHARE_WRITE, &sattr,                        FILE_SHARE_WRITE, &sattr,
# Line 506  gpg_revoke_key (const char *inp_data, co Line 506  gpg_revoke_key (const char *inp_data, co
506      if (!p)      if (!p)
507          return gpg_error (GPG_ERR_INV_ARG);          return gpg_error (GPG_ERR_INV_ARG);
508    
509      cmd = (char*)calloc (1, strlen (p) + 128);      cmd = (char*)calloc (1, strlen (p) + strlen (keyid)+1 + 128);
510      if (!cmd)      if (!cmd)
511          abort ();          abort ();
512      sprintf (cmd, "%s --pgp7 --command-fd=0 --status-fd=2 --gen-revoke %s",      sprintf (cmd, "%s --pgp7 --command-fd=0 --status-fd=2 --gen-revoke %s",
# Line 530  gpg_revoke_key (const char *inp_data, co Line 530  gpg_revoke_key (const char *inp_data, co
530      CloseHandle (out);      CloseHandle (out);
531      return err;      return err;
532  }  }
533    
534    
535    /* Return the validity of the user attribute, informerly known
536       as photo-ID. If no uat was found, return 0 for unknown. */
537    gpgme_error_t
538    get_uat_validity (const char *keyid, gpgme_validity_t *r_valid)
539    {
540        gpgme_error_t err = gpg_error (GPG_ERR_NO_ERROR);
541        HANDLE out;
542        char *p, *cmd;
543        char *uat;
544    
545        *r_valid = GPGME_VALIDITY_UNKNOWN;
546        p = read_w32_registry (HKEY_CURRENT_USER,
547                               "Software\\GNU\\GnuPG", "gpgProgram");
548        if (!p)
549            return gpg_error (GPG_ERR_INV_ARG);
550    
551        cmd = (char*)calloc (1, strlen (p) + strlen (keyid)+1 + 128);
552        if (!cmd)
553            abort ();
554        sprintf (cmd, "%s --with-colons --fixed-list-mode --list-keys \"%s\"",
555                 p, keyid);
556    
557        out = create_tmpfile ("gpg_keys");
558        if (create_process (cmd, NULL, out))
559            err = gpg_error (GPG_ERR_INTERNAL);
560    
561        free (p);
562        free (cmd);
563        
564        p = map_tmpfile (out);
565        if ((uat = strstr (p, "uat:"))) {
566            switch (*(uat+4)) {
567            case 'm': *r_valid = GPGME_VALIDITY_MARGINAL; break;
568            case 'f':
569            case 'u': *r_valid = GPGME_VALIDITY_FULL; break;
570            default: *r_valid = GPGME_VALIDITY_UNDEFINED; break;
571            }
572        }
573    
574        free (p);    
575        CloseHandle (out);
576        return err;
577    }
578    
579    
580    #if 0
581    /* Extract all recipients from the file @file.
582       Return value: 0 on success. */
583    static int
584    do_get_recipients (const char *file, gpgme_recipient_t *r_list)
585    {
586        gpgme_recipient_t l;
587        PACKET *pkt;
588        gpg_iobuf_t inp = NULL;
589        armor_filter_context_t afx;
590        int rc = 0, quit=0;
591    
592        if (!file || !r_list) {
593            log_debug ("do_list_packets: !r_list || !file");
594            return -1;
595        }
596    
597        *r_list=NULL;
598        inp = gpg_iobuf_open (file);
599        if (!inp)
600            return WPTERR_FILE_OPEN;
601        gpg_iobuf_ioctl (inp, 3, 1, NULL); /* disable cache */
602        if (gpg_use_armor_filter (inp)) {
603            memset (&afx, 0, sizeof (afx));
604            gpg_iobuf_push_filter (inp, gpg_armor_filter, &afx);
605        }
606        pkt = (PACKET *)calloc(1, sizeof *pkt);
607        gpg_init_packet (pkt);
608        while (!quit && (rc = gpg_parse_packet (inp, pkt)) != -1) {
609            switch (pkt->pkttype) {
610            case PKT_PUBKEY_ENC:
611                {PKT_pubkey_enc *enc = pkt->pkt.pubkey_enc;
612                if (!enc)
613                    break;
614                l = calloc (1, sizeof *l);
615                l->keyid = calloc (1, 16+1);
616                _snprintf (l->keyid, 16, "%08lX%08lX", enc->keyid[0], enc->keyid[1]);
617                l->pubkey_algo = enc->pubkey_algo;
618                l->status = 0;
619                l->next = (*r_list);
620                *r_list = l;
621                break;}
622    
623            case PKT_ENCRYPTED:    
624            case PKT_ENCRYPTED_MDC:
625            case PKT_COMPRESSED:
626            case PKT_PUBLIC_KEY:
627            case PKT_SECRET_KEY:
628                quit = 1;
629                break;
630            }
631            gpg_free_packet (pkt);
632            gpg_init_packet (pkt);
633        }
634        gpg_iobuf_close (inp);
635        safe_free (pkt);
636        return 0;
637    }
638    #endif

Legend:
Removed from v.32  
changed lines
  Added in v.33

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26