/[winpt]/trunk/MyGPGME/gpgme.h
ViewVC logotype

Contents of /trunk/MyGPGME/gpgme.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 21 - (show annotations)
Wed Jul 27 11:17:44 2005 UTC (19 years, 7 months ago) by twoaday
File MIME type: text/plain
File size: 31528 byte(s)
2005-07-22  Timo Schulz  <twoaday@freakmail.de>
 
        * gpgme.c (_gpgme_add_comment): Forgot to alloc an extra
        byte for the '0'. This fixes a lot of crashes related to
        file operations.
        * keylist.c (gpgme_op_keylist_getkey): Use the param for
        'pub' or 'sec' mode.
        * keycache.c (gpgme_keycache_update_key): If the key is
        not in the cache, add it and if the cache contain secret
        key, sync it with the pub cache.
        * editkey.c (edit_key_colon_handler): Allocate 1 byte for
        the NUL-char.  This also fixes a lot of reported crashes
        related to the showpref feature.
 


1 /* gpgme.h - My GnuPG Made Easy (MyGPGME)
2 * Copyright (C) 2000 Werner Koch (dd9jn)
3 * Copyright (C) 2001-2005 Timo Schulz
4 *
5 * This file is part of MyGPGME.
6 *
7 * MyGPGME is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * MyGPGME is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
20 */
21
22 #ifndef GPGME_H
23 #define GPGME_H
24
25 #include <stdio.h> /* for FILE * */
26 #include <time.h> /* for time_t */
27
28 #ifdef __cplusplus
29 extern "C" {
30 #if 0 /* just to make Emacs auto-indent happy */
31 }
32 #endif
33 #endif
34
35
36 /*
37 * The version of this header should match the one of the library
38 * It should not be used by a program because gpgme_check_version(NULL)
39 * does return the same version. The purpose of this macro is to
40 * let autoconf (using the AM_PATH_GPGME macro) check that this
41 * header matches the installed library.
42 * Warning: Do not edit the next line. configure will do that for you! */
43 #define GPGME_VERSION "20050418ts"
44
45 struct gpgme_context_s;
46 typedef struct gpgme_context_s *gpgme_ctx_t;
47
48 struct gpgme_data_s;
49 typedef struct gpgme_data_s *gpgme_data_t;
50
51 struct gpgme_recipients_s;
52 typedef struct gpgme_recipients_s *gpgme_recipients_t;
53
54 struct gpgme_key_s;
55 typedef struct gpgme_key_s *gpgme_key_t;
56
57 struct gpgme_keycache_s;
58 typedef struct gpgme_keycache_s *gpgme_keycache_t;
59
60 struct gpgme_signature_s;
61 typedef struct gpgme_signature_s *gpgme_sig_t;
62
63 struct gpgme_editkey_s;
64 typedef struct gpgme_editkey_s *gpgme_editkey_t;
65
66 struct gpgme_editcard_s;
67 typedef struct gpgme_editcard_s *gpgme_editcard_t;
68
69 struct gpgme_card_s;
70 typedef struct gpgme_card_s *gpgme_card_t;
71
72 struct gpgme_user_id_info_s;
73 typedef struct gpgme_user_id_info_s *gpgme_uidinfo_t;
74
75 struct gpgme_rev_cert_s;
76 typedef struct gpgme_rev_cert_s *gpgme_revcert_t;
77
78
79 typedef enum {
80 GPGME_EOF = -1,
81 GPGME_No_Error = 0,
82 GPGME_General_Error = 1,
83 GPGME_Out_Of_Core = 2,
84 GPGME_Invalid_Value = 3,
85 GPGME_Busy = 4,
86 GPGME_No_Request = 5,
87 GPGME_Exec_Error = 6,
88 GPGME_Too_Many_Procs = 7,
89 GPGME_Pipe_Error = 8,
90 GPGME_No_Recipients = 9,
91 GPGME_No_Data = 10,
92 GPGME_Conflict = 11,
93 GPGME_Not_Implemented = 12,
94 GPGME_Read_Error = 13,
95 GPGME_Write_Error = 14,
96 GPGME_Invalid_Type = 15,
97 GPGME_Invalid_Mode = 16,
98 GPGME_File_Error = 17, /* errno is set in this case */
99 GPGME_Decryption_Failed = 18,
100 GPGME_Signing_Failed = 19,
101 GPGME_Encryption_Failed = 29,
102 GPGME_No_Passphrase = 20,
103 GPGME_No_Seckey = 21,
104 GPGME_No_Pubkey = 27,
105 GPGME_Canceled = 22,
106 GPGME_Invalid_Key = 23,
107 GPGME_Invalid_Engine = 24,
108 GPGME_Bad_Signature = 25,
109 GPGME_Bad_Passphrase = 26,
110 GPGME_Inv_Recipients = 28,
111 GPGME_Internal_GPG_Problem = 30,
112 GPGME_Clip_Open = 31,
113 GPGME_Clip_Empty = 32,
114 GPGME_Clip_Get = 33,
115 GPGME_Cipher_IDEA = 34,
116 GPGME_Conf_InvOption = 35,
117 GPGME_SC_Failure = 36,
118
119 /* Recipient Errors */
120 GPGME_RecpError_NoReason = 100,
121 GPGME_RecpError_NotFound = 101,
122 GPGME_RecpError_Ambigious = 102,
123 GPGME_RecpError_WrongKeyUsage = 103,
124 GPGME_RecpError_Revoked = 104,
125 GPGME_RecpError_Expired = 105,
126 GPGME_RecpError_NotSecret = 109,
127 GPGME_RecpError_Untrusted = 110,
128 } gpgme_error_t;
129
130 typedef enum {
131 GPGME_DATA_TYPE_NONE = 0,
132 GPGME_DATA_TYPE_MEM = 1,
133 GPGME_DATA_TYPE_FD = 2,
134 GPGME_DATA_TYPE_FILE = 3,
135 GPGME_DATA_TYPE_CB = 4
136 } gpgme_data_type_t;
137
138 typedef enum {
139 GPGME_SIG_STAT_NONE = 0,
140 GPGME_SIG_STAT_GOOD = 1,
141 GPGME_SIG_STAT_BAD = 2,
142 GPGME_SIG_STAT_NOKEY = 3,
143 GPGME_SIG_STAT_NOSIG = 4,
144 GPGME_SIG_STAT_ERROR = 5,
145 GPGME_SIG_STAT_DIFF = 6,
146 GPGME_SIG_STAT_E_GOOD= 7,
147 GPGME_SIG_STAT_R_GOOD= 8,
148 } gpgme_sigstat_t;
149
150 typedef enum {
151 GPGME_SIGF_NONE = 0,
152 GPGME_SIGF_LOCAL = 1,
153 GPGME_SIGF_NREV = 2
154 } gpgme_sigflat_t;
155
156 typedef enum {
157 GPGME_SIG_MODE_NORMAL = 0,
158 GPGME_SIG_MODE_DETACH = 1,
159 GPGME_SIG_MODE_CLEAR = 2
160 } gpgme_sigmode_t;
161
162 typedef enum {
163 GPGME_ATTR_KEYID = 1,
164 GPGME_ATTR_FPR = 2,
165 GPGME_ATTR_ALGO = 3,
166 GPGME_ATTR_ALGO_SHORT = 4,
167 GPGME_ATTR_LEN = 5,
168 GPGME_ATTR_CREATED = 6,
169 GPGME_ATTR_EXPIRE = 7,
170 GPGME_ATTR_EXPIRES = 8,
171 GPGME_ATTR_OTRUST = 9,
172 GPGME_ATTR_USERID = 10,
173 GPGME_ATTR_NAME = 11,
174 GPGME_ATTR_EMAIL = 12,
175 GPGME_ATTR_COMMENT = 13,
176 GPGME_ATTR_VALIDITY = 14,
177 GPGME_ATTR_LEVEL = 15,
178 GPGME_ATTR_TYPE = 16,
179 GPGME_ATTR_IS_SECRET = 17,
180 GPGME_ATTR_IS_ULTIMATE = 18,
181 GPGME_ATTR_IS_PROTECTED = 19,
182 GPGME_ATTR_MDC = 20,
183 GPGME_ATTR_NOTATION = 21,
184 GPGME_ATTR_POLICY_URL = 22,
185 GPGME_ATTR_REVKEY_ALGO = 23,
186 GPGME_ATTR_REVKEY_FPR = 24,
187 GPGME_ATTR_OPAQUE = 25,
188 GPGME_ATTR_MD = 26,
189 GPGME_ATTR_PHOTO = 27,
190 GPGME_ATTR_CAN_ENCRYPT = 28,
191 GPGME_ATTR_CAN_SIGN = 29,
192 GPGME_ATTR_CAN_CERTIFY = 30,
193 GPGME_ATTR_CAN_AUTH = 31,
194 GPGME_ATTR_DIVERT_CARD = 32,
195 GPGME_ATTR_KEYSERVER = 33,
196 GPGME_ATTR_VERSION = 34,
197
198 GPGME_ATTR_KEYDAT_NP = 50,
199 GPGME_ATTR_KEYDAT_BITS = 51,
200 GPGME_ATTR_KEYDAT_VAL = 52,
201
202 GPGME_ATTR_KEY_REVOKED = 100,
203 GPGME_ATTR_KEY_INVALID = 101,
204 GPGME_ATTR_KEY_EXPIRED = 102,
205 GPGME_ATTR_KEY_DISABLED = 103,
206 GPGME_ATTR_KEY_CAPS = 104,
207 GPGME_ATTR_KEY_SYMPREFS = 105,
208 GPGME_ATTR_KEY_VALIDITY = 106,
209 GPGME_ATTR_KEY_CARDNO = 107,
210 GPGME_ATTR_KEY_USABLE = 108,
211
212 GPGME_ATTR_UID_REVOKED = 150,
213 GPGME_ATTR_UID_INVALID = 151,
214 GPGME_ATTR_UID_PRIMARY = 152,
215 GPGME_ATTR_UID_PREFS = 153,
216 GPGME_ATTR_UID_CREATED = 154,
217 GPGME_ATTR_UID_HASH = 155,
218
219 GPGME_ATTR_SIG_ALGO = 200,
220 GPGME_ATTR_SIG_KEYID = 201,
221 GPGME_ATTR_SIG_ISSUER = 202,
222 GPGME_ATTR_SIG_CREATED = 203,
223 GPGME_ATTR_SIG_EXPIRES = 204,
224 GPGME_ATTR_SIG_STAT = 205,
225 GPGME_ATTR_SIG_USERID = 206,
226 GPGME_ATTR_SIG_CLASS = 206,
227 GPGME_ATTR_SIG_FLAGS = 207,
228
229 GPGME_ATTR_CARD_AID = 250,
230 GPGME_ATTR_CARD_VER = 251,
231 GPGME_ATTR_CARD_VENDOR = 252,
232 GPGME_ATTR_CARD_SERIAL = 253,
233 GPGME_ATTR_CARD_NAME = 254,
234 GPGME_ATTR_CARD_NAME2 = 255,
235 GPGME_ATTR_CARD_LANG = 256,
236 GPGME_ATTR_CARD_SEX = 257,
237 GPGME_ATTR_CARD_URL = 258,
238 GPGME_ATTR_CARD_LOGIN = 259,
239 GPGME_ATTR_CARD_MAXPINLEN=260,
240 GPGME_ATTR_CARD_SIGCOUNT= 261,
241 GPGME_ATTR_CARD_FPR = 262
242 } gpgme_attr_t;
243
244 typedef enum {
245 GPGME_EDITKEY_SIGN = 1,
246 GPGME_EDITKEY_LSIGN = 2,
247 GPGME_EDITKEY_NRSIGN = 19,
248 GPGME_EDITKEY_NRLSIGN = 22,
249 GPGME_EDITKEY_TSIGN = 20,
250 GPGME_EDITKEY_TRUST = 3,
251 GPGME_EDITKEY_ADDUID = 4,
252 GPGME_EDITKEY_DELUID = 5,
253 GPGME_EDITKEY_DELKEY = 6,
254 GPGME_EDITKEY_ADDKEY = 7,
255 GPGME_EDITKEY_PASSWD = 8,
256 GPGME_EDITKEY_PRIMARY = 9,
257 GPGME_EDITKEY_EXPIRE = 10,
258 GPGME_EDITKEY_REVSIG = 11,
259 GPGME_EDITKEY_REVKEY = 12,
260 GPGME_EDITKEY_REVOKE = 13, /* revoke the whole key */
261 GPGME_EDITKEY_ADDREV = 14,
262 GPGME_EDITKEY_ADDPHOTO= 15,
263 GPGME_EDITKEY_ENABLE = 16,
264 GPGME_EDITKEY_DISABLE = 17,
265 GPGME_EDITKEY_SETPREF = 18,
266 GPGME_EDITKEY_DELSIG = 21,
267 GPGME_EDITKEY_KEYSERV = 23
268 } gpgme_edit_key_t;
269
270
271 typedef enum {
272 GPGME_EDITCARD_NAME = 1,
273 GPGME_EDITCARD_NAME2 = 2,
274 GPGME_EDITCARD_KEYURL = 3,
275 GPGME_EDITCARD_LOGIN = 4,
276 GPGME_EDITCARD_SEX = 5,
277 GPGME_EDITCARD_LANG = 6,
278 GPGME_EDITCARD_APIN = 7,
279 GPGME_EDITCARD_UPIN = 8,
280 GPGME_EDITCARD_GENKEY = 9,
281 GPGME_EDITCARD_FETCH = 10,
282 GPGME_EDITCARD_CAFPR = 11,
283 /* change pin */
284 GPGME_EDITCARD_CHAPIN = 20,
285 GPGME_EDITCARD_CHUPIN = 21,
286 GPGME_EDITCARD_UNBPIN = 22 /*unblock PIN*/
287 } gpgme_edit_card_t;
288
289 typedef enum {
290 GPGME_CARDFLAG_NONE = 0,
291 GPGME_CARDFLAG_REPLACE = 1,
292 GPGME_CARDFLAG_BAKENC = 2
293 } gpgme_cardflag_t;
294
295 typedef enum {
296 GPGME_VALIDITY_UNKNOWN = 0,
297 GPGME_VALIDITY_UNDEFINED = 1,
298 GPGME_VALIDITY_NEVER = 2,
299 GPGME_VALIDITY_MARGINAL = 3,
300 GPGME_VALIDITY_FULL = 4,
301 GPGME_VALIDITY_ULTIMATE = 5,
302 GPGME_VALIDITY_REVOKED = 6,
303 GPGME_VALIDITY_EXPIRED = 7
304 } gpgme_validity_t;
305
306 typedef enum {
307 GPGME_TRUST_UNKNOWN = 0,
308 GPGME_TRUST_DONTKNOW = 1,
309 GPGME_TRUST_NEVER = 2,
310 GPGME_TRUST_MARGINAL = 3,
311 GPGME_TRUST_FULLY = 4,
312 GPGME_TRUST_ULTIMATE = 5,
313 GPGME_TRUST_UNDEFINED = 6,
314 GPGME_TRUST_EXPIRED = 7
315 } GpgmeOwnertrust;
316
317 typedef enum {
318 GPGME_CTRL_ARMOR = 1,
319 GPGME_CTRL_TEXTMODE = 2,
320 GPGME_CTRL_THROWKEYID = 4,
321 GPGME_CTRL_LISTMODE = 8,
322 GPGME_CTRL_FORCETRUST = 16,
323 GPGME_CTRL_SIGMODE = 32,
324 GPGME_CTRL_CIPHER = 64,
325 GPGME_CTRL_PASSPWD = 128,
326 GPGME_CTRL_TMPFILES = 256,
327 GPGME_CTRL_WITH_SECRET_KEY = 512,
328 GPGME_CTRL_FORCEOPT = 1024,
329 GPGME_CTRL_FILE = 2048,
330 GPGME_CTRL_FPR = 4096,
331 GPGME_CTRL_S2K = 8192,
332 GPGME_CTRL_S2K_MODE = 16384,
333 GPGME_CTRL_S2K_HASH = 32678,
334 GPGME_CTRL_INTERACTIVE = 65536,
335 GPGME_CTRL_PIPEMODE = 131072,
336 GPGME_CTRL_LOGGING = 262144,
337 GPGME_CTRL_NO_COMPR = 524288,
338 GPGME_CTRL_CB_VAL = 1048576
339 } gpgme_control_t;
340
341 typedef enum {
342 GPGME_LISTMODE_NORMAL = 0,
343 GPGME_LISTMODE_NOTRUST = 1,
344 GPGME_LISTMODE_KEYDATA = 2,
345 GPGME_LISTMODE_FAST = 4
346 } gpgme_listmode_t;
347
348 typedef enum {
349 GPGME_LISTOPT_NONE = 0,
350 GPGME_LISTOPT_SIGSUBPKT = 1
351 } gpgme_listopt_t;
352
353 typedef enum {
354 GPGME_KEYGEN_NONE = 0,
355 GPGME_KEYGEN_DSA_ELG = 1,
356 GPGME_KEYGEN_DSA_RSA = 2,
357 GPGME_KEYGEN_DSA_SIG = 3,
358 GPGME_KEYGEN_RSA_SIG = 4,
359 GPGME_KEYGEN_RSA = 5,
360 GPGME_KEYGEN_RSA_RSA = 6 /*PGP*/
361 } gpgme_keygen_t;
362
363 typedef enum {
364 GPGME_IMPSTAT_NPKEYS = 0,
365 GPGME_IMPSTAT_NOSELFSIG = 1,
366 GPGME_IMPSTAT_IPKEYS = 2,
367 GPGME_IMPSTAT_NUIDS = 5,
368 GPGME_IMPSTAT_NSUBKEYS = 6,
369 GPGME_IMPSTAT_NSIGS = 7,
370 GPGME_IMPSTAT_NREV = 8,
371 GPGME_IMPSTAT_NSKEYS = 9,
372 GPGME_IMPSTAT_ISKEYS = 10
373 } gpgme_import_status_t;
374
375
376 typedef enum {
377 GPGME_REVOKE_INSECURE = 1,
378 GPGME_REVOKE_SUPERSEDED = 2,
379 GPGME_REVOKE_NOUSED = 3
380 } gpgme_revoke_reason_t;
381
382
383 typedef enum {
384 GPGME_OPFLAG_NOSECKEY = 1,
385 GPGME_OPFLAG_BADMDC = 2,
386 GPGME_OPFLAG_BADARMOR = 4
387 } gpgme_op_flags_t;
388
389
390 typedef enum {
391 GPGME_PGP_MESSAGE = 1,
392 GPGME_PGP_CLEARSIG = 2,
393 GPGME_PGP_SIG = 4,
394 GPGME_PGP_PUBKEY = 8,
395 GPGME_PGP_SECKEY = 16,
396 GPGME_PGP_DASH_ESCAPED = 32 /* actually not a type, just a flag */
397 } gpgme_pgptype_t;
398
399 typedef enum {
400 GPGME_CIPHER_3DES = 1,
401 GPGME_CIPHER_CAST5 = 2,
402 GPGME_CIPHER_BLOWFISH = 3,
403 GPGME_CIPHER_AES128 = 4,
404 GPGME_CIPHER_AES192 = 5,
405 GPGME_CIPHER_AES256 = 6,
406 GPGME_CIPHER_TWOFISH = 7
407 } gpgme_cipher_t;
408
409 typedef enum {
410 GPGME_S2K_SIMPLE = 0,
411 GPGME_S2K_SALTED = 1,
412 GPGME_S2K_ITERSALTED = 3
413 } gpgme_s2kmode_t;
414
415
416 typedef enum {
417 GPGME_PK_RSA = 1,
418 GPGME_PK_RSA_E = 2,
419 GPGME_PK_RSA_S = 3,
420 GPGME_PK_ELG_E = 16,
421 GPGME_PK_DSA = 17,
422 GPGME_PK_ELG_ES = 20
423 } gpgme_pk_cipher_t;
424
425 typedef enum {
426 GPGME_MD_SHA1 = 2,
427 GPGME_MD_RMD160 = 3
428 } gpgme_md_t;
429
430
431 #define GPGME_KEY_CANSIGN 0x01
432 #define GPGME_KEY_CANENCR 0x02
433
434 typedef const char *(*gpgme_passphrase_cb_t)( void*, const char *desc,
435 void * r_hd );
436
437 typedef const char *(*gpgme_interactive_cb_t)( void * opaque,
438 int code, const char * key,
439 const char * val );
440 typedef void (*gpgme_progress_cb_t)( void * opaque,
441 const char * what,
442 int type, unsigned current, unsigned total );
443
444 typedef void (*gpgme_wipe_t)( const char *path, int simple );
445
446
447 /* Initialize the library */
448 gpgme_error_t gpgme_lib_init (void);
449 void gpgme_lib_cleanup (void);
450
451 /* Context management */
452 gpgme_error_t gpgme_new( gpgme_ctx_t * r_ctx );
453 void gpgme_release( gpgme_ctx_t ctx );
454 void gpgme_cancel( gpgme_ctx_t ctx );
455 gpgme_ctx_t gpgme_wait( gpgme_ctx_t c, int hang );
456
457 gpgme_error_t gpgme_get_enc_to_ctx( gpgme_ctx_t c, gpgme_recipients_t *r_ctx );
458 void gpgme_clear_enc_to_ctx (gpgme_ctx_t ctx);
459 char * gpgme_get_notation (gpgme_ctx_t ctx);
460 char * gpgme_get_logging (gpgme_ctx_t ctx);
461 gpgme_error_t gpgme_check_logging (gpgme_ctx_t ctx);
462 void gpgme_set_comment (gpgme_ctx_t c, const char * text);
463 void * gpgme_control( gpgme_ctx_t c, int cmd, int val );
464 void gpgme_set_passphrase_cb( gpgme_ctx_t c,
465 gpgme_passphrase_cb_t cb, void *cb_value );
466 void gpgme_set_interactive_cb( gpgme_ctx_t ctx,
467 gpgme_interactive_cb_t cb, void * cb_value );
468 void gpgme_set_progress_cb( gpgme_ctx_t c,
469 gpgme_progress_cb_t cb, void * cb_value );
470 void gpgme_set_wipe_fnc( gpgme_ctx_t c, gpgme_wipe_t fnc );
471 void gpgme_set_local_user( gpgme_ctx_t ctx, const char * name );
472 int gpgme_get_process_rc( gpgme_ctx_t ctx );
473
474 void gpgme_signers_clear( gpgme_ctx_t ctx );
475 gpgme_error_t gpgme_signers_add( gpgme_ctx_t ctx, const gpgme_key_t key );
476 gpgme_key_t gpgme_signers_enum( const gpgme_ctx_t c, int seq );
477 gpgme_error_t gpgme_get_sig_key( gpgme_ctx_t ctx, int idx, gpgme_key_t *r_key );
478 gpgme_error_t gpgme_get_sig_ctx( gpgme_ctx_t ctx, int idx, size_t *r_ncount,
479 gpgme_sig_t *r_sig );
480
481 /* Functions to handle recipients */
482 gpgme_error_t gpgme_recipients_new( gpgme_recipients_t *r_rset );
483 void gpgme_recipients_release( gpgme_recipients_t rset );
484 gpgme_error_t gpgme_recipients_add_name( gpgme_recipients_t rset,
485 const char *name );
486 gpgme_error_t gpgme_recipients_add_name_with_validity( gpgme_recipients_t rset,
487 const char *name,
488 gpgme_validity_t val );
489 unsigned int gpgme_recipients_count (const gpgme_recipients_t rset);
490 const char* gpgme_recipients_get_name (const gpgme_recipients_t rset, int pos);
491 gpgme_error_t gpgme_recipients_enum_open( const gpgme_recipients_t rset,
492 void ** ctx );
493 const char * gpgme_recipients_enum_read( const gpgme_recipients_t rset,
494 void ** ctx );
495 gpgme_error_t gpgme_recipients_enum_close( const gpgme_recipients_t rset,
496 void ** ctx );
497
498 int gpgme_recperr_count_items( gpgme_ctx_t ctx );
499 const char * gpgme_recperr_get( gpgme_ctx_t ctx, int idx,
500 gpgme_error_t * r_code );
501
502 /* Functions to handle data sources */
503 gpgme_error_t gpgme_data_new( gpgme_data_t *r_dh );
504 gpgme_error_t gpgme_data_new_from_mem( gpgme_data_t *r_dh,
505 const char *buffer, size_t size,
506 int copy );
507 gpgme_error_t gpgme_data_new_with_read_cb( gpgme_data_t *r_dh,
508 int (*read_cb)(void*,char *,size_t,size_t*),
509 void *read_cb_value );
510
511 gpgme_error_t gpgme_data_new_from_file (gpgme_data_t *r_dh,
512 const char *fname);
513 gpgme_error_t gpgme_data_new_from_filepart( gpgme_data_t * r_dh,
514 const char * fname, FILE * fp,
515 long offset,
516 unsigned long length );
517 void gpgme_data_release( gpgme_data_t dh );
518 char * gpgme_data_release_and_get_mem( gpgme_data_t dh,
519 size_t * r_len );
520 gpgme_data_type_t gpgme_data_get_type( gpgme_data_t dh );
521 gpgme_error_t gpgme_data_rewind( gpgme_data_t dh );
522 gpgme_error_t gpgme_data_read( gpgme_data_t dh,
523 char *buffer, size_t length, size_t *nread );
524 gpgme_error_t gpgme_data_write( gpgme_data_t dh,
525 const char *buffer, size_t length );
526 #define gpgme_data_putc( dh, c ) do { \
527 unsigned char buf[2]; \
528 buf[0] = c & 0xFF; buf[1] = 0x00; \
529 gpgme_data_write( dh, buf, 1 ); \
530 } while( 0 )
531
532 /* Key and trust functions */
533 gpgme_error_t gpgme_key_append (gpgme_key_t dst, gpgme_key_t src, int idx);
534 void gpgme_key_ref( gpgme_key_t key );
535 void gpgme_key_unref( gpgme_key_t key );
536 void gpgme_key_release( gpgme_key_t key );
537 const char * gpgme_key_get_string_attr( gpgme_key_t key, gpgme_attr_t what,
538 void **reserved, int idx );
539 unsigned long gpgme_key_get_ulong_attr( gpgme_key_t key, gpgme_attr_t what,
540 void **reserved, int idx );
541
542 /* Key management functions */
543 gpgme_error_t gpgme_op_keylist_start (gpgme_ctx_t ctx,
544 const char *pattern, int secret_only);
545 gpgme_error_t gpgme_op_keylist_next (gpgme_ctx_t ctx, gpgme_key_t * r_key);
546 gpgme_error_t gpgme_op_keylist_getkey (int is_sec, const char *pattern,
547 gpgme_key_t *r_key);
548
549 /* Convenience functions for normal usage */
550 gpgme_error_t gpgme_op_encrypt ( gpgme_ctx_t c, gpgme_recipients_t recp,
551 gpgme_data_t in, gpgme_data_t out );
552 gpgme_error_t gpgme_op_file_encrypt( gpgme_ctx_t ctx, gpgme_recipients_t rset,
553 const char * input, const char * output );
554 gpgme_error_t gpgme_op_files_encrypt( gpgme_ctx_t ctx, gpgme_recipients_t rset,
555 const char ** files, size_t nfiles );
556 gpgme_error_t gpgme_op_clip_encrypt( gpgme_recipients_t rset, int opts,
557 gpgme_ctx_t * r_ctx );
558
559 gpgme_error_t gpgme_op_list_keys( gpgme_data_t ciph, const char * file,
560 gpgme_recipients_t * r_rset );
561 gpgme_error_t gpgme_op_decrypt( gpgme_ctx_t ctx, gpgme_data_t ciph,
562 gpgme_data_t plain );
563 gpgme_error_t gpgme_op_file_decrypt( gpgme_ctx_t ctx, const char * ciph,
564 const char * plain );
565 gpgme_error_t gpgme_op_files_decrypt( gpgme_ctx_t ctx, const char ** files,
566 size_t nfiles );
567 gpgme_error_t gpgme_op_clip_decrypt( gpgme_ctx_t ctx );
568
569 gpgme_error_t gpgme_op_sign ( gpgme_ctx_t c, gpgme_data_t in, gpgme_data_t out,
570 gpgme_sigmode_t mode );
571 gpgme_error_t gpgme_op_clip_sign( gpgme_ctx_t ctx, gpgme_sigmode_t mode,
572 const char * keyid, int wraplen );
573 gpgme_error_t gpgme_op_file_sign( gpgme_ctx_t ctx, gpgme_sigmode_t mode,
574 const char *input, const char *output );
575 gpgme_error_t gpgme_op_files_sign( gpgme_ctx_t ctx, gpgme_sigmode_t mode,
576 const char ** files, size_t nfiles );
577
578 gpgme_error_t gpgme_op_verify ( gpgme_ctx_t c, gpgme_data_t sig,
579 gpgme_data_t text );
580 gpgme_error_t gpgme_op_file_verify( gpgme_ctx_t ctx, gpgme_sigmode_t sigmode,
581 gpgme_sig_t * r_sigctx,
582 const char * sigfile, const char * datfile );
583 gpgme_error_t gpgme_op_files_verify( gpgme_ctx_t ctx, const char ** files,
584 size_t nfiles, gpgme_sig_t * ret_sig );
585 gpgme_error_t gpgme_op_clip_verify( gpgme_keycache_t cache,
586 gpgme_sig_t * r_sigctx );
587 gpgme_error_t gpgme_op_clip_verify_detached( gpgme_keycache_t cache,
588 gpgme_sig_t * r_sigctx,
589 const char * data, size_t len );
590
591 gpgme_error_t gpgme_op_import( gpgme_ctx_t ctx, gpgme_recipients_t selkeys,
592 gpgme_data_t keydata );
593 gpgme_error_t gpgme_op_clip_import( int ctrl, gpgme_recipients_t selkeys,
594 int * import_res );
595 gpgme_error_t gpgme_op_file_import( gpgme_ctx_t ctx, gpgme_recipients_t selkeys,
596 const char *input );
597 gpgme_error_t gpgme_op_import_list( gpgme_ctx_t ctx, gpgme_data_t in,
598 gpgme_data_t out );
599 gpgme_error_t gpgme_op_import_list_next( gpgme_data_t out,
600 char **pending_line,
601 gpgme_key_t *r_key );
602
603 gpgme_error_t gpgme_op_export ( gpgme_ctx_t c, gpgme_recipients_t recp,
604 gpgme_data_t keydata );
605 gpgme_error_t gpgme_op_file_export( gpgme_ctx_t ctx, gpgme_recipients_t recp,
606 const char *output );
607 gpgme_error_t gpgme_op_clip_export( gpgme_recipients_t rset );
608
609 gpgme_error_t gpgme_op_genkey ( gpgme_ctx_t c, const char *parms,
610 gpgme_data_t pubkey, gpgme_data_t seckey );
611 gpgme_error_t gpgme_op_delete ( gpgme_ctx_t c, const gpgme_key_t key,
612 int allow_secret );
613
614 gpgme_error_t gpgme_op_symenc ( gpgme_ctx_t c, gpgme_data_t in,
615 gpgme_data_t out );
616 gpgme_error_t gpgme_op_clip_symenc( gpgme_ctx_t ctx );
617
618 gpgme_error_t gpgme_op_sign_encrypt( gpgme_ctx_t ctx, gpgme_recipients_t rset,
619 gpgme_data_t plain, gpgme_data_t ciph );
620 gpgme_error_t gpgme_op_clip_sign_encrypt( gpgme_ctx_t c, gpgme_recipients_t rset,
621 const char * keyid, int force_trust );
622 gpgme_error_t gpgme_op_file_sign_encrypt( gpgme_ctx_t ctx,
623 gpgme_recipients_t rset,
624 const char * input,
625 const char * output );
626 gpgme_error_t gpgme_op_files_sign_encrypt( gpgme_ctx_t ctx,
627 gpgme_recipients_t recp,
628 const char ** files, size_t nfiles );
629
630 /* miscellaneous functions */
631 const char *gpgme_strerror( gpgme_error_t err );
632
633 /* Extensions */
634 void gpgme_set_debug_mode( int val );
635 void gpgme_set_edit_ctx( gpgme_ctx_t c, void * edit_ctx, int edit_id );
636 void gpgme_set_cache_ctx( gpgme_ctx_t c, void * cache_ctx );
637
638 /* Signature API */
639 gpgme_error_t gpgme_sig_new( gpgme_sig_t * r_sig );
640 void gpgme_sig_release( gpgme_sig_t sig );
641 unsigned long gpgme_sig_get_ulong_attr( gpgme_sig_t sig, int idx, int what );
642 const char* gpgme_sig_get_string_attr( gpgme_sig_t sig, int what );
643 void gpgme_sig_set_key_ctx( gpgme_sig_t sig, gpgme_keycache_t cache );
644
645 /* Passphrase operations */
646 void gpgme_set_passphrase( gpgme_ctx_t c, const char * passphrase );
647
648 /* Data operations */
649 gpgme_error_t gpgme_data_new_from_clipboard (gpgme_data_t * r_dh);
650 void gpgme_data_release_and_set_clipboard (gpgme_data_t dh);
651 gpgme_error_t gpgme_data_change_version( gpgme_data_t *r_dh );
652 size_t gpgme_data_readline( gpgme_data_t dh, char *line, size_t nbytes );
653 int gpgme_data_wrap_lines( gpgme_data_t *r_dh, size_t wraplen );
654 gpgme_error_t gpgme_data_release_and_set_file( gpgme_data_t dh, const char *fname );
655 char* gpgme_data_release_and_return_string( gpgme_data_t dh );
656 char* gpgme_data_get_as_string (gpgme_data_t dh);
657 gpgme_error_t gpgme_data_extract_plaintext (gpgme_data_t sig, gpgme_data_t *r_plain);
658 gpgme_error_t gpgme_data_mail_quote (gpgme_data_t *r_dh);
659
660 /* Key edit operations */
661 gpgme_error_t gpgme_op_delete_key( const char *keyid, int allow_secret );
662 gpgme_error_t gpgme_op_delete_keys( gpgme_recipients_t rset, int allow_secret );
663
664 /* Key caching */
665 gpgme_error_t gpgme_keycache_new (gpgme_keycache_t * r_ctx);
666 void gpgme_keycache_release (gpgme_keycache_t ctx);
667 void gpgme_keycache_set_cb (gpgme_keycache_t ctx,
668 void (*cb)(void *, const char *, int, unsigned, unsigned),
669 void * cb_value1, int cb_value2);
670 gpgme_error_t gpgme_keycache_add_key (gpgme_keycache_t ctx, gpgme_key_t key,
671 void **opaque);
672 gpgme_error_t gpgme_keycache_update_key (gpgme_keycache_t ctx, int is_sec,
673 void *opaque, const char *keyid);
674 gpgme_error_t gpgme_keycache_find_key (gpgme_keycache_t ctx, const char * pattern,
675 int flags, gpgme_key_t * r_key);
676 gpgme_error_t gpgme_keycache_delete_key (gpgme_keycache_t ctx,
677 const char * pattern);
678 gpgme_error_t gpgme_keycache_init (gpgme_keycache_t ctx, const char * pattern,
679 int secret);
680 gpgme_error_t gpgme_keycache_next_key (gpgme_keycache_t ctx, int flags,
681 gpgme_key_t * r_key);
682 void gpgme_keycache_rewind( gpgme_keycache_t ctx );
683 int gpgme_keycache_count( gpgme_keycache_t ctx );
684 gpgme_error_t gpgme_keycache_prepare( gpgme_keycache_t ctx,
685 const char *pubring, const char * secring );
686 gpgme_error_t gpgme_keycache_sync (gpgme_keycache_t pub, gpgme_keycache_t sec);
687 int gpgme_getkey_bykeyid( void *fd_handle, const char * keyid, gpgme_key_t *r_key );
688
689
690 /* Ownertrust */
691 gpgme_error_t gpgme_op_key_trust_import( gpgme_ctx_t c, gpgme_data_t in );
692 gpgme_error_t gpgme_op_key_trust_export( gpgme_ctx_t c, gpgme_data_t out );
693 gpgme_error_t gpgme_op_ownertrust_export_file( const char *output );
694 gpgme_error_t gpgme_op_ownertrust_import_file( const char *input );
695
696 gpgme_error_t gpgme_op_rebuild_cache( void );
697
698 /* Import parser */
699
700 void gpgme_implist_create_revcert( gpgme_key_t *r_key, gpgme_revcert_t cert, gpgme_key_t pubk );
701
702
703 /* Key generation */
704 char * gpgme_genkey_params( int keytype, int bits,
705 const char *user, const char *comment,const char *email,
706 const char *expdate, const char *passphrase );
707 gpgme_error_t gpgme_op_genkey_auto( const char *params, gpgme_progress_cb_t prog_cb,
708 char **fpr );
709
710 /* Key attributes */
711 const char * gpgme_key_expand_attr( int what, unsigned long attr );
712
713 /* Key edit */
714 gpgme_error_t gpgme_uid_info_new( gpgme_uidinfo_t * r_inf );
715 void gpgme_uid_info_release( gpgme_uidinfo_t inf );
716 gpgme_error_t gpgme_op_editkey_get_info( gpgme_ctx_t ctx, const char * keyid,
717 gpgme_uidinfo_t * r_inf );
718 unsigned long gpgme_editkey_get_ulong_attr( gpgme_uidinfo_t inf, int what, int idx );
719 const char * gpgme_editkey_get_string_attr( gpgme_uidinfo_t inf, int what, int idx );
720 int gpgme_editkey_count_items( gpgme_uidinfo_t inf );
721 gpgme_error_t gpgme_op_editkey( gpgme_ctx_t ctx, const char *keyid );
722
723 /* Card edit */
724 gpgme_error_t gpgme_editcard_new( gpgme_editcard_t * r_ctx );
725 void gpgme_editcard_release( gpgme_editcard_t ctx );
726 gpgme_error_t gpgme_editcard_control( gpgme_editcard_t ctx, int cmd,
727 const void * val );
728 gpgme_error_t gpgme_editcard_set_passwd (gpgme_editcard_t ctx, const char * passwd);
729 gpgme_error_t gpgme_editcard_set_keygen_params( gpgme_editcard_t ctx, int flags,
730 const char * name, const char * email,
731 const char * comment, const char * expdate );
732 void gpgme_editcard_set_callback( gpgme_editcard_t ctx,
733 const char *(*cb)( int code, void * opaque ),
734 void * cb_value );
735
736 gpgme_error_t gpgme_op_changepin( gpgme_ctx_t ctx );
737 gpgme_error_t gpgme_changepin_set( gpgme_editcard_t chpin, int which,
738 const char * pinold, const char * pinnew );
739
740 gpgme_error_t gpgme_op_editcard( gpgme_ctx_t ctx );
741 gpgme_error_t gpgme_op_statuscard( gpgme_ctx_t ctx, gpgme_card_t * ret_card );
742
743 gpgme_error_t gpgme_card_new( gpgme_card_t * ret_card );
744 void gpgme_card_release( gpgme_card_t card );
745 const char * gpgme_card_get_string_attr( gpgme_card_t card, gpgme_attr_t what,
746 void ** reserved, int idx );
747 unsigned long gpgme_card_get_ulong_attr( gpgme_card_t card, gpgme_attr_t what,
748 void ** reserved, int idx );
749
750 /* Key revocation */
751 gpgme_error_t gpgme_revcert_new( gpgme_revcert_t *r_cert );
752 void gpgme_revcert_release( gpgme_revcert_t cert );
753 gpgme_error_t gpgme_revcert_parse( const char *data, gpgme_revcert_t cert, char * keyid );
754 gpgme_error_t gpgme_revoke_set( gpgme_editkey_t ctx, const char *uid,
755 const char *text, int reason, int pgpmode,
756 const char *pass );
757 gpgme_error_t gpgme_op_revoke( gpgme_ctx_t c, gpgme_editkey_t rev, gpgme_data_t cert );
758
759 /* Misc - version */
760 gpgme_error_t gpgme_op_version( char **info );
761 void gpgme_set_gettext_handler( char *(*gettext)( const char *id ) );
762
763 /* Misc */
764 void gpgme_set_pgm_string( const char *name );
765 int gpgme_key_count_items( gpgme_key_t key, int what );
766 int gpgme_key_get_cability( gpgme_key_t key, int attr, int keyidx );
767 int gpgme_key_cability_from_algo( gpgme_pk_cipher_t algo );
768 gpgme_error_t gpgme_get_import_status( gpgme_ctx_t ctx, int * import_res,
769 gpgme_recipients_t * r_keys );
770 void gpgme_decrypt_get_status( gpgme_ctx_t ctx, char * keyid,
771 gpgme_op_flags_t *r_flags );
772 void gpgme_decrypt_get_sig_ctx( gpgme_ctx_t ctx, gpgme_sig_t *r_sig );
773
774 /* Edit key interface */
775 gpgme_error_t gpgme_editkey_new( gpgme_editkey_t *ctx );
776 void gpgme_editkey_release( gpgme_editkey_t ctx );
777 void gpgme_editkey_make_invalid( gpgme_editkey_t ctx );
778 int gpgme_editkey_is_valid( gpgme_editkey_t ctx );
779 int gpgme_editkey_is_secret( gpgme_editkey_t ctx, int val );
780
781
782 void gpgme_editkey_trust_set( gpgme_editkey_t ctx, int val );
783 void gpgme_editkey_delsig_set (gpgme_editkey_t ctx, int uid, int signo);
784 gpgme_error_t gpgme_editkey_sign_set (gpgme_editkey_t ctx,
785 const char * passwd,
786 int sigclass,
787 int sigtype,
788 const char * param);
789 void gpgme_editkey_primary_set( gpgme_editkey_t ctx, int id, const char *passwd );
790 void gpgme_editkey_adduid_set( gpgme_editkey_t ctx, const char *name,
791 const char *email, const char *comment,
792 const char *passwd );
793 void gpgme_editkey_deluid_set_id( gpgme_editkey_t ctx, int id );
794 void gpgme_editkey_delkey_set_id( gpgme_editkey_t ctx, int id );
795 gpgme_error_t gpgme_editkey_addkey_set (gpgme_editkey_t ctx,
796 const char * passwd,
797 int algo, int size, int valid);
798 void gpgme_editkey_passwd_set( gpgme_editkey_t ctx,
799 const char * old_pwd, const char * new_pwd,
800 int allow_empty );
801 void gpgme_editkey_expire_set( gpgme_editkey_t ctx, int id, int days,
802 const char *date, const char *passwd );
803 void gpgme_editkey_revsig_set( gpgme_editkey_t ctx, int id, const char *passwd );
804 void gpgme_editkey_revkey_set( gpgme_editkey_t ctx, int id, int reason,
805 const char * passwd );
806 void gpgme_editkey_setpref_set (gpgme_editkey_t ctx, const char * new_prefs,
807 int uid_idx, const char * passwd);
808 gpgme_error_t gpgme_editkey_addrev_set (gpgme_editkey_t ctx, const char * userid,
809 const char * passwd);
810 void gpgme_editkey_addphoto_set (gpgme_editkey_t ctx, const char *jpegfile,
811 const char * passwd);
812 void gpgme_editkey_enable_set (gpgme_editkey_t ctx);
813 void gpgme_editkey_disable_set (gpgme_editkey_t ctx);
814 void gpgme_editkey_keyserver_set (gpgme_editkey_t ctx, const char *url,
815 int uid_idx, const char * passwd);
816
817
818 /* Clipboard interface */
819 gpgme_error_t gpgme_clip_istext_avail (int *r_rc);
820 gpgme_error_t gpgme_clip_is_secured (gpgme_pgptype_t *r_type, int *r_rc);
821 gpgme_error_t gpgme_clip_get_pgptype (gpgme_pgptype_t *r_type);
822 gpgme_error_t gpgme_clip_parse_pgpid (const char *data, gpgme_pgptype_t *r_type );
823 gpgme_error_t gpgme_clip_do_check (int *r_rc);
824
825 #ifdef __cplusplus
826 }
827 #endif
828 #endif /* GPGME_H */

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26