root/openpgpsdk/trunk/include/packet.h

Revision 136 (checked in by ben, 8 years ago)

Partial signature code, prior to refactor for verification.

  • Property svn:keywords set to Id
Line 
1 /** \file
2  * packet related headers.
3  */
4
5 #ifndef OPS_PACKET_H
6 #define OPS_PACKET_H
7
8 #include <time.h>
9 #include <openssl/bn.h>
10 #include "types.h"
11
12 /** general use structure for variable-length data */
13
14 typedef struct
15     {
16     size_t len;
17     unsigned char *contents;
18     } data_t;
19
20 /************************************/
21 /* Packet Tags - RFC2440bis-12, 4.2 */
22 /************************************/
23
24 /** Packet Tag - Bit 7 Mask (this bit is always set).
25  * The first byte of a packet is the "Packet Tag".  It always
26  * has bit 7 set.  This is the mask for it.
27  *
28  * \see RFC2440bis-12 4.2
29  */
30 #define OPS_PTAG_ALWAYS_SET             0x80
31
32 /** Packet Tag - New Format Flag.
33  * Bit 6 of the Packet Tag is the packet format indicator.
34  * If it is set, the new format is used, if cleared the
35  * old format is used.
36  *
37  * \see RFC2440bis-12 4.2
38  */
39 #define OPS_PTAG_NEW_FORMAT             0x40
40
41
42 /** Old Packet Format: Mask for content tag.
43  * In the old packet format bits 5 to 2 (including)
44  * are the content tag.  This is the mask to apply
45  * to the packet tag.  Note that you need to
46  * shift by #OPS_PTAG_OF_CONTENT_TAG_SHIFT bits.
47  *
48  * \see RFC2440bis-12 4.2
49  */
50 #define OPS_PTAG_OF_CONTENT_TAG_MASK    0x3c
51 /** Old Packet Format: Offset for the content tag.
52  * As described at #OPS_PTAG_OF_CONTENT_TAG_MASK the
53  * content tag needs to be shifted after being masked
54  * out from the Packet Tag.
55  *
56  * \see RFC2440bis-12 4.2
57  */
58 #define OPS_PTAG_OF_CONTENT_TAG_SHIFT   2
59 /** Old Packet Format: Mask for length type.
60  * Bits 1 and 0 of the packet tag are the length type
61  * in the old packet format.
62  *
63  * See #ops_ptag_of_lt_t for the meaning of the values.
64  *
65  * \see RFC2440bis-12 4.2
66  */
67 #define OPS_PTAG_OF_LENGTH_TYPE_MASK    0x03
68
69
70 /** Old Packet Format Lengths.
71  * Defines the meanings of the 2 bits for length type in the
72  * old packet format.
73  *
74  * \see RFC2440bis-12 4.2.1
75  */
76 typedef enum
77     {
78     OPS_PTAG_OF_LT_ONE_BYTE             =0x00, /*!< Packet has a 1 byte length - header is 2 bytes long. */
79     OPS_PTAG_OF_LT_TWO_BYTE             =0x01, /*!< Packet has a 2 byte length - header is 3 bytes long. */
80     OPS_PTAG_OF_LT_FOUR_BYTE            =0x02, /*!< Packet has a 4 byte length - header is 5 bytes long. */
81     OPS_PTAG_OF_LT_INDETERMINATE        =0x03  /*!< Packet has a indeterminate length. */
82     } ops_ptag_of_lt_t;
83
84
85 /** New Packet Format: Mask for content tag.
86  * In the new packet format the 6 rightmost bits
87  * are the content tag.  This is the mask to apply
88  * to the packet tag.  Note that you need to
89  * shift by #OPS_PTAG_NF_CONTENT_TAG_SHIFT bits.
90  *
91  * \see RFC2440bis-12 4.2
92  */
93 #define OPS_PTAG_NF_CONTENT_TAG_MASK    0x3f
94 /** New Packet Format: Offset for the content tag.
95  * As described at #OPS_PTAG_NF_CONTENT_TAG_MASK the
96  * content tag needs to be shifted after being masked
97  * out from the Packet Tag.
98  *
99  * \see RFC2440bis-12 4.2
100  */
101 #define OPS_PTAG_NF_CONTENT_TAG_SHIFT   0
102
103
104
105 /* PTag Content Tags */
106 /***************************/
107
108 /** Package Tags (aka Content Tags) and signatue subpacket types.
109  * This enumerates all rfc-defined packet tag values and the
110  * signature subpacket type values that we understand.
111  *
112  * \see RFC2440bis-12 4.3
113  * \see RFC2440bis-12 5.2.3.1
114  */
115 enum ops_content_tag_t
116     {
117     OPS_PTAG_CT_RESERVED                = 0,    /*!< Reserved - a packet tag must not have this value */
118     OPS_PTAG_CT_PK_SESSION_KEY          = 1,    /*!< Public-Key Encrypted Session Key Packet */
119     OPS_PTAG_CT_SIGNATURE               = 2,    /*!< Signature Packet */
120     OPS_PTAG_CT_SK_SESSION_KEY          = 3,    /*!< Symmetric-Key Encrypted Session Key Packet */
121     OPS_PTAG_CT_ONE_PASS_SIGNATURE      = 4,    /*!< One-Pass Signature Packet */
122     OPS_PTAG_CT_SECRET_KEY              = 5,    /*!< Secret Key Packet */
123     OPS_PTAG_CT_PUBLIC_KEY              = 6,    /*!< Public Key Packet */
124     OPS_PTAG_CT_SECRET_SUBKEY           = 7,    /*!< Secret Subkey Packet */
125     OPS_PTAG_CT_COMPRESSED              = 8,    /*!< Compressed Data Packet */
126     OPS_PTAG_CT_SK_DATA                 = 9,    /*!< Symmetrically Encrypted Data Packet */
127     OPS_PTAG_CT_MARKER                  =10,    /*!< Marker Packet */
128     OPS_PTAG_CT_LITERAL_DATA            =11,    /*!< Literal Data Packet */
129     OPS_PTAG_CT_TRUST                   =12,    /*!< Trust Packet */
130     OPS_PTAG_CT_USER_ID                 =13,    /*!< User ID Packet */
131     OPS_PTAG_CT_PUBLIC_SUBKEY           =14,    /*!< Public Subkey Packet */
132     OPS_PTAG_CT_RESERVED2               =15,    /*!< reserved */
133     OPS_PTAG_CT_RESERVED3               =16,    /*!< reserved */
134     OPS_PTAG_CT_USER_ATTRIBUTE          =17,    /*!< User Attribute Packet */
135     OPS_PTAG_CT_SK_IP_DATA              =18,    /*!< Sym. Encrypted and Integrity Protected Data Packet */
136     OPS_PTAG_CT_MDC                     =19,    /*!< Modification Detection Code Packet */
137
138     OPS_PARSER_ERROR                    =0x100, /*!< Internal Use: Parser Error */
139     OPS_PARSER_PTAG                     =0x101, /*!< Internal Use: The packet is the "Packet Tag" itself - used when
140                                                      callback sends back the PTag. */
141     OPS_PTAG_RAW_SS                     =0x102, /*!< Internal Use: content is raw sig subtag */
142     OPS_PTAG_SS_ALL                     =0x103, /*!< Internal Use: select all subtags */
143     OPS_PARSER_PACKET_END               =0x104,
144
145     /* signature subpackets (0x200-2ff) (type+0x200) */
146     /* only those we can parse are listed here */
147     OPS_PTAG_SIGNATURE_SUBPACKET_BASE   =0x200,         /*!< Base for signature subpacket types - All signature type
148                                                              values are relative to this value. */
149     OPS_PTAG_SS_CREATION_TIME           =0x200+2,       /*!< signature creation time */
150     OPS_PTAG_SS_EXPIRATION_TIME         =0x200+3,       /*!< signature expiration time */
151
152     OPS_PTAG_SS_TRUST                   =0x200+5,       /*!< trust signature */
153     OPS_PTAG_SS_REGEXP                  =0x200+6,       /*!< regular expression */
154     OPS_PTAG_SS_REVOCABLE               =0x200+7,       /*!< revocable */
155     OPS_PTAG_SS_KEY_EXPIRATION_TIME     =0x200+9,       /*!< key expiration time */
156     OPS_PTAG_SS_PREFERRED_SKA           =0x200+11,      /*!< preferred symmetric algorithms */
157     OPS_PTAG_SS_REVOCATION_KEY          =0x200+12,      /*!< revocation key */
158     OPS_PTAG_SS_ISSUER_KEY_ID           =0x200+16, /*!< issuer key ID */
159     OPS_PTAG_SS_NOTATION_DATA           =0x200+20, /*!< notation data */
160     OPS_PTAG_SS_PREFERRED_HASH          =0x200+21, /*!< preferred hash algorithms */
161     OPS_PTAG_SS_PREFERRED_COMPRESSION   =0x200+22, /*!< preferred compression algorithms */
162     OPS_PTAG_SS_KEY_SERVER_PREFS        =0x200+23, /*!< key server preferences */
163     OPS_PTAG_SS_PREFERRED_KEY_SERVER    =0x200+24, /*!< Preferred Key Server */
164     OPS_PTAG_SS_PRIMARY_USER_ID         =0x200+25, /*!< primary User ID */
165     OPS_PTAG_SS_POLICY_URL              =0x200+26, /*!< Policy URL */
166     OPS_PTAG_SS_KEY_FLAGS               =0x200+27, /*!< key flags */
167     OPS_PTAG_SS_REVOCATION_REASON       =0x200+29, /*!< reason for revocation */
168     OPS_PTAG_SS_FEATURES                =0x200+30, /*!< features */
169
170     OPS_PTAG_SS_USERDEFINED00   =0x200+100, /*!< internal or user-defined */
171     OPS_PTAG_SS_USERDEFINED01   =0x200+101,
172     OPS_PTAG_SS_USERDEFINED02   =0x200+102,
173     OPS_PTAG_SS_USERDEFINED03   =0x200+103,
174     OPS_PTAG_SS_USERDEFINED04   =0x200+104,
175     OPS_PTAG_SS_USERDEFINED05   =0x200+105,
176     OPS_PTAG_SS_USERDEFINED06   =0x200+106,
177     OPS_PTAG_SS_USERDEFINED07   =0x200+107,
178     OPS_PTAG_SS_USERDEFINED08   =0x200+108,
179     OPS_PTAG_SS_USERDEFINED09   =0x200+109,
180     OPS_PTAG_SS_USERDEFINED10   =0x200+110,
181
182        
183     /* pseudo content types */
184     OPS_PTAG_CT_LITERAL_DATA_HEADER     =0x300,
185     OPS_PTAG_CT_LITERAL_DATA_BODY       =0x300+1,
186     };
187
188 /** Structure to hold one parse error string. */
189 typedef struct
190     {
191     const char *error; /*!< error message. */
192     } ops_parser_error_t;
193
194 /** Structure to hold one packet tag.
195  * \see RFC2440bis-12 4.2
196  */
197 typedef struct
198     {
199     unsigned            new_format;     /*!< Whether this packet tag is new (true) or old format (false) */
200     unsigned            content_tag;    /*!< content_tag value - See #ops_content_tag_t for meanings */
201     ops_ptag_of_lt_t    length_type;    /*!< Length type (#ops_ptag_of_lt_t) - only if this packet tag is old format.  Set to 0 if new format. */
202     unsigned            length;         /*!< The length of the packet.  This value is set when we read and compute the
203                                           length information, not at the same moment we create the packet tag structure.
204                                           Only defined if #length_read is set. */  /* XXX: Ben, is this correct? */
205     //    unsigned              length_read;    /*!< How much bytes of this packet we have read so far - for internal use
206     //                                    only. */
207     } ops_ptag_t;
208
209 /** Public Key Algorithm Numbers.
210  * OpenPGP assigns a unique Algorithm Number to each algorithm that is part of OpenPGP.
211  *
212  * This lists algorithm numbers for public key algorithms.
213  *
214  * \see RFC2440bis-12 9.1
215  */
216 typedef enum
217     {
218     OPS_PKA_RSA                 =1,     /*!< RSA (Encrypt or Sign) */
219     OPS_PKA_RSA_ENCRYPT_ONLY    =2,     /*!< RSA Encrypt-Only (deprecated - \see RFC2440bis-12 12.4) */
220     OPS_PKA_RSA_SIGN_ONLY       =3,     /*!< RSA Sign-Only (deprecated - \see RFC2440bis-12 12.4) */
221     OPS_PKA_ELGAMAL             =16,    /*!< Elgamal (Encrypt-Only) */
222     OPS_PKA_DSA                 =17     /*!< DSA (Digital Signature Algorithm) */
223     } ops_public_key_algorithm_t;
224
225 /** Structure to hold one DSA public key parameters.
226  *
227  * \see RFC2440bis-12 5.5.2
228  */
229 typedef struct
230     {
231     BIGNUM *p;  /*!< DSA prime p */
232     BIGNUM *q;  /*!< DSA group order q */
233     BIGNUM *g;  /*!< DSA group generator g */
234     BIGNUM *y;  /*!< DSA public key value y (= g^x mod p with x being the secret) */
235     } ops_dsa_public_key_t;
236
237 /** Structure to hold on RSA public key.
238  *
239  * \see RFC2440bis-12 5.5.2
240  */
241 typedef struct
242     {
243     BIGNUM *n;  /*!< RSA public modulus n */
244     BIGNUM *e;  /*!< RSA public encryptiong exponent e */
245     } ops_rsa_public_key_t;
246
247 /** Structure to hold on ElGamal public key parameters.
248  *
249  * \see RFC2440bis-12 5.5.2
250  */
251 typedef struct
252     {
253     BIGNUM *p;  /*!< ElGamal prime p */
254     BIGNUM *g;  /*!< ElGamal group generator g */
255     BIGNUM *y;  /*!< ElGamal public key value y (= g^x mod p with x being the secret) */
256     } ops_elgamal_public_key_t;
257
258 /** Union to hold public key parameters of any algorithm */
259 typedef union
260     {
261     ops_dsa_public_key_t        dsa;            /*!< A DSA public key */
262     ops_rsa_public_key_t        rsa;            /*!< An RSA public key */
263     ops_elgamal_public_key_t    elgamal;        /*!< An ElGamal public key */
264     } ops_public_key_union_t;
265
266 /** Structure to hold one pgp public key */
267 typedef struct
268     {
269     unsigned                    version;        /*!< version of the key (v3, v4...) */
270     time_t                      creation_time;  /*!< when the key was created.  Note that interpretation varies with key
271                                                   version. */
272     unsigned                    days_valid;     /*!< validity period of the key in days since creation.  A value of 0
273                                                   has a special meaning indicating this key does not expire.  Only
274                                                   used with v3 keys. */
275     ops_public_key_algorithm_t  algorithm;      /*!< Public Key Algorithm type */
276     ops_public_key_union_t      key;            /*!< Public Key Parameters */
277     } ops_public_key_t;
278
279 typedef struct
280     {
281     BIGNUM *d;
282     BIGNUM *p;
283     BIGNUM *q;
284     BIGNUM *u;
285     } ops_rsa_secret_key_t;
286
287 typedef struct
288     {
289     ops_rsa_secret_key_t rsa;
290     } ops_secret_key_union_t;
291
292 typedef struct
293     {
294     ops_secret_key_union_t key;
295     } ops_secret_key_t;
296
297 /** Symmetric Key Algorithm Numbers.
298  * OpenPGP assigns a unique Algorithm Number to each algorithm that is part of OpenPGP.
299  *
300  * This lists algorithm numbers for symmetric key algorithms.
301  *
302  * \see RFC2440bis-12 9.2
303  */
304 typedef enum
305     {
306     OPS_SKA_PLAINTEXT   =0, /*!< Plaintext or unencrypted data */
307     OPS_SKA_IDEA        =1, /*!< IDEA */
308     OPS_SKA_TRIPLEDES   =2, /*!< TripleDES */
309     OPS_SKA_CAST5       =3, /*!< CAST5 */
310     OPS_SKA_BLOWFISH    =4, /*!< Blowfish */
311     OPS_SKA_AES_128     =7, /*!< AES with 128-bit key (AES) */
312     OPS_SKA_AES_192     =8, /*!< AES with 192-bit key */
313     OPS_SKA_AES_256     =9, /*!< AES with 256-bit key */
314     OPS_SKA_TWOFISH     =10, /*!< Twofish with 256-bit key (TWOFISH) */
315
316     } ops_symmetric_key_algorithm_t;
317
318 /** Structure to hold one trust packet's data */
319
320 typedef struct
321     {
322     data_t data;
323     } ops_trust_t;
324        
325 /** Structure to hold one user id */
326 typedef struct
327     {
328     char *                      user_id;        /*!< User ID string */
329     } ops_user_id_t;
330
331 /** Structure to hold one user attribute */
332 typedef struct
333     {
334     data_t data;
335     } ops_user_attribute_t;
336
337 /** Signature Version.
338  * OpenPGP has two different signature versions: version 3 and version 4.
339  *
340  * \see RFC2440bis-12 5.2
341  */
342 typedef enum
343     {
344     OPS_SIG_V3=3,       /*<! Version 3 Signature */
345     OPS_SIG_V4=4,       /*<! Version 4 Signature */
346     } ops_sig_version_t;
347
348 /** Signature Type.
349  * OpenPGP defines different signature types that allow giving different meanings to signatures.  Signature types
350  * include 0x10 for generitc User ID certifications (used when Ben signs Weasel's key), Subkey binding signatures,
351  * document signatures, key revocations, etc.
352  *
353  * Different types are used in different places, and most make only sense in their intended location (for instance a
354  * subkey binding has no place on a UserID).
355  *
356  * \see RFC2440bis-12 5.2.1
357  */
358 typedef enum
359     {
360     OPS_SIG_BINARY      =0x00,  /*<! Signature of a binary document */
361     OPS_SIG_TEXT        =0x01,  /*<! Signature of a canonical text document */
362     OPS_SIG_STANDALONE  =0x02,  /*<! Standalone signature */
363
364     OPS_CERT_GENERIC    =0x10,  /*<! Generic certification of a User ID and Public Key packet */
365     OPS_CERT_PERSONA    =0x11,  /*<! Persona certification of a User ID and Public Key packet */
366     OPS_CERT_CASUAL     =0x12,  /*<! Casual certification of a User ID and Public Key packet */
367     OPS_CERT_POSITIVE   =0x13,  /*<! Positive certification of a User ID and Public Key packet */
368
369     OPS_SIG_SUBKEY      =0x18,  /*<! Subkey Binding Signature */
370     OPS_SIG_PRIMARY     =0x19,  /*<! Primary Key Binding Signature */
371     OPS_SIG_DIRECT      =0x1f,  /*<! Signature directly on a key */
372
373     OPS_SIG_REV_KEY     =0x20,  /*<! Key revocation signature */
374     OPS_SIG_REV_SUBKEY  =0x28,  /*<! Subkey revocation signature */
375     OPS_SIG_REV_CERT    =0x30,  /*<! Certification revocation signature */
376
377     OPS_SIG_TIMESTAMP   =0x40,  /*<! Timestamp signature */
378
379     OPS_SIG_3RD_PARTY   =0x50,  /*<! Third-Party Confirmation signature */
380     } ops_sig_type_t;
381
382 /** Hashing Algorithm Numbers.
383  * OpenPGP assigns a unique Algorithm Number to each algorithm that is part of OpenPGP.
384  *
385  * This lists algorithm numbers for hash algorithms.
386  *
387  * \see RFC2440bis-12 9.4
388  */
389 typedef enum
390     {
391     OPS_HASH_MD5        = 1,    /*!< MD5 */
392     OPS_HASH_SHA1       = 2,    /*!< SHA-1 */
393     OPS_HASH_RIPEMD     = 3,    /*!< RIPEMD160 */
394
395     OPS_HASH_SHA256     = 8,    /*!< SHA256 */
396     OPS_HASH_SHA384     = 9,    /*!< SHA384 */
397     OPS_HASH_SHA512     =10,    /*!< SHA512 */
398     } ops_hash_algorithm_t;
399
400 /** Struct to hold parameters of an RSA signature */
401 typedef struct
402     {
403     BIGNUM                      *sig;   /*!< the signature value (m^d % n) */
404     } ops_rsa_signature_t;
405
406 /** Struct to hold parameters of a DSA signature */
407 typedef struct
408     {
409     BIGNUM                      *r;     /*!< DSA value r */
410     BIGNUM                      *s;     /*!< DSA value s */
411     } ops_dsa_signature_t;
412
413 /** Union to hold signature parameters of any algorithm */
414 typedef union
415     {
416     ops_rsa_signature_t         rsa;    /*!< An RSA Signature */
417     ops_dsa_signature_t         dsa;    /*!< A DSA Signature */
418     } ops_signature_union_t;
419
420 /** Struct to hold a signature packet.
421  *
422  * \see RFC2440bis-12 5.2.2
423  * \see RFC2440bis-12 5.2.3
424  */
425 #define OPS_KEY_ID_SIZE         8
426 typedef struct
427     {
428     ops_sig_version_t           version;        /*!< signature version number */
429     ops_sig_type_t              type;           /*!< signature type value */
430     time_t                      creation_time;  /*!< creation time of the signature - only with v3 signatures*/
431     unsigned char               signer_id[OPS_KEY_ID_SIZE];     /*!< Eight-octet key ID of signer*/
432     ops_public_key_algorithm_t  key_algorithm;  /*!< public key algorithm number */
433     ops_hash_algorithm_t        hash_algorithm; /*!< hashing algorithm number */
434     unsigned char               hash2[2];       /*!< high 2 bytes of hashed value - for quick test */
435     ops_signature_union_t       signature;      /*!< signature parameters */
436     size_t                      v4_hashed_data_start; // only valid if accumulate is set
437     size_t                      v4_hashed_data_length;
438     } ops_signature_t;
439
440 /** The raw bytes of a signature subpacket */
441
442 typedef struct
443     {
444     ops_content_tag_t           tag;
445     size_t                      length;
446     unsigned char               *raw;
447     } ops_ss_raw_t;
448
449 /** Signature Subpacket Type 5, Trust Level */
450
451 typedef struct
452     {
453     unsigned char               level;
454     unsigned char               amount;
455     } ops_ss_trust_t;
456
457 typedef struct
458         {
459         ops_boolean_t   revocable;
460         } ops_ss_revocable_t;
461        
462 typedef struct
463     {
464     time_t                      time;
465     } ops_ss_time_t;
466
467 typedef struct
468     {
469     unsigned char               key_id[OPS_KEY_ID_SIZE];
470     } ops_ss_key_id_t;
471
472 typedef struct
473     {
474     data_t flags;
475     data_t name;
476     data_t value;
477     } ops_ss_notation_data_t;
478
479 typedef struct
480     {
481     data_t data;
482     } ops_ss_userdefined_t;
483
484 typedef struct
485     {
486     data_t data;
487     /* Note that value 0 may represent the plaintext algorithm
488        so we cannot expect data->contents to be a null-terminated list */
489     } ops_ss_preferred_ska_t;
490
491 typedef struct
492     {
493     data_t data;
494     } ops_ss_preferred_hash_t;
495
496 typedef struct
497     {
498     data_t data;
499     } ops_ss_preferred_compression_t;
500
501 typedef struct
502     {
503     data_t data;
504     } ops_ss_key_flags_t;
505
506 typedef struct
507     {
508     data_t data;
509     } ops_ss_key_server_prefs_t;
510
511 typedef struct
512     {
513     data_t data;
514     } ops_ss_features_t;
515
516 typedef struct
517     {
518     size_t                      length;
519     unsigned char               *raw;
520     } ops_packet_t;
521
522 typedef enum
523     {
524     OPS_C_NONE=0,
525     OPS_C_ZIP=1,
526     OPS_C_ZLIB=2,
527     OPS_C_BZIP2=3,
528     } ops_compression_type_t;
529
530 // unlike most structures, this will feed its data as a stream
531 // to the application instead of directly including it
532 typedef struct
533     {
534     ops_compression_type_t      type;
535     } ops_compressed_t;
536
537 typedef struct
538     {
539     unsigned char               version;
540     ops_sig_type_t              sig_type;
541     ops_hash_algorithm_t        hash_algorithm;
542     ops_public_key_algorithm_t  key_algorithm;
543     unsigned char               keyid[OPS_KEY_ID_SIZE];
544     ops_boolean_t               nested;
545     } ops_one_pass_signature_t;
546
547 typedef struct
548     {
549     ops_boolean_t       primary_user_id;
550     } ops_ss_primary_user_id_t;
551
552 typedef struct
553     {
554     char *text;
555     } ops_ss_regexp_t;
556
557 typedef struct
558     {
559     char *text;
560     } ops_ss_policy_url_t;
561
562 typedef struct
563     {
564     char *text;
565     } ops_ss_preferred_key_server_t;
566
567 typedef struct
568     {
569     unsigned char       class;
570     unsigned char       algid;
571     unsigned char fingerprint[20];
572     } ops_ss_revocation_key_t;
573
574 typedef struct
575     {
576     unsigned char code;
577     char *text;
578     } ops_ss_revocation_reason_t;
579
580 typedef enum
581     {
582     OPS_LDT_BINARY='b',
583     OPS_LDT_TEXT='t',
584     OPS_LDT_UTF8='u',
585     OPS_LDT_LOCAL='l',
586     OPS_LDT_LOCAL2='1'
587     } literal_data_type_t;
588
589 typedef struct
590     {
591     literal_data_type_t         format;
592     char                        filename[256];
593     time_t                      modification_time;
594     } ops_literal_data_header_t;
595
596 typedef struct
597     {
598     size_t                      length;
599     unsigned char               data[8192];
600     } ops_literal_data_body_t;
601
602 typedef union
603     {
604     ops_parser_error_t          error;
605     ops_ptag_t                  ptag;
606     ops_public_key_t            public_key;
607     ops_trust_t                 trust;
608     ops_user_id_t               user_id;
609     ops_user_attribute_t        user_attribute;
610     ops_signature_t             signature;
611     ops_ss_raw_t                ss_raw;
612     ops_ss_trust_t              ss_trust;
613     ops_ss_revocable_t          ss_revocable;
614     ops_ss_time_t               ss_time;
615     ops_ss_key_id_t             ss_issuer_key_id;
616     ops_ss_notation_data_t      ss_notation_data;
617     ops_packet_t                packet;
618     ops_compressed_t            compressed;
619     ops_one_pass_signature_t    one_pass_signature;
620     ops_ss_preferred_ska_t      ss_preferred_ska;
621     ops_ss_preferred_hash_t     ss_preferred_hash;
622     ops_ss_preferred_compression_t     ss_preferred_compression;
623     ops_ss_key_flags_t          ss_key_flags;
624     ops_ss_key_server_prefs_t   ss_key_server_prefs;
625     ops_ss_primary_user_id_t    ss_primary_user_id;
626     ops_ss_regexp_t             ss_regexp;
627     ops_ss_policy_url_t         ss_policy_url;
628     ops_ss_preferred_key_server_t       ss_preferred_key_server;
629     ops_ss_revocation_key_t     ss_revocation_key;
630     ops_ss_userdefined_t        ss_userdefined;
631     ops_literal_data_header_t   literal_data_header;
632     ops_literal_data_body_t     literal_data_body;
633     ops_ss_features_t           ss_features;
634     ops_ss_revocation_reason_t  ss_revocation_reason;
635     } ops_parser_content_union_t;
636
637 struct ops_parser_content_t
638     {
639     ops_content_tag_t           tag;
640     unsigned char               critical; /* for signature subpackets */
641     ops_parser_content_union_t  content;
642     };
643
644 typedef struct
645     {
646     unsigned char               fingerprint[20];
647     unsigned                    length;
648     } ops_fingerprint_t;
649
650 void ops_init(void);
651 void ops_finish(void);
652 void ops_keyid(unsigned char keyid[OPS_KEY_ID_SIZE],
653                const ops_public_key_t *key);
654 void ops_fingerprint(ops_fingerprint_t *fp,const ops_public_key_t *key);
655 void ops_public_key_free(ops_public_key_t *key);
656 void ops_user_id_free(ops_user_id_t *id);
657 void ops_user_attribute_free(ops_user_attribute_t *att);
658 void ops_signature_free(ops_signature_t *sig);
659 void ops_trust_free(ops_trust_t * trust);
660 void ops_ss_preferred_ska_free(ops_ss_preferred_ska_t *ss_preferred_ska);
661 void ops_ss_preferred_hash_free(ops_ss_preferred_hash_t *ss_preferred_hash);
662 void ops_ss_preferred_compression_free(ops_ss_preferred_compression_t *ss_preferred_compression);
663 void ops_ss_key_flags_free(ops_ss_key_flags_t * ss_key_flags);
664 void ops_ss_key_server_prefs_free(ops_ss_key_server_prefs_t * ss_key_server_prefs);
665 void ops_ss_features_free(ops_ss_features_t * ss_features);
666 void ops_ss_notation_data_free(ops_ss_notation_data_t *ss_notation_data);
667 void ops_ss_policy_url_free(ops_ss_policy_url_t *ss_policy_url);
668 void ops_ss_preferred_key_server_free(ops_ss_preferred_key_server_t *ss_preferred_key_server);
669 void ops_ss_regexp_free(ops_ss_regexp_t *ss_regexp);
670 void ops_ss_userdefined_free(ops_ss_userdefined_t *ss_userdefined);
671 void ops_ss_revocation_reason_free(ops_ss_revocation_reason_t *ss_revocation_reason);
672 void ops_packet_free(ops_packet_t *packet);
673 void ops_parser_content_free(ops_parser_content_t *c);
674
675 /* vim:set textwidth=120: */
676 /* vim:set ts=8: */
677
678 #endif
679
Note: See TracBrowser for help on using the browser.