1 |
twoaday |
38 |
/* wptKeyCache.h |
2 |
twoaday |
146 |
* Copyright (C) 2005, 2006 Timo Schulz |
3 |
twoaday |
38 |
* |
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 |
twoaday |
151 |
enum keycache_flag_t { |
24 |
|
|
KC_FLAG_ADD = 1, |
25 |
|
|
KC_FLAG_UPD = 2 |
26 |
|
|
}; |
27 |
|
|
|
28 |
twoaday |
182 |
/* key specifc attributes. */ |
29 |
|
|
enum keycache_attr_t { |
30 |
|
|
KC_ATTR_PREFSYM = 11, |
31 |
|
|
KC_ATTR_PREFKSERV = 24 |
32 |
|
|
}; |
33 |
|
|
|
34 |
|
|
|
35 |
twoaday |
38 |
struct keycache_s { |
36 |
twoaday |
167 |
struct keycache_s *next; |
37 |
twoaday |
38 |
int flags; |
38 |
|
|
gpgme_key_t key; /* actual key context. */ |
39 |
twoaday |
167 |
unsigned int default_key:1; /* default signing key. */ |
40 |
twoaday |
38 |
struct keycache_s *pubpart; /* corresponding public key. */ |
41 |
|
|
struct { |
42 |
|
|
unsigned int is_protected:1; /* key is protected. */ |
43 |
|
|
unsigned int divert_to_card:1; /* secret key on card. */ |
44 |
|
|
unsigned int has_desig_rev:1; /* has desig. revokers. */ |
45 |
|
|
} gloflags; |
46 |
|
|
struct { |
47 |
twoaday |
133 |
unsigned int flags; |
48 |
twoaday |
38 |
unsigned char *d; /* attribute (JPG) data. */ |
49 |
|
|
unsigned int len; /* attribute data length. */ |
50 |
|
|
gpgme_validity_t validity; /* attribute id validity. */ |
51 |
|
|
} attrib; |
52 |
|
|
unsigned char *sym_prefs;/* symmetric cipher preferences. */ |
53 |
twoaday |
182 |
char *pref_keyserver; /* if != NULL preferred keyserver. */ |
54 |
twoaday |
38 |
char *card_type; /* if != NULL key stored on smart card. */ |
55 |
|
|
}; |
56 |
|
|
|
57 |
|
|
struct gpg_keycache_s { |
58 |
|
|
struct keycache_s *item; |
59 |
|
|
struct keycache_s *tmp; |
60 |
|
|
int secret; |
61 |
|
|
int pos; |
62 |
twoaday |
167 |
void (*cb) (void*, const char*, int, int, int); |
63 |
twoaday |
38 |
void *cb_value; |
64 |
|
|
int cb_value2; |
65 |
|
|
}; |
66 |
|
|
typedef struct gpg_keycache_s *gpg_keycache_t; |
67 |
|
|
|
68 |
|
|
gpgme_error_t gpg_keycache_new (gpg_keycache_t * r_ctx); |
69 |
|
|
void gpg_keycache_release (gpg_keycache_t ctx); |
70 |
|
|
void gpg_keycache_set_cb (gpg_keycache_t ctx, |
71 |
|
|
void (*cb)(void *, const char *, int, int, int), |
72 |
twoaday |
167 |
void* cb_value1, int cb_value2); |
73 |
twoaday |
38 |
void gpg_keycache_rewind (gpg_keycache_t ctx); |
74 |
|
|
int gpg_keycache_get_size (gpg_keycache_t ctx); |
75 |
|
|
gpgme_error_t gpg_keycache_add_key (gpg_keycache_t ctx, gpgme_key_t key, |
76 |
|
|
void **opaque); |
77 |
|
|
gpgme_error_t gpg_keycache_update_key (gpg_keycache_t ctx, int is_sec, |
78 |
|
|
void *opaque, const char *keyid); |
79 |
twoaday |
167 |
gpgme_error_t gpg_keycache_find_key (gpg_keycache_t ctx, const char *pattern, |
80 |
twoaday |
38 |
int flags, gpgme_key_t * r_key); |
81 |
twoaday |
167 |
gpgme_error_t gpg_keycache_find_key2 (gpg_keycache_t ctx, |
82 |
|
|
const char *pattern, int flags, |
83 |
|
|
gpgme_key_t *r_key, |
84 |
|
|
struct keycache_s **r_item); |
85 |
twoaday |
38 |
gpgme_error_t gpg_keycache_delete_key (gpg_keycache_t ctx, |
86 |
|
|
const char * pattern); |
87 |
|
|
gpgme_error_t gpg_keycache_init (gpg_keycache_t ctx, const char * pattern, |
88 |
|
|
int secret); |
89 |
|
|
gpgme_error_t gpg_keycache_next_key (gpg_keycache_t ctx, int flags, |
90 |
|
|
gpgme_key_t * r_key); |
91 |
|
|
gpgme_error_t gpg_keycache_prepare (gpg_keycache_t ctx, |
92 |
twoaday |
167 |
const char *pubring, |
93 |
|
|
const char *secring); |
94 |
twoaday |
38 |
gpgme_error_t gpg_keycache_prepare_single (gpg_keycache_t ctx, |
95 |
|
|
const char *keyid, |
96 |
|
|
const char *pubr, |
97 |
|
|
const char *secr); |
98 |
|
|
gpgme_error_t gpg_keycache_sync (gpg_keycache_t pub, gpg_keycache_t sec); |
99 |
twoaday |
146 |
gpgme_error_t gpg_keycache_next_updated_key (gpg_keycache_t ctx, |
100 |
twoaday |
151 |
struct keycache_s **r_obj, |
101 |
|
|
int *r_status); |
102 |
twoaday |
167 |
gpgme_error_t gpg_keycache_set_default_key (gpg_keycache_t ctx, |
103 |
|
|
const char *pattern); |
104 |
|
|
gpgme_error_t gpg_keycache_get_default_key (gpg_keycache_t ctx, |
105 |
|
|
gpgme_key_t *r_key); |
106 |
twoaday |
182 |
gpgme_error_t gpg_keycache_update_attr (struct keycache_s *item, |
107 |
|
|
int attr, int force); |
108 |
twoaday |
38 |
|
109 |
|
|
#endif /*WPT_KEYCACHE_H*/ |