summaryrefslogtreecommitdiffstats
path: root/openpgp-ffi/include/sequoia/openpgp/types.h
blob: 74b4f1d63157119ea2ec226ec5d21579f1a2d67a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
#ifndef SEQUOIA_OPENPGP_TYPES_H
#define SEQUOIA_OPENPGP_TYPES_H

/*/
/// Holds a session key.
///
/// The session key is cleared when dropped.
/*/
typedef struct pgp_session_key *pgp_session_key_t;

/*/
/// Holds a password.
///
/// The password is cleared when dropped.
/*/
typedef struct pgp_password *pgp_password_t;

/*/
/// Holds a fingerprint.
/*/
typedef struct pgp_fingerprint *pgp_fingerprint_t;

/*/
/// Holds a KeyID.
/*/
typedef struct pgp_keyid *pgp_keyid_t;

/*/
/// Specifies the type of data (see [RFC 4880, section 6.2]).
///
/// [RFC 4880, section 6.2]: https://tools.ietf.org/html/rfc4880#section-6.2
/*/
typedef enum pgp_armor_kind {
  /*/
  /// When reading an Armored file, accept any type.
  /*/
  PGP_ARMOR_KIND_ANY,

  /*/
  /// A generic OpenPGP message.
  /*/
  PGP_ARMOR_KIND_MESSAGE,

  /*/
  /// A certificate.
  /*/
  PGP_ARMOR_KIND_PUBLICKEY,

  /*/
  /// A transferable secret key.
  /*/
  PGP_ARMOR_KIND_SECRETKEY,

  /*/
  /// A detached signature.
  /*/
  PGP_ARMOR_KIND_SIGNATURE,

  /*/
  /// A generic file.  This is a GnuPG extension.
  /*/
  PGP_ARMOR_KIND_FILE,

  /* Dummy value to make sure the enumeration has a defined size.  Do
     not use this value.  */
  PGP_ARMOR_KIND_FORCE_WIDTH = INT_MAX,
} pgp_armor_kind_t;

/*/
/// Represents a (key, value) pair in an armor header.
/*/
typedef struct pgp_armor_header {
  char *key;
  char *value;
} *pgp_armor_header_t;


/*/
/// Holds a revocation status.
/*/
typedef struct pgp_revocation_status *pgp_revocation_status_t;

typedef enum pgp_revocation_status_variant {
  /*/
  /// The key is definitely revoked.
  ///
  /// All self-revocations are returned, the most recent revocation
  /// first.
  /*/
  PGP_REVOCATION_STATUS_REVOKED,

  /*/
  /// We have a third-party revocation certificate that is allegedly
  /// from a designated revoker, but we don't have the designated
  /// revoker's key to check its validity.
  ///
  /// All such certificates are returned.  The caller must check
  /// them manually.
  /*/
  PGP_REVOCATION_STATUS_COULD_BE,

  /*/
  /// The key does not appear to be revoked, but perhaps an attacker
  /// has performed a DoS, which prevents us from seeing the
  /// revocation certificate.
  /*/
  PGP_REVOCATION_STATUS_NOT_AS_FAR_AS_WE_KNOW,

  /* Dummy value to make sure the enumeration has a defined size.  Do
     not use this value.  */
  PGP_REVOCATION_STATUS_FORCE_WIDTH = INT_MAX,
} pgp_revocation_status_variant_t;

typedef enum pgp_reason_for_revocation {
  /*/
  /// No reason specified (key revocations or cert revocations)
  /*/
  PGP_REASON_FOR_REVOCATION_UNSPECIFIED,

  /*/
  /// Key is superseded (key revocations)
  /*/
  PGP_REASON_FOR_REVOCATION_KEY_SUPERSEDED,

  /*/
  /// Key material has been compromised (key revocations)
  /*/
  PGP_REASON_FOR_REVOCATION_KEY_COMPROMISED,

  /*/
  /// Key is retired and no longer used (key revocations)
  /*/
  PGP_REASON_FOR_REVOCATION_KEY_RETIRED,

  /*/
  /// User ID information is no longer valid (cert revocations)
  /*/
  PGP_REASON_FOR_REVOCATION_UID_RETIRED,

  /* Dummy value to make sure the enumeration has a defined size.  Do
     not use this value.  */
  PGP_REASON_FOR_REVOCATION_FORCE_WIDTH = INT_MAX,
} pgp_reason_for_revocation_t;

typedef enum pgp_public_key_algorithm {
  /*/
  /// RSA (Encrypt or Sign)
  /*/
  PGP_PUBLIC_KEY_ALGO_RSA_ENCRYPT_SIGN,

  /*/
  /// RSA Encrypt-Only
  /*/
  PGP_PUBLIC_KEY_ALGO_RSA_ENCRYPT,

  /*/
  /// RSA Sign-Only
  /*/
  PGP_PUBLIC_KEY_ALGO_RSA_SIGN,

  /*/
  /// Elgamal (Encrypt-Only)
  /*/
  PGP_PUBLIC_KEY_ALGO_ELGAMAL_ENCRYPT,

  /*/
  /// DSA (Digital Signature Algorithm)
  /*/
  PGP_PUBLIC_KEY_ALGO_DSA,

  /*/
  /// Elliptic curve DH
  /*/
  PGP_PUBLIC_KEY_ALGO_ECDH,

  /*/
  /// Elliptic curve DSA
  /*/
  PGP_PUBLIC_KEY_ALGO_ECDSA,

  /*/
  /// Elgamal (Encrypt or Sign)
  /*/
  PGP_PUBLIC_KEY_ALGO_ELGAMAL_ENCRYPT_SIGN,

  /*/
  /// "Twisted" Edwards curve DSA
  /*/
  PGP_PUBLIC_KEY_ALGO_EDDSA,

  /* Dummy value to make sure the enumeration has a defined size.  Do
     not use this value.  */
  PGP_PUBLIC_KEY_ALGO_FORCE_WIDTH = INT_MAX,
} pgp_public_key_algo_t;

/*/
/// The OpenPGP packet tags as defined in [Section 4.3 of RFC 4880].
///
///   [Section 4.3 of RFC 4880]: https://tools.ietf.org/html/rfc4880#section-4.3
///
/// The values correspond to the serialized format.  The packet types
/// named `UnassignedXX` are not in use as of RFC 4880.
///
/// Use [`Tag::from_numeric`] to translate a numeric value to a symbolic
/// one.
///
///   [`Tag::from_numeric`]: enum.Tag.html#method.from_numeric
/*/
typedef enum pgp_tag {
    PGP_TAG_RESERVED0 = 0,
    /* Public-Key Encrypted Session Key Packet.  */
    PGP_TAG_PKESK = 1,
    PGP_TAG_SIGNATURE = 2,
    /* Symmetric-Key Encrypted Session Key Packet.  */
    PGP_TAG_SKESK = 3,
    /* One-Pass Signature Packet.  */
    PGP_TAG_ONE_PASS_SIG = 4,
    PGP_TAG_SECRET_KEY = 5,
    PGP_TAG_PUBLIC_KEY = 6,
    PGP_TAG_SECRET_SUBKEY = 7,
    PGP_TAG_COMPRESSED_DATA = 8,
    /* Symmetrically Encrypted Data Packet.  */
    PGP_TAG_SED = 9,
    PGP_TAG_MARKER = 10,
    PGP_TAG_LITERAL = 11,
    PGP_TAG_TRUST = 12,
    PGP_TAG_USER_ID = 13,
    PGP_TAG_PUBLIC_SUBKEY = 14,

    PGP_TAG_UNASSIGNED15 = 15,
    PGP_TAG_UNASSIGNED16 = 16,

    PGP_TAG_USER_ATTRIBUTE = 17,
    /* Sym. Encrypted and Integrity Protected Data Packet.  */
    PGP_TAG_SEIP = 18,
    /* Modification Detection Code Packet.  */
    PGP_TAG_MDC = 19,

    /* Unassigned packets (as of RFC4880).  */
    PGP_TAG_UNASSIGNED20 = 20,
    PGP_TAG_UNASSIGNED21 = 21,
    PGP_TAG_UNASSIGNED22 = 22,
    PGP_TAG_UNASSIGNED23 = 23,
    PGP_TAG_UNASSIGNED24 = 24,
    PGP_TAG_UNASSIGNED25 = 25,
    PGP_TAG_UNASSIGNED26 = 26,
    PGP_TAG_UNASSIGNED27 = 27,
    PGP_TAG_UNASSIGNED28 = 28,
    PGP_TAG_UNASSIGNED29 = 29,

    PGP_TAG_UNASSIGNED30 = 30,
    PGP_TAG_UNASSIGNED31 = 31,
    PGP_TAG_UNASSIGNED32 = 32,
    PGP_TAG_UNASSIGNED33 = 33,
    PGP_TAG_UNASSIGNED34 = 34,
    PGP_TAG_UNASSIGNED35 = 35,
    PGP_TAG_UNASSIGNED36 = 36,
    PGP_TAG_UNASSIGNED37 = 37,
    PGP_TAG_UNASSIGNED38 = 38,
    PGP_TAG_UNASSIGNED39 = 39,

    PGP_TAG_UNASSIGNED40 = 40,
    PGP_TAG_UNASSIGNED41 = 41,
    PGP_TAG_UNASSIGNED42 = 42,
    PGP_TAG_UNASSIGNED43 = 43,
    PGP_TAG_UNASSIGNED44 = 44,
    PGP_TAG_UNASSIGNED45 = 45,
    PGP_TAG_UNASSIGNED46 = 46,
    PGP_TAG_UNASSIGNED47 = 47,
    PGP_TAG_UNASSIGNED48 = 48,
    PGP_TAG_UNASSIGNED49 = 49,

    PGP_TAG_UNASSIGNED50 = 50,
    PGP_TAG_UNASSIGNED51 = 51,
    PGP_TAG_UNASSIGNED52 = 52,
    PGP_TAG_UNASSIGNED53 = 53,
    PGP_TAG_UNASSIGNED54 = 54,
    PGP_TAG_UNASSIGNED55 = 55,
    PGP_TAG_UNASSIGNED56 = 56,
    PGP_TAG_UNASSIGNED57 = 57,
    PGP_TAG_UNASSIGNED58 = 58,
    PGP_TAG_UNASSIGNED59 = 59,

    /* Experimental packets.  */
    PGP_TAG_PRIVATE0 = 60