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

Diff of /trunk/Src/wptGPGME.cpp

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

revision 22 by twoaday, Wed Aug 10 11:33:35 2005 UTC revision 23 by twoaday, Fri Sep 30 10:10:16 2005 UTC
# Line 160  keycache_get_ctx (int is_pub) Line 160  keycache_get_ctx (int is_pub)
160    
161    
162  static int  static int
163  get_key( const char *keyid, gpgme_key_t *r_key, int secret )  get_key (const char *keyid, gpgme_key_t *r_key, struct keycache_s **c, int secret)
164  {  {
165      gpgme_keycache_t cache;      gpgme_keycache_t cache;
166      gpgme_error_t err;      gpgme_error_t err;
# Line 170  get_key( const char *keyid, gpgme_key_t Line 170  get_key( const char *keyid, gpgme_key_t
170          return WPTERR_GENERAL;          return WPTERR_GENERAL;
171      if( r_key )      if( r_key )
172          *r_key = NULL;          *r_key = NULL;
173      cache = keycache_get_ctx( mode );      cache = keycache_get_ctx (mode);
174      if( !cache )      if( !cache )
175          BUG( NULL );          BUG( NULL );
176      err = gpgme_keycache_find_key( cache, keyid, 0, r_key );      if (!c)
177            err = gpgme_keycache_find_key( cache, keyid, 0, r_key );
178        else
179            err = gpgme_keycache_find_key2 (cache, keyid, 0, r_key, c);
180      if( err )      if( err )
181          return WPTERR_GENERAL;          return WPTERR_GENERAL;
182      return 0;      return 0;
# Line 208  get_key2( const char * keyid, gpgme_key_ Line 211  get_key2( const char * keyid, gpgme_key_
211    
212    
213  int  int
214    winpt_get_pubkey (const char *keyid, winpt_key_s *k)
215    {
216        int rc;
217        
218        rc = get_key (keyid, &k->ctx, &k->ext, 0);
219        if (rc)
220            return rc;
221        k->is_v3 = k->ctx->subkeys->pubkey_algo == GPGME_PK_RSA && strlen (k->ctx->subkeys->fpr) == 32;
222        k->is_protected = k->ext->gloflags.is_protected;
223        k->keyid = k->ctx->subkeys->keyid;
224        k->uid = k->ctx->uids->uid;
225        return rc;
226    }
227    
228    
229    int
230    winpt_get_seckey (const char *keyid, winpt_key_s *k)
231    {
232        int rc;
233        rc = get_key (keyid, &k->ctx, &k->ext, 1);
234        if (rc)
235            return rc;
236        k->is_v3 = k->ctx->subkeys->pubkey_algo == GPGME_PK_RSA && strlen (k->ctx->subkeys->fpr) == 32;
237        k->is_protected = k->ext->gloflags.is_protected;
238        k->keyid = k->ctx->subkeys->keyid;
239        k->uid = k->ctx->uids->uid;
240        return rc;
241    }
242    
243    
244    int
245  get_pubkey (const char *keyid, gpgme_key_t *ret_key)  get_pubkey (const char *keyid, gpgme_key_t *ret_key)
246  {  {
247      int rc = 0;      int rc = 0;
248    
249      if (pub && sec)      if (pub && sec)
250          rc = get_key (keyid, ret_key, 0);          rc = get_key (keyid, ret_key, NULL, 0);
251      else      else
252          rc = get_key2 (keyid, ret_key, 0);          rc = get_key2 (keyid, ret_key, 0);
253      return rc;      return rc;
# Line 226  get_seckey( const char *keyid, gpgme_key Line 260  get_seckey( const char *keyid, gpgme_key
260      int rc = 0;      int rc = 0;
261    
262      if( pub && sec )      if( pub && sec )
263          rc = get_key( keyid, ret_skey, 1 );          rc = get_key( keyid, ret_skey, NULL, 1 );
264      else      else
265          rc = get_key2( keyid, ret_skey, 1 );          rc = get_key2( keyid, ret_skey, 1 );
266      return rc;      return rc;
# Line 244  count_insecure_elgkeys (void) Line 278  count_insecure_elgkeys (void)
278      if (!pc)      if (!pc)
279          BUG (0);          BUG (0);
280      while (!gpgme_keycache_next_key (pc, 0, &key)) {      while (!gpgme_keycache_next_key (pc, 0, &key)) {
281          if (gpgme_key_get_ulong_attr (key, GPGME_ATTR_ALGO, NULL, 0)          if (key->subkeys->pubkey_algo == GPGME_PK_ELG)
             == GPGME_PK_ELG_ES)  
282              n++;              n++;
283      }      }
284      gpgme_keycache_rewind (pc);      gpgme_keycache_rewind (pc);

Legend:
Removed from v.22  
changed lines
  Added in v.23

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26