/[winpt]/trunk/Include/wptGPG.h
ViewVC logotype

Annotation of /trunk/Include/wptGPG.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 273 - (hide annotations)
Fri Dec 8 10:22:17 2006 UTC (18 years, 2 months ago) by twoaday
File MIME type: text/plain
File size: 8964 byte(s)


1 werner 37 /* wptGPG.h - GnuPG interface
2 twoaday 175 * Copyright (C) 2000-2006 Timo Schulz
3 werner 37 *
4     * This file is part of WinPT.
5     *
6     * WinPT is free software; you can redistribute it and/or
7     * modify it under the terms of the GNU General Public License
8     * as published by the Free Software Foundation; either version 2
9     * of the License, or (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 GNU
14     * 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    
21     #ifndef WPT_GPG_H
22     #define WPT_GPG_H
23    
24 twoaday 121 #include <gpgme.h>
25 werner 37 #include "wptKeyCache.h"
26     #include "wptNLS.h"
27    
28    
29     #define NO_STRICT 0
30    
31 twoaday 254 /* Macro to indicate if a key is useable or not. */
32 twoaday 179 #define key_is_useable(key) (!(key)->revoked && \
33     !(key)->expired && \
34     !(key)->disabled)
35 werner 37
36     enum setup_t {
37     SETUP_KEYGEN = 1,
38     SETUP_IMPORT = 2,
39 twoaday 260 SETUP_EXISTING = 3,
40     SETUP_CARDGEN = 4
41 werner 37 };
42    
43     enum gpg_cmd_t {
44     GPG_CMD_DECRYPT = 0,
45     GPG_CMD_SIGN = 1
46     };
47    
48     enum keycache_t {
49     KEYCACHE_PRV = 0,
50     KEYCACHE_PUB = 1
51     };
52    
53    
54     struct gpg_card_s;
55 twoaday 179 typedef struct gpg_card_s *gpg_card_t;
56 werner 37
57     /* Keycache refresh context. */
58     struct refresh_cache_s {
59 twoaday 273 int kring_update; /* update the keyring cache. */
60     int sig_update; /* update the signature cache. */
61 werner 37 };
62    
63    
64 twoaday 254 /* Structure for the passphrase callback. */
65 werner 37 struct passphrase_cb_s {
66     int gpg_cmd; /* sign or decrypt. */
67     int pwd_init; /* 1 = passphrase request via dialog. */
68     char *pwd; /* actual passphrase. */
69     char info[1024]; /* hold up the info message */
70     char *title; /* dialog title. */
71     char keyid[16+1]; /* keyid of the secret key the pwd can be used for. */
72     HWND hwnd; /* handle of the dialog window. */
73     int cancel; /* 1 = user cancelled passphrase request. */
74     unsigned int is_card:1; /* 1 = key stored on a smart card. */
75     unsigned int bad_pwd:1; /* 1 = last passphrase was bad. */
76     gpgme_ctx_t gpg;
77     gpgme_recipient_t recipients;
78     struct {
79     int sym_algo;
80     int s2k_mode;
81     int s2k_hash;
82     } sym;
83     };
84    
85    
86     /* This variable is 1 if IDEA is available. */
87     extern int idea_available;
88    
89     /*-- wptGPG.cpp --*/
90 twoaday 254 char* get_gnupg_default_key (void);
91     int set_gnupg_default_key (const char *key);
92 werner 37 char* get_gnupg_config (void);
93     int check_gnupg_config (const char *fname, int *secrings, int *pubrings);
94 twoaday 260 char* get_gnupg_path (void);
95     int check_gnupg_prog (void);
96 werner 37 int gnupg_access_files (void);
97 twoaday 260 char* get_gnupg_prog (void);
98 werner 37 char* get_gnupg_keyring (int pub, int strict);
99     char* get_gnupg_cfgfile (void);
100     int set_gnupg_options( const char *buf, size_t buflen );
101 twoaday 39 int gnupg_load_config (void);
102 twoaday 128 char* multi_gnupg_path (int strict);
103 werner 37
104 twoaday 254 int check_gnupg_options (const char *buf, int showerr);
105 werner 37 void init_gnupg_table (void);
106     void free_gnupg_table (void);
107     int keyring_check_last_access (void);
108     const char* gnupg_check_file_ext (const char *fname, int *r_type);
109     int gpg_check_permissions (int showmsg);
110     int gnupg_check_homedir (void);
111     int gnupg_access_keyring (int _pub);
112     void gnupg_backup_options ();
113 twoaday 229 void gnupg_backup_keyrings (int auto_backup, int backup_mode,
114 twoaday 222 int include_secr);
115 werner 37 int gnupg_copy_keyrings (void);
116 twoaday 137 int check_gnupg_engine (const char *need_gpg_ver,
117     int *r_major, int *r_minor, int *r_patch);
118 werner 37
119     /*-- wptGPGME.cpp --*/
120     const char * get_signature_status( gpgme_sigsum_t sigstat );
121    
122 twoaday 211 gpgme_error_t get_pubkey (const char *keyid, gpgme_key_t *ret_key);
123     gpgme_error_t winpt_get_pubkey (const char *keyid, struct winpt_key_s *k);
124 twoaday 217 void winpt_release_pubkey (winpt_key_s *k);
125 twoaday 211 gpgme_error_t get_seckey (const char *keyid, gpgme_key_t *ret_skey);
126     gpgme_error_t winpt_get_seckey (const char *keyid, struct winpt_key_s *k);
127 werner 37
128     void keycache_release (int cleanup);
129     gpgme_error_t keycache_update (int is_sec, const char *keyid);
130 twoaday 151 gpgme_error_t keycache_init (const char *pubring, const char * secring);
131     gpg_keycache_t keycache_get_ctx (int _pub);
132 werner 37
133 twoaday 226 gpgme_error_t gpg_clip_sym_encrypt (void);
134 twoaday 109 const char *get_gpg_sigstat (gpgme_sigsum_t sum);
135 twoaday 175 int check_ultimate_trusted_key (void);
136 twoaday 214 bool secret_key_available (void);
137 werner 37
138     /*-- wptGPGParser.cpp --*/
139 twoaday 254 enum entry_t {
140     ENTRY_OPAQUE = 1,
141     ENTRY_SINGLE = 2,
142     ENTRY_MULTI = 3,
143     ENTRY_GROUP = 4,
144     };
145    
146 twoaday 271 struct conf_option_s {
147     struct conf_option_s *next;
148 twoaday 254 char *name;
149     char *val;
150     unsigned int used:1;
151     int type;
152     };
153 twoaday 271 typedef struct conf_option_s *conf_option_t;
154 twoaday 254
155 twoaday 271 struct conf_member_s {
156 twoaday 273 struct conf_member_s * next;
157 twoaday 254 char *name;
158     unsigned int used:1;
159     };
160 twoaday 271 typedef struct conf_member_s *conf_member_t;
161 twoaday 254
162 twoaday 271 struct conf_group_s {
163     struct conf_group_s *next;
164     struct conf_member_s *list;
165 twoaday 254 char *name;
166     unsigned int used:1;
167     };
168 twoaday 271 typedef struct conf_group_s *conf_group_t;
169 twoaday 254
170 twoaday 271 struct conf_file_s {
171 twoaday 273 conf_option_t list;
172     conf_group_t grp;
173 twoaday 254 };
174 twoaday 271 typedef struct conf_file_s *config_file_t;
175 twoaday 254
176 twoaday 273 /* find/delete/add */
177     conf_group_t conf_find_group (config_file_t opt, const char *str);
178     conf_option_t conf_find_option (config_file_t opt, const char *str);
179     conf_member_t conf_find_member (config_file_t opt,
180     const char *grp, const char *str);
181     int conf_delete_group (config_file_t opt, const char *str);
182     int conf_delete_member (config_file_t opt, const char *grp, const char *str);
183     int conf_delete_option (config_file_t opt, const char *str);
184     int conf_modify_entry (config_file_t opt, int type, const char *name, const char *val);
185     int conf_add_entry (config_file_t opt, int type, const char *name, const char *val);
186 twoaday 271 int conf_add_entry_int (config_file_t opt, int type, const char *name, int val);
187 twoaday 273 int conf_add_member (config_file_t opt, const char *grp, const char *str);
188     int conf_add_group (config_file_t opt, const char *str);
189 werner 37 /* high-level */
190 twoaday 270 void new_config (config_file_t *r_opt);
191     int parse_config (const char *file, config_file_t *r_opt);
192     int commit_config (const char *file, config_file_t opt);
193     void release_config (config_file_t opt);
194 twoaday 273 void release_group (conf_group_t grp);
195 werner 37
196     /*-- wptPassphraseCB.cpp --*/
197     enum passdlg_t {
198 twoaday 273 PASSDLG_REPEAT = 0, /* indicate the dialig is in the 'repeat passwd' state. */
199     PASSDLG_INIT = 1,
200 twoaday 182 PASSDLG_STRICT = 2,
201 twoaday 229 PASSDLG_NOTEMPTY= 4,
202     PASSDLG_WARN_UTF8=8,
203 werner 37 };
204    
205     void set_gpg_passphrase_cb (passphrase_cb_s *cb, gpgme_ctx_t ctx,
206     int cmd, HWND hwnd, const char *title);
207     void release_gpg_passphrase_cb (passphrase_cb_s *cb);
208 twoaday 214 void release_gpg_recipients (gpgme_recipient_t *recipients);
209 werner 37
210 twoaday 225 char *request_passphrase (const char *title, int flags, int *ret_cancel);
211     char *request_passphrase2 (const char *title, int flags, int *ret_cancel);
212 twoaday 229 char *request_key_passphrase (gpgme_key_t key, const char *title,
213 twoaday 225 int *ret_cancel);
214 werner 37 const char * passphrase_cb (void *opaque, const char * desc, void *r_hd);
215     char * get_key_userid (const char *keyid);
216     int check_passwd_quality (const char *pass, int strict);
217    
218 twoaday 121 /*-- wptClipboard.cpp --*/
219     gpgme_error_t gpg_clip_istext_avail (int *r_val);
220     gpgme_error_t gpg_clip_is_secured (int *r_type, int *r_val);
221     gpgme_error_t gpg_clip_get_pgptype (int *r_type);
222     gpgme_error_t gpg_clip_parse_pgpid (const char *data, int *r_type);
223    
224     /* wptGPGMEData.cpp --*/
225     gpgme_error_t gpg_data_new_from_clipboard (gpgme_data_t *r_dh, int wraplen);
226     void gpg_data_release_and_set_clipboard (gpgme_data_t dh, int chg_ver);
227     size_t gpg_data_readline (gpgme_data_t dh, char *line, size_t nbytes);
228    
229     gpgme_error_t gpg_data_release_and_set_file (gpgme_data_t dh, const char *fname);
230     gpgme_error_t gpg_data_mail_quote (gpgme_data_t *r_dh);
231     gpgme_error_t gpg_data_extract_plaintext (gpgme_data_t sig, gpgme_data_t *r_plain);
232 twoaday 143 void gpg_data_putc (gpgme_data_t hd, int c);
233 twoaday 121
234 werner 37 /*-- wptGPGUtil.cpp --*/
235     gpgme_error_t gpg_rebuild_cache (char **r_inf);
236     gpgme_error_t gpg_get_version (char **r_inf);
237     void gpg_set_debug_mode (int val);
238     gpgme_error_t gpg_export_seckey (const char *keyid, const char *outfile);
239 twoaday 39 gpgme_error_t gpg_manage_ownertrust (char **data, int do_export);
240 twoaday 133 gpgme_error_t gpg_get_photoid_data (const char *keyid, char **r_status_data,
241     unsigned char **r_data,
242     unsigned long *ndata);
243 twoaday 208 gpgme_error_t gpg_revoke_cert (int desig_revoke, const char *inp_data,
244     const char *keyid, char **r_revcert);
245 werner 37 gpgme_error_t gpg_decode_c_string (const char *src, char **destp, size_t len);
246     gpgme_error_t gpg_import_key_list (const char *fname, char **r_out);
247 twoaday 175 gpgme_error_t gpg_extract_keys (const char *keyfile, const char **keys, DWORD nkeys,
248     char **new_keyfile);
249 werner 37 gpgme_error_t get_uat_validity (const char *keyid, gpgme_validity_t *r_valid);
250 twoaday 179 gpgme_error_t gpg_get_recipients (const char *file, gpgme_recipient_t *r_list);
251 twoaday 182 gpgme_error_t gpg_find_key_subpacket (const char *key, int subpktid,
252     char **value);
253 twoaday 273 int gpg_check_return_code (const char *args);
254 werner 37
255     #endif /* WPT_GPG_H */

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26