1 |
/* wptKeyCache.h |
2 |
* Copyright (C) 2005 Timo Schulz |
3 |
* |
4 |
* This file is part of WinPT. |
5 |
* |
6 |
* WinPT is free software; you can redistribute it and/or modify |
7 |
* it under the terms of the GNU General Public License as published by |
8 |
* the Free Software Foundation; either version 2 of the License, or |
9 |
* (at your option) any later version. |
10 |
* |
11 |
* WinPT is distributed in the hope that it will be useful, |
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
* GNU General Public License for more details. |
15 |
* |
16 |
* You should have received a copy of the GNU General Public License |
17 |
* along with WinPT; if not, write to the Free Software Foundation, |
18 |
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
19 |
*/ |
20 |
#ifndef WPT_KEYCACHE_H |
21 |
#define WPT_KEYCACHE_H |
22 |
|
23 |
struct keycache_s { |
24 |
struct keycache_s * next; |
25 |
int flags; |
26 |
gpgme_key_t key; /* actual key context. */ |
27 |
struct keycache_s *pubpart; /* corresponding public key. */ |
28 |
struct { |
29 |
unsigned int is_protected:1; /* key is protected. */ |
30 |
unsigned int divert_to_card:1; /* secret key on card. */ |
31 |
unsigned int has_desig_rev:1; /* has desig. revokers. */ |
32 |
} gloflags; |
33 |
struct { |
34 |
unsigned int used:1; |
35 |
unsigned char *d; /* attribute (JPG) data. */ |
36 |
unsigned int len; /* attribute data length. */ |
37 |
gpgme_validity_t validity; /* attribute id validity. */ |
38 |
} attrib; |
39 |
unsigned char *sym_prefs;/* symmetric cipher preferences. */ |
40 |
char *card_type; /* if != NULL key stored on smart card. */ |
41 |
}; |
42 |
|
43 |
struct gpg_keycache_s { |
44 |
struct keycache_s *item; |
45 |
struct keycache_s *tmp; |
46 |
int secret; |
47 |
int pos; |
48 |
void (*cb) (void *, const char *, int, int, int); |
49 |
void *cb_value; |
50 |
int cb_value2; |
51 |
}; |
52 |
typedef struct gpg_keycache_s *gpg_keycache_t; |
53 |
|
54 |
gpgme_error_t gpg_keycache_new (gpg_keycache_t * r_ctx); |
55 |
void gpg_keycache_release (gpg_keycache_t ctx); |
56 |
void gpg_keycache_set_cb (gpg_keycache_t ctx, |
57 |
void (*cb)(void *, const char *, int, int, int), |
58 |
void * cb_value1, int cb_value2); |
59 |
void gpg_keycache_rewind (gpg_keycache_t ctx); |
60 |
int gpg_keycache_get_size (gpg_keycache_t ctx); |
61 |
gpgme_error_t gpg_keycache_add_key (gpg_keycache_t ctx, gpgme_key_t key, |
62 |
void **opaque); |
63 |
gpgme_error_t gpg_keycache_update_key (gpg_keycache_t ctx, int is_sec, |
64 |
void *opaque, const char *keyid); |
65 |
gpgme_error_t gpg_keycache_find_key (gpg_keycache_t ctx, const char * pattern, |
66 |
int flags, gpgme_key_t * r_key); |
67 |
gpgme_error_t gpg_keycache_find_key2 (gpg_keycache_t ctx, const char *pattern, int flags, |
68 |
gpgme_key_t *r_key, struct keycache_s **r_item); |
69 |
gpgme_error_t gpg_keycache_delete_key (gpg_keycache_t ctx, |
70 |
const char * pattern); |
71 |
gpgme_error_t gpg_keycache_init (gpg_keycache_t ctx, const char * pattern, |
72 |
int secret); |
73 |
gpgme_error_t gpg_keycache_next_key (gpg_keycache_t ctx, int flags, |
74 |
gpgme_key_t * r_key); |
75 |
gpgme_error_t gpg_keycache_prepare (gpg_keycache_t ctx, |
76 |
const char *pubring, const char * secring); |
77 |
gpgme_error_t gpg_keycache_prepare_single (gpg_keycache_t ctx, |
78 |
const char *keyid, |
79 |
const char *pubr, |
80 |
const char *secr); |
81 |
gpgme_error_t gpg_keycache_sync (gpg_keycache_t pub, gpg_keycache_t sec); |
82 |
|
83 |
#endif /*WPT_KEYCACHE_H*/ |