/[winpt]/trunk/Gnupg/openpgp.h
ViewVC logotype

Contents of /trunk/Gnupg/openpgp.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 439 - (show annotations)
Thu Apr 12 18:41:31 2012 UTC (12 years, 10 months ago) by twoaday
File MIME type: text/plain
File size: 25203 byte(s)
2012-04-12  Timo Schulz  <twoaday@gmx.net>

        * sha512.c: Removed.
        * md.c (gpg_md_hash_file): Removed.
	        (gpg_md_open): Removed non SHA-1 support.
	        (gpg_md_write): Likewise.
	        (do_check_md): Removed.
	        (gpg_md_selftest): Removed unused code.


1 #ifndef GPGLIB_OPENPGP_H
2 #define GPGLIB_OPENPGP_H
3
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7
8 #ifndef HAVE_BYTE_TYPEDEF
9 typedef unsigned char byte;
10 #define HAVE_BYTE_TYPEDEF
11 #endif
12
13 #ifndef HAVE_U32_TYPEDEF
14 typedef unsigned long u32;
15 #define HAVE_U32_TYPEDEF
16 #endif
17
18 #ifndef HAVE_ULONG_TYPEDEF
19 typedef unsigned long ulong;
20 #define SIZEOF_UNSIGNED_LONG 4
21 #define HAVE_ULONG_TYPEDEF
22 #endif
23
24 #ifndef HAVE_U16_TYPEDEF
25 typedef unsigned short u16;
26 #define HAVE_U16_TYPEDEF
27 #endif
28
29 #ifndef DIM
30 #define DIM(v) (sizeof(v)/sizeof((v)[0]))
31 #endif
32
33 #ifndef safe_free
34 #define safe_free( p ) do { \
35 if( p ) { free( p ); p = NULL; } \
36 } while( 0 )
37 #endif
38
39 #define G10ERR_GENERAL 1
40 #define G10ERR_UNKNOWN_PACKET 2
41 #define G10ERR_UNKNOWN_VERSION 3 /* Unknown version (in packet) */
42 #define G10ERR_PUBKEY_ALGO 4 /* Unknown pubkey algorithm */
43 #define G10ERR_DIGEST_ALGO 5 /* Unknown digest algorithm */
44 #define G10ERR_BAD_PUBKEY 6 /* Bad public key */
45 #define G10ERR_BAD_SECKEY 7 /* Bad secret key */
46 #define G10ERR_BAD_SIGN 8 /* Bad signature */
47 #define G10ERR_NO_PUBKEY 9 /* public key not found */
48 #define G10ERR_CHECKSUM 10 /* checksum error */
49 #define G10ERR_BAD_PASS 11 /* Bad passphrase */
50 #define G10ERR_CIPHER_ALGO 12 /* Unknown cipher algorithm */
51 #define G10ERR_KEYRING_OPEN 13
52 #define G10ERR_INVALID_PACKET 14
53 #define G10ERR_INVALID_ARMOR 15
54 #define G10ERR_NO_USER_ID 16
55 #define G10ERR_NO_SECKEY 17 /* secret key not available */
56 #define G10ERR_WRONG_SECKEY 18 /* wrong seckey used */
57 #define G10ERR_UNSUPPORTED 19
58 #define G10ERR_BAD_KEY 20 /* bad (session) key */
59 #define G10ERR_READ_FILE 21
60 #define G10ERR_WRITE_FILE 22
61 #define G10ERR_COMPR_ALGO 23 /* Unknown compress algorithm */
62 #define G10ERR_OPEN_FILE 24
63 #define G10ERR_CREATE_FILE 25
64 #define G10ERR_PASSPHRASE 26 /* invalid passphrase */
65 #define G10ERR_NI_PUBKEY 27
66 #define G10ERR_NI_CIPHER 28
67 #define G10ERR_SIG_CLASS 29
68 #define G10ERR_BAD_MPI 30
69 #define G10ERR_RESOURCE_LIMIT 31
70 #define G10ERR_INV_KEYRING 32
71 #define G10ERR_TRUSTDB 33 /* a problem with the trustdb */
72 #define G10ERR_BAD_CERT 34 /* bad certicate */
73 #define G10ERR_INV_USER_ID 35
74 #define G10ERR_CLOSE_FILE 36
75 #define G10ERR_RENAME_FILE 37
76 #define G10ERR_DELETE_FILE 38
77 #define G10ERR_UNEXPECTED 39
78 #define G10ERR_TIME_CONFLICT 40
79 #define G10ERR_WR_PUBKEY_ALGO 41 /* unusabe pubkey algo */
80 #define G10ERR_FILE_EXISTS 42
81 #define G10ERR_WEAK_KEY 43 /* NOTE: hardcoded into the cipher modules */
82 #define G10ERR_WRONG_KEYLEN 44 /* NOTE: hardcoded into the cipher modules */
83 #define G10ERR_INV_ARG 45
84 #define G10ERR_BAD_URI 46 /* syntax error in URI */
85 #define G10ERR_INVALID_URI 47 /* e.g. unsupported scheme */
86 #define G10ERR_NETWORK 48 /* general network error */
87 #define G10ERR_UNKNOWN_HOST 49
88 #define G10ERR_SELFTEST_FAILED 50
89 #define G10ERR_NOT_ENCRYPTED 51
90 #define G10ERR_NOT_PROCESSED 52
91 #define G10ERR_UNU_PUBKEY 53
92 #define G10ERR_UNU_SECKEY 54
93 #define G10ERR_KEYSERVER 55
94
95 #define CIPHER_ALGO_NONE 0
96 #define CIPHER_ALGO_IDEA 1
97 #define CIPHER_ALGO_3DES 2
98 #define CIPHER_ALGO_CAST5 3
99 #define CIPHER_ALGO_BLOWFISH 4 /* blowfish 128 bit key */
100 #define CIPHER_ALGO_SAFER_SK128 5
101 #define CIPHER_ALGO_DES_SK 6
102 #define CIPHER_ALGO_AES 7
103 #define CIPHER_ALGO_AES192 8
104 #define CIPHER_ALGO_AES256 9
105 #define CIPHER_ALGO_RIJNDAEL CIPHER_ALGO_AES
106 #define CIPHER_ALGO_RIJNDAEL192 CIPHER_ALGO_AES192
107 #define CIPHER_ALGO_RIJNDAEL256 CIPHER_ALGO_AES256
108 #define CIPHER_ALGO_TWOFISH 10 /* twofish 256 bit */
109 #define CIPHER_ALGO_SKIPJACK 101 /* experimental: skipjack */
110 #define CIPHER_ALGO_TWOFISH_OLD 102 /* experimental: twofish 128 bit */
111 #define CIPHER_ALGO_DUMMY 110 /* no encryption at all */
112
113 #define PUBKEY_ALGO_RSA 1
114 #define PUBKEY_ALGO_RSA_E 2 /* RSA encrypt only */
115 #define PUBKEY_ALGO_RSA_S 3 /* RSA sign only */
116 #define PUBKEY_ALGO_ELGAMAL_E 16 /* encrypt only ElGamal (but not for v3)*/
117 #define PUBKEY_ALGO_DSA 17
118 #define PUBKEY_ALGO_ELGAMAL 20 /* sign and encrypt elgamal */
119
120 #define PUBKEY_USAGE_SIG 1 /* key is good for signatures */
121 #define PUBKEY_USAGE_ENC 2 /* key is good for encryption */
122 #define PUBKEY_USAGE_CERT 4 /* key is also good to certify other keys*/
123
124 #define DIGEST_ALGO_MD5 1
125 #define DIGEST_ALGO_SHA1 2
126 #define DIGEST_ALGO_RMD160 3
127 #define DIGEST_ALGO_SHA256 8
128 #define DIGEST_ALGO_SHA384 9
129 #define DIGEST_ALGO_SHA512 10
130
131 #define MD_MD5 DIGEST_ALGO_MD5
132 #define MD_SHA1 DIGEST_ALGO_SHA1
133 #define MD_RMD160 DIGEST_ALGO_RMD160
134 #define MD_SHA256 DIGEST_ALGO_SHA256
135 #define MD_SHA384 DIGEST_ALGO_SHA384
136 #define MD_SHA512 DIGEST_ALGO_SHA512
137
138 #define is_RSA(a) ((a)==PUBKEY_ALGO_RSA || (a)==PUBKEY_ALGO_RSA_E \
139 || (a)==PUBKEY_ALGO_RSA_S )
140 #define is_ELGAMAL(a) ((a)==PUBKEY_ALGO_ELGAMAL || (a)==PUBKEY_ALGO_ELGAMAL_E)
141
142
143 #define PUBKEY_MAX_NPKEY 4
144 #define PUBKEY_MAX_NSKEY 6
145 #define PUBKEY_MAX_NSIG 2
146 #define PUBKEY_MAX_NENC 2
147
148 #define MAX_FINGERPRINT_LEN 20
149
150 #define IOBUFCTRL_INIT 1
151 #define IOBUFCTRL_FREE 2
152 #define IOBUFCTRL_UNDERFLOW 3
153 #define IOBUFCTRL_FLUSH 4
154 #define IOBUFCTRL_DESC 5
155 #define IOBUFCTRL_CANCEL 6
156 #define IOBUFCTRL_USER 16
157
158
159 /*-- md.c --*/
160 struct gpgm_md_s;
161 typedef struct gpgm_md_s *gpg_md_t;
162
163 gpg_md_t gpg_md_open( int algo );
164 void gpg_md_close( gpg_md_t md );
165 void gpg_md_final( gpg_md_t md );
166 void gpg_md_write( gpg_md_t md, byte *inbuf, size_t len );
167 void gpg_md_putc( gpg_md_t md, int c );
168 const byte * gpg_md_read( gpg_md_t md );
169
170
171 /*-- iobuf.c --*/
172 struct gpg_iobuf_s {
173 int use; /* 1 input , 2 output, 3 temp */
174 _off_t nlimit;
175 _off_t nbytes; /* used together with nlimit */
176 _off_t ntotal; /* total bytes read (position of stream) */
177 int nofast; /* used by the iobuf_get() */
178 void *directfp;
179 struct {
180 size_t size; /* allocated size */
181 size_t start; /* number of invalid bytes at the begin of the buffer */
182 size_t len; /* currently filled to this size */
183 byte *buf;
184 } d;
185 int filter_eof;
186 int error;
187 int (*filter)( void *opaque, int control,
188 struct gpg_iobuf_s *chain, byte *buf, size_t *len);
189 void *filter_ov; /* value for opaque */
190 int filter_ov_owner;
191 char *real_fname;
192 struct gpg_iobuf_s *chain; /* next iobuf used for i/o if any (passed to filter) */
193 int no, subno;
194 const char *desc;
195 void *opaque; /* can be used to hold any information */
196 /* this value is copied to all instances */
197 struct {
198 size_t size; /* allocated size */
199 size_t start; /* number of invalid bytes at the begin of the buffer */
200 size_t len; /* currently filled to this size */
201 byte *buf;
202 } unget;
203 };
204 typedef struct gpg_iobuf_s *gpg_iobuf_t;
205
206 typedef struct {
207 /* these fields may be initialized */
208 int what; /* what kind of armor headers to write */
209 int only_keyblocks; /* skip all headers but ".... key block" */
210 const char *hdrlines; /* write these headerlines */
211
212 /* these fileds must be initialized to zero */
213 int no_openpgp_data; /* output flag: "No valid OpenPGP data found" */
214
215 /* the following fields must be initialized to zero */
216 int inp_checked; /* set if the input has been checked */
217 int inp_bypass; /* set if the input is not armored */
218 int in_cleartext; /* clear text message */
219 int not_dash_escaped; /* clear text is not dash escaped */
220 int hashes; /* detected hash algorithms */
221 int faked; /* we are faking a literal data packet */
222 int truncated; /* number of truncated lines */
223 int qp_detected;
224 int pgp2mode;
225
226 byte *buffer; /* malloced buffer */
227 unsigned buffer_size; /* and size of this buffer */
228 unsigned buffer_len; /* used length of the buffer */
229 unsigned buffer_pos; /* read position */
230
231 byte radbuf[4];
232 int idx, idx2;
233 u32 crc;
234
235 int status; /* an internal state flag */
236 int cancel;
237 int any_data; /* any valid armored data seen */
238 int pending_lf; /* used together with faked */
239 } armor_filter_context_t;
240
241 struct unarmor_pump_s;
242 typedef struct unarmor_pump_s *UnarmorPump;
243
244 struct gpg_mpi_s {
245 int alloced; /* array size (# of allocated limbs) */
246 int nlimbs; /* number of valid limbs */
247 int nbits; /* the real number of valid bits (info only) */
248 int sign; /* indicates a negative number */
249 unsigned flags; /* bit 0: array must be allocated in secure memory space */
250 /* bit 1: the mpi is encrypted */
251 /* bit 2: the limb is a pointer to some m_alloced data */
252 unsigned long *d; /* array with the limbs */
253 };
254 typedef struct gpg_mpi_s *gpg_mpi_t;
255
256 typedef enum {
257 PKT_NONE =0,
258 PKT_PUBKEY_ENC =1, /* public key encrypted packet */
259 PKT_SIGNATURE =2, /* secret key encrypted packet */
260 PKT_SYMKEY_ENC =3, /* session key packet (OpenPGP)*/
261 PKT_ONEPASS_SIG =4, /* one pass sig packet (OpenPGP)*/
262 PKT_SECRET_KEY =5, /* secret key */
263 PKT_PUBLIC_KEY =6, /* public key */
264 PKT_SECRET_SUBKEY =7, /* secret subkey (OpenPGP) */
265 PKT_COMPRESSED =8, /* compressed data packet */
266 PKT_ENCRYPTED =9, /* conventional encrypted data */
267 PKT_MARKER =10, /* marker packet (OpenPGP) */
268 PKT_PLAINTEXT =11, /* plaintext data with filename and mode */
269 PKT_RING_TRUST =12, /* keyring trust packet */
270 PKT_USER_ID =13, /* user id packet */
271 PKT_PUBLIC_SUBKEY =14, /* public subkey (OpenPGP) */
272 PKT_OLD_COMMENT =16, /* comment packet from an OpenPGP draft */
273 PKT_ATTRIBUTE =17, /* PGP's attribute packet */
274 PKT_ENCRYPTED_MDC =18, /* integrity protected encrypted data */
275 PKT_MDC =19, /* manipulaion detection code packet */
276 PKT_COMMENT =61, /* new comment packet (private) */
277 PKT_GPG_CONTROL =63 /* internal control packet */
278 } pkttype_t;
279
280 typedef struct packet_struct PACKET;
281
282 /* PKT_GPG_CONTROL types */
283 typedef enum {
284 CTRLPKT_CLEARSIGN_START = 1,
285 CTRLPKT_PIPEMODE = 2,
286 CTRLPKT_PLAINTEXT_MARK =3
287 } ctrlpkttype_t;
288
289 typedef enum {
290 PREFTYPE_NONE = 0,
291 PREFTYPE_SYM = 1,
292 PREFTYPE_HASH = 2,
293 PREFTYPE_ZIP = 3
294 } preftype_t;
295
296 typedef struct {
297 byte type;
298 byte value;
299 } prefitem_t;
300
301 typedef struct {
302 int mode;
303 byte hash_algo;
304 byte salt[8];
305 u32 count;
306 } STRING2KEY;
307
308 typedef struct {
309 byte version;
310 byte cipher_algo; /* cipher algorithm used */
311 STRING2KEY s2k;
312 byte seskeylen; /* keylength in byte or 0 for no seskey */
313 byte seskey[1];
314 } PKT_symkey_enc;
315
316 typedef struct {
317 u32 keyid[2]; /* 64 bit keyid */
318 byte version;
319 byte pubkey_algo; /* algorithm used for public key scheme */
320 byte throw_keyid;
321 gpg_mpi_t data[PUBKEY_MAX_NENC];
322 } PKT_pubkey_enc;
323
324
325 typedef struct {
326 u32 keyid[2]; /* 64 bit keyid */
327 byte sig_class; /* sig classification */
328 byte digest_algo; /* algorithm used for digest */
329 byte pubkey_algo; /* algorithm used for public key scheme */
330 byte last; /* a stupid flag */
331 } PKT_onepass_sig;
332
333
334 typedef struct {
335 size_t size; /* allocated */
336 size_t len; /* used */
337 byte data[1];
338 } subpktarea_t;
339
340 struct revocation_key {
341 byte rclass;
342 byte algid;
343 byte fpr[MAX_FINGERPRINT_LEN];
344 };
345
346 typedef struct {
347 ulong local_id; /* internal use, valid if > 0 */
348 struct {
349 unsigned checked:1; /* signature has been checked */
350 unsigned valid:1; /* signature is good (if checked is set) */
351 unsigned unknown_critical:1;
352 unsigned exportable:1;
353 unsigned revocable:1;
354 unsigned policy_url:1; /* Policy URL is present */
355 unsigned notation:1; /* At least one notation is present */
356 unsigned expired:1;
357 } flags;
358 u32 keyid[2]; /* 64 bit keyid */
359 u32 timestamp; /* signature made */
360 u32 expiredate; /* expires at this date or 0 if not at all */
361 byte version;
362 byte sig_class; /* sig classification, append for MD calculation*/
363 byte pubkey_algo; /* algorithm used for public key scheme */
364 /* (PUBKEY_ALGO_xxx) */
365 byte digest_algo; /* algorithm used for digest (DIGEST_ALGO_xxxx) */
366 struct revocation_key **revkey;
367 int numrevkeys;
368 subpktarea_t *hashed; /* all subpackets with hashed data (v4 only) */
369 subpktarea_t *unhashed; /* ditto for unhashed data */
370 byte digest_start[2]; /* first 2 bytes of the digest */
371 gpg_mpi_t data[PUBKEY_MAX_NSIG];
372 } PKT_signature;
373
374 #define ATTRIB_IMAGE 1
375
376 /* This is the cooked form of attributes */
377 struct user_attribute {
378 byte type;
379 const byte *data;
380 u32 len;
381 };
382
383 typedef struct {
384 int ref; /* reference counter */
385 int len; /* length of the name */
386 struct user_attribute *attribs;
387 int numattribs;
388 byte *attrib_data; /* if this is not NULL, the packet is an attribute */
389 unsigned long attrib_len;
390 int help_key_usage;
391 u32 help_key_expire;
392 int is_primary;
393 int is_revoked;
394 int is_expired;
395 u32 expiredate; /* expires at this date or 0 if not at all */
396 prefitem_t *prefs; /* list of preferences (may be NULL)*/
397 int mdc_feature;
398 u32 created; /* according to the self-signature */
399 byte selfsigversion;
400 char name[1];
401 } PKT_user_id;
402
403
404 /****************
405 * Note about the pkey/skey elements: We assume that the secret keys
406 * has the same elemts as the public key at the begin of the array, so
407 * that npkey < nskey and it is possible to compare the secret and
408 * public keys by comparing the first npkey elements of pkey againts skey.
409 */
410 typedef struct {
411 u32 timestamp; /* key made */
412 u32 expiredate; /* expires at this date or 0 if not at all */
413 u32 max_expiredate; /* must not expire past this date */
414 byte hdrbytes; /* number of header bytes */
415 byte version;
416 byte selfsigversion; /* highest version of all of the self-sigs */
417 byte pubkey_algo; /* algorithm used for public key scheme */
418 byte pubkey_usage; /* for now only used to pass it to getkey() */
419 byte req_usage; /* hack to pass a request to getkey() */
420 byte req_algo; /* Ditto */
421 u32 has_expired; /* set to the expiration date if expired */
422 int is_revoked; /* key has been revoked */
423 int is_valid; /* key (especially subkey) is valid */
424 int dont_cache; /* do not cache this */
425 ulong local_id; /* internal use, valid if > 0 */
426 u32 main_keyid[2]; /* keyid of the primary key */
427 u32 keyid[2]; /* calculated by keyid_from_pk() */
428 prefitem_t *prefs; /* list of preferences (may be NULL) */
429 int mdc_feature; /* mdc feature set */
430 byte *namehash; /* if != NULL: found by this name */
431 PKT_user_id *user_id; /* if != NULL: found by that uid */
432 struct revocation_key *revkey;
433 int numrevkeys;
434 int is_primary;
435 gpg_mpi_t pkey[PUBKEY_MAX_NPKEY];
436 } PKT_public_key;
437
438 typedef struct {
439 u32 timestamp; /* key made */
440 u32 expiredate; /* expires at this date or 0 if not at all */
441 u32 max_expiredate; /* must not expire past this date */
442 byte hdrbytes; /* number of header bytes */
443 byte version;
444 byte pubkey_algo; /* algorithm used for public key scheme */
445 byte pubkey_usage;
446 byte req_usage;
447 byte req_algo;
448 u32 has_expired; /* set to the expiration date if expired */
449 int is_revoked; /* key has been revoked */
450 int is_valid; /* key (especially subkey) is valid */
451 u32 main_keyid[2]; /* keyid of the primary key */
452 u32 keyid[2];
453 byte is_primary;
454 byte is_protected; /* The secret info is protected and must */
455 /* be decrypted before use, the protected */
456 /* GPG_MPIs are simply (void*) pointers to memory */
457 /* and should never be passed to a mpi_xxx() */
458 struct {
459 byte algo; /* cipher used to protect the secret information*/
460 byte sha1chk; /* SHA1 is used instead of a 16 bit checksum */
461 STRING2KEY s2k;
462 byte ivlen; /* used length of the iv */
463 byte iv[16]; /* initialization vector for CFB mode */
464 } protect;
465 gpg_mpi_t skey[PUBKEY_MAX_NSKEY];
466 u16 csum; /* checksum */
467 } PKT_secret_key;
468
469
470 typedef struct {
471 int len; /* length of data */
472 char data[1];
473 } PKT_comment;
474
475 typedef struct {
476 u32 len; /* reserved */
477 byte new_ctb;
478 byte algorithm;
479 gpg_iobuf_t buf; /* gpg_iobuf_t reference */
480 } PKT_compressed;
481
482 typedef struct {
483 u32 len; /* length of encrypted data */
484 int extralen; /* this is (blocksize+2) */
485 byte new_ctb; /* uses a new CTB */
486 byte mdc_method; /* > 0: integrity protected encrypted data packet */
487 gpg_iobuf_t buf; /* gpg_iobuf_t reference */
488 } PKT_encrypted;
489
490 typedef struct {
491 byte hash[20];
492 } PKT_mdc;
493
494 typedef struct {
495 unsigned int trustval;
496 unsigned int sigcache;
497 } PKT_ring_trust;
498
499 typedef struct {
500 u32 len; /* length of encrypted data */
501 gpg_iobuf_t buf; /* gpg_iobuf_t reference */
502 byte new_ctb;
503 byte is_partial; /* partial length encoded */
504 int mode;
505 u32 timestamp;
506 int namelen;
507 char name[1];
508 } PKT_plaintext;
509
510 typedef struct {
511 int control;
512 size_t datalen;
513 char data[1];
514 } PKT_gpg_control;
515
516 /* combine all packets into a union */
517 struct packet_struct {
518 pkttype_t pkttype;
519 union {
520 void *generic;
521 PKT_symkey_enc *symkey_enc; /* PKT_SYMKEY_ENC */
522 PKT_pubkey_enc *pubkey_enc; /* PKT_PUBKEY_ENC */
523 PKT_onepass_sig *onepass_sig; /* PKT_ONEPASS_SIG */
524 PKT_signature *signature; /* PKT_SIGNATURE */
525 PKT_public_key *public_key; /* PKT_PUBLIC_[SUB)KEY */
526 PKT_secret_key *secret_key; /* PKT_SECRET_[SUB]KEY */
527 PKT_comment *comment; /* PKT_COMMENT */
528 PKT_user_id *user_id; /* PKT_USER_ID */
529 PKT_compressed *compressed; /* PKT_COMPRESSED */
530 PKT_encrypted *encrypted; /* PKT_ENCRYPTED[_MDC] */
531 PKT_mdc *mdc; /* PKT_MDC */
532 PKT_ring_trust *ring_trust; /* PKT_RING_TRUST */
533 PKT_plaintext *plaintext; /* PKT_PLAINTEXT */
534 PKT_gpg_control *gpg_control; /* PKT_GPG_CONTROL */
535 } pkt;
536 };
537
538 struct gpg_kbnode_s {
539 struct gpg_kbnode_s *next;
540 PACKET *pkt;
541 int flag;
542 int private_flag;
543 ulong recno; /* used while updating the trustdb */
544 };
545 typedef struct gpg_kbnode_s *gpg_kbnode_t;
546
547 #define gpg_init_packet(a) do { (a)->pkttype = (pkttype_t)0; \
548 (a)->pkt.generic = NULL; \
549 } while(0)
550
551 typedef enum {
552 SIGSUBPKT_TEST_CRITICAL=-3,
553 SIGSUBPKT_LIST_UNHASHED=-2,
554 SIGSUBPKT_LIST_HASHED =-1,
555 SIGSUBPKT_NONE = 0,
556 SIGSUBPKT_SIG_CREATED = 2, /* signature creation time */
557 SIGSUBPKT_SIG_EXPIRE = 3, /* signature expiration time */
558 SIGSUBPKT_EXPORTABLE = 4, /* exportable */
559 SIGSUBPKT_TRUST = 5, /* trust signature */
560 SIGSUBPKT_REGEXP = 6, /* regular expression */
561 SIGSUBPKT_REVOCABLE = 7, /* revocable */
562 SIGSUBPKT_KEY_EXPIRE = 9, /* key expiration time */
563 SIGSUBPKT_ARR =10, /* additional recipient request */
564 SIGSUBPKT_PREF_SYM =11, /* preferred symmetric algorithms */
565 SIGSUBPKT_REV_KEY =12, /* revocation key */
566 SIGSUBPKT_ISSUER =16, /* issuer key ID */
567 SIGSUBPKT_NOTATION =20, /* notation data */
568 SIGSUBPKT_PREF_HASH =21, /* preferred hash algorithms */
569 SIGSUBPKT_PREF_COMPR =22, /* preferred compression algorithms */
570 SIGSUBPKT_KS_FLAGS =23, /* key server preferences */
571 SIGSUBPKT_PREF_KS =24, /* preferred key server */
572 SIGSUBPKT_PRIMARY_UID =25, /* primary user id */
573 SIGSUBPKT_POLICY =26, /* policy URL */
574 SIGSUBPKT_KEY_FLAGS =27, /* key flags */
575 SIGSUBPKT_SIGNERS_UID =28, /* signer's user id */
576 SIGSUBPKT_REVOC_REASON =29, /* reason for revocation */
577 SIGSUBPKT_FEATURES =30, /* feature flags */
578 SIGSUBPKT_PRIV_VERIFY_CACHE =101, /* cache verification result (obsolete)*/
579
580 SIGSUBPKT_FLAG_CRITICAL=128
581 } sigsubpkttype_t;
582
583 /*-- iobuf.c --*/
584 void gpg_iobuf_enable_special_filenames ( int yes );
585 gpg_iobuf_t gpg_iobuf_alloc(int use, size_t bufsize);
586 gpg_iobuf_t gpg_iobuf_temp(void);
587 gpg_iobuf_t gpg_iobuf_temp_with_content( const char *buffer, size_t length );
588 gpg_iobuf_t gpg_iobuf_open( const char *fname );
589 gpg_iobuf_t gpg_iobuf_fdopen( int fd, const char *mode );
590 gpg_iobuf_t gpg_iobuf_sockopen( int fd, const char *mode );
591 gpg_iobuf_t gpg_iobuf_create( const char *fname );
592 gpg_iobuf_t gpg_iobuf_append( const char *fname );
593 gpg_iobuf_t gpg_iobuf_openrw( const char *fname );
594 int gpg_iobuf_ioctl ( gpg_iobuf_t a, int cmd, int intval, void *ptrval );
595 int gpg_iobuf_close( gpg_iobuf_t iobuf );
596 int gpg_iobuf_cancel( gpg_iobuf_t iobuf );
597
598 int gpg_iobuf_push_filter( gpg_iobuf_t a, int (*f)(void *opaque, int control,
599 gpg_iobuf_t chain, byte *buf, size_t *len), void *ov );
600 int gpg_iobuf_push_filter2( gpg_iobuf_t a,
601 int (*f)(void *opaque, int control,
602 gpg_iobuf_t chain, byte *buf, size_t *len),
603 void *ov, int rel_ov );
604 int gpg_iobuf_flush(gpg_iobuf_t a);
605 void gpg_iobuf_clear_eof(gpg_iobuf_t a);
606 #define gpg_iobuf_set_error(a) do { (a)->error = 1; } while(0)
607 #define gpg_iobuf_error(a) ((a)->error)
608
609 void gpg_iobuf_set_limit( gpg_iobuf_t a, _off_t nlimit );
610
611 _off_t gpg_iobuf_tell( gpg_iobuf_t a );
612 int gpg_iobuf_seek( gpg_iobuf_t a, _off_t newpos );
613
614 int gpg_iobuf_readbyte(gpg_iobuf_t a);
615 int gpg_iobuf_read(gpg_iobuf_t a, byte *buf, unsigned buflen );
616 unsigned gpg_iobuf_read_line( gpg_iobuf_t a, byte **addr_of_buffer,
617 unsigned *length_of_buffer, unsigned *max_length );
618 int gpg_iobuf_peek(gpg_iobuf_t a, byte *buf, unsigned buflen );
619 int gpg_iobuf_writebyte(gpg_iobuf_t a, unsigned c);
620 int gpg_iobuf_write(gpg_iobuf_t a, byte *buf, unsigned buflen );
621 int gpg_iobuf_writestr(gpg_iobuf_t a, const char *buf );
622
623 void gpg_iobuf_flush_temp( gpg_iobuf_t temp );
624 int gpg_iobuf_write_temp( gpg_iobuf_t a, gpg_iobuf_t temp );
625 size_t gpg_iobuf_temp_to_buffer( gpg_iobuf_t a, byte *buffer, size_t buflen );
626 void gpg_iobuf_unget_and_close_temp( gpg_iobuf_t a, gpg_iobuf_t temp );
627
628 off_t gpg_iobuf_get_filelength( gpg_iobuf_t a );
629 #define IOBUF_FILELENGTH_LIMIT 0xffffffff
630 const char *gpg_iobuf_get_real_fname( gpg_iobuf_t a );
631 const char *gpg_iobuf_get_fname( gpg_iobuf_t a );
632
633 void gpg_iobuf_set_block_mode( gpg_iobuf_t a, size_t n );
634 void gpg_iobuf_set_partial_block_mode( gpg_iobuf_t a, size_t len );
635 int gpg_iobuf_in_block_mode( gpg_iobuf_t a );
636
637 int gpg_iobuf_translate_file_handle ( int fd, int for_write );
638
639 /* get a byte form the iobuf; must check for eof prior to this function
640 * this function returns values in the range 0 .. 255 or -1 to indicate EOF
641 * iobuf_get_noeof() does not return -1 to indicate EOF, but masks the
642 * returned value to be in the range 0 ..255.
643 */
644 #define gpg_iobuf_get(a) \
645 ( ((a)->nofast || (a)->d.start >= (a)->d.len )? \
646 gpg_iobuf_readbyte((a)) : ( (a)->nbytes++, (a)->d.buf[(a)->d.start++] ) )
647 #define gpg_iobuf_get_noeof(a) (gpg_iobuf_get((a))&0xff)
648
649 /* write a byte to the iobuf and return true on write error
650 * This macro does only write the low order byte
651 */
652 #define gpg_iobuf_put(a,c) gpg_iobuf_writebyte(a,c)
653
654 #define gpg_iobuf_where(a) "[don't know]"
655 #define gpg_iobuf_id(a) ((a)->no)
656
657 #define gpg_iobuf_get_temp_buffer(a) ( (a)->d.buf )
658 #define gpg_iobuf_get_temp_length(a) ( (a)->d.len )
659 #define gpg_iobuf_is_temp(a) ( (a)->use == 3 )
660
661 /*-- parse-packet.c --*/
662 int gpg_parse_packet( gpg_iobuf_t inp, PACKET *ret_pkt );
663 int gpg_read_keyblock( gpg_iobuf_t a, PACKET **pending_pkt,
664 gpg_kbnode_t *ret_root );
665
666 const byte * gpg_parse_sig_subpkt( const subpktarea_t * buffer,
667 sigsubpkttype_t reqtype,
668 size_t *ret_n );
669 const byte * gpg_parse_sig_subpkt2( PKT_signature * sig,
670 sigsubpkttype_t reqtype,
671 size_t *ret_n );
672 void gpg_free_packet( PACKET *pkt );
673
674 int pubkey_get_npkey( int algo );
675 int pubkey_get_nskey( int algo );
676 int pubkey_get_nsig( int algo );
677 int pubkey_get_nenc( int algo );
678
679
680 u32 gpg_keyid_from_sk( PKT_secret_key * sk, byte *fprint );
681 u32 gpg_keyid_from_pk( PKT_public_key * pk, byte *fprint );
682
683 /*-- armor.c --*/
684 int gpg_use_armor_filter( gpg_iobuf_t a );
685 int gpg_armor_filter( void *opaque, int control, gpg_iobuf_t a, byte *buf,
686 size_t *ret_len);
687
688 /*-- rand.c --*/
689 void gpg_randomize( unsigned char *buffer, size_t length, int level );
690 char gpg_random_char( int level );
691 int gpg_quick_random_gen( int onoff );
692 char gpg_random_char( int level );
693
694 /*-- kbnode.c --*/
695 gpg_kbnode_t gpg_new_kbnode( PACKET *pkt );
696 void gpg_release_kbnode( gpg_kbnode_t n );
697 void gpg_add_kbnode( gpg_kbnode_t root, gpg_kbnode_t node );
698 gpg_kbnode_t gpg_walk_kbnode( gpg_kbnode_t root, gpg_kbnode_t *context, int all );
699
700 #ifdef __cplusplus
701 }
702 #endif
703
704
705 #endif /*GPGLIB_OPENPGP_H*/
706

Properties

Name Value
svn:eol-style native

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26