75 |
} |
} |
76 |
|
|
77 |
|
|
78 |
int |
gpgme_error_t |
79 |
gpgme_keycache_add_key( gpgme_keycache_t ctx, gpgme_key_t key ) |
gpgme_keycache_add_key (gpgme_keycache_t ctx, gpgme_key_t key, void **opaque) |
80 |
{ |
{ |
81 |
struct keycache_s * c, * n1; |
struct keycache_s * c, * n1; |
82 |
|
|
94 |
; |
; |
95 |
n1->next = c; |
n1->next = c; |
96 |
} |
} |
97 |
|
if (opaque) |
98 |
|
*opaque = c; |
99 |
return 0; |
return 0; |
100 |
} /* gpgme_keycache_add_key */ |
} /* gpgme_keycache_add_key */ |
101 |
|
|
120 |
|
|
121 |
if (strstr (pattern, "0x")) |
if (strstr (pattern, "0x")) |
122 |
pattern += 2; |
pattern += 2; |
123 |
/* fixme: this is VERY slow, se we should use the GPGME original code */ |
/* XXX: this code is very slow, revamp it and use hash tables whenever |
124 |
|
it is possible. */ |
125 |
for (c = ctx->item; c; c = c->next) { |
for (c = ctx->item; c; c = c->next) { |
126 |
if (is_deleted_item (c)) |
if (is_deleted_item (c)) |
127 |
continue; |
continue; |
161 |
|
|
162 |
|
|
163 |
gpgme_error_t |
gpgme_error_t |
164 |
|
gpgme_keycache_update_key (gpgme_keycache_t ctx, int is_sec, void *opaque, |
165 |
|
const char *keyid) |
166 |
|
{ |
167 |
|
struct keycache_s *c = NULL; |
168 |
|
gpgme_key_t key=NULL, fndkey=NULL; |
169 |
|
gpgme_error_t err; |
170 |
|
|
171 |
|
err = gpgme_op_keylist_getkey (is_sec, keyid, &key); |
172 |
|
if (err) |
173 |
|
return err; |
174 |
|
err = keycache_find_key (ctx, keyid, 0, &fndkey, &c); |
175 |
|
if (!err && c != NULL) { |
176 |
|
gpgme_key_release (c->key); |
177 |
|
c->key = key; |
178 |
|
c->flags = 0; |
179 |
|
} |
180 |
|
else { |
181 |
|
gpgme_keycache_t pub = (gpgme_keycache_t)opaque; |
182 |
|
if (is_sec && !keycache_find_key (pub, keyid, 0, &fndkey, &c)) { |
183 |
|
fndkey->gloflags.is_protected = c->key->gloflags.is_protected; |
184 |
|
fndkey->gloflags.divert_to_card = c->key->gloflags.divert_to_card; |
185 |
|
} |
186 |
|
gpgme_keycache_add_key (ctx, key, &c); |
187 |
|
DEBUG3 ("keycache update: is_sec=%d keyid=%s %p\r\n", is_sec, keyid, c); |
188 |
|
if (is_sec) |
189 |
|
c->pubpart = fndkey; |
190 |
|
} |
191 |
|
return 0; |
192 |
|
} |
193 |
|
|
194 |
|
gpgme_error_t |
195 |
gpgme_keycache_delete_key (gpgme_keycache_t ctx, const char * pattern) |
gpgme_keycache_delete_key (gpgme_keycache_t ctx, const char * pattern) |
196 |
{ |
{ |
197 |
struct keycache_s * c = NULL; |
struct keycache_s *c = NULL; |
198 |
gpgme_key_t key; |
gpgme_key_t key; |
199 |
gpgme_error_t rc; |
gpgme_error_t rc; |
200 |
|
|
208 |
|
|
209 |
|
|
210 |
gpgme_error_t |
gpgme_error_t |
211 |
gpgme_keycache_init( gpgme_keycache_t ctx, const char *pattern, int secret ) |
gpgme_keycache_init (gpgme_keycache_t ctx, const char *pattern, int secret) |
212 |
{ |
{ |
213 |
gpgme_error_t err; |
gpgme_error_t err; |
214 |
gpgme_ctx_t c; |
gpgme_ctx_t c; |
231 |
{ |
{ |
232 |
err = gpgme_op_keylist_next (c, &key); |
err = gpgme_op_keylist_next (c, &key); |
233 |
if (!err) |
if (!err) |
234 |
err = gpgme_keycache_add_key (ctx, key); |
err = gpgme_keycache_add_key (ctx, key, NULL); |
235 |
} |
} |
236 |
if (err == GPGME_EOF) |
if (err == GPGME_EOF) |
237 |
err = 0; |
err = 0; |
276 |
int |
int |
277 |
gpgme_keycache_count (gpgme_keycache_t ctx) |
gpgme_keycache_count (gpgme_keycache_t ctx) |
278 |
{ |
{ |
279 |
struct keycache_s * c; |
struct keycache_s *c; |
280 |
int count = 0; |
int count = 0; |
281 |
|
|
282 |
if (!ctx) |
if (!ctx) |
305 |
return mk_error (Invalid_Value); |
return mk_error (Invalid_Value); |
306 |
} |
} |
307 |
|
|
308 |
if (r_key) |
*r_key = flags? ctx->tmp->pubpart : ctx->tmp->key; |
|
*r_key = flags? ctx->tmp->pubpart : ctx->tmp->key; |
|
309 |
|
|
310 |
ctx->tmp = ctx->tmp->next; |
ctx->tmp = ctx->tmp->next; |
311 |
ctx->pos++; |
ctx->pos++; |