Repository navigation
Expand file tree
/
Copy pathdkim.h
More file actions
1565 lines (1334 loc) · 42.4 KB
/
Copy pathdkim.h
File metadata and controls
1565 lines (1334 loc) · 42.4 KB
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
5
8000
34
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
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
** Copyright (c) 2005-2009 Sendmail, Inc. and its suppliers.
** All rights reserved.
**
** Copyright (c) 2009, 2010, The OpenDKIM Project. All rights reserved.
*/
#ifndef _DKIM_H_
#define _DKIM_H_
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
#ifndef lint
static char dkim_h_id[] = "@(#)$Id: dkim.h,v 1.25.2.2 2010/04/07 19:23:17 cm-msk Exp $";
#endif /* !lint */
/* system includes */
#include <sys/types.h>
#include <sys/param.h>
#include <stdbool.h>
/*
** version -- 0xrrMMmmpp
**
** rr == release number
** MM == major revision number
** mm == minor revision number
** pp == patch number
*/
#define OPENDKIM_LIB_VERSION 0x01020000
#ifdef __STDC__
# ifndef __P
# define __P(x) x
# endif /* ! __P */
#else /* __STDC__ */
# ifndef __P
# define __P(x) ()
# endif /* ! __P */
#endif /* __STDC__ */
/* definitions */
#define DKIM_HDRMARGIN 75 /* "standard" header margin */
#define DKIM_MAXHEADER 4096 /* buffer for caching one header */
#define DKIM_MAXHOSTNAMELEN 256 /* max. FQDN we support */
#define DKIM_SIGNHEADER "DKIM-Signature"
/* DKIM signature header */
/* special DNS tokens */
#define DKIM_DNSKEYNAME "_domainkey"
/* reserved DNS sub-zone */
#define DKIM_DNSPOLICYNAME "_adsp" /* reserved DNS sub-zone */
/*
** DKIM_STAT -- status code type
*/
typedef int DKIM_STAT;
#define DKIM_STAT_OK 0 /* function completed successfully */
#define DKIM_STAT_BADSIG 1 /* signature available but failed */
#define DKIM_STAT_NOSIG 2 /* no signature available */
#define DKIM_STAT_NOKEY 3 /* public key not found */
#define DKIM_STAT_CANTVRFY 4 /* can't get domain key to verify */
#define DKIM_STAT_SYNTAX 5 /* message is not valid syntax */
#define DKIM_STAT_NORESOURCE 6 /* resource unavailable */
#define DKIM_STAT_INTERNAL 7 /* internal error */
#define DKIM_STAT_REVOKED 8 /* key found, but revoked */
#define DKIM_STAT_INVALID 9 /* invalid function parameter */
#define DKIM_STAT_NOTIMPLEMENT 10 /* function not implemented */
#define DKIM_STAT_KEYFAIL 11 /* key retrieval failed */
#define DKIM_STAT_CBREJECT 12 /* callback requested reject */
#define DKIM_STAT_CBINVALID 13 /* callback gave invalid result */
#define DKIM_STAT_CBTRYAGAIN 14 /* callback says try again later */
#define DKIM_STAT_CBERROR 15 /* callback error */
#define DKIM_STAT_MULTIDNSREPLY 16 /* multiple DNS replies */
/*
** DKIM_CBSTAT -- callback status code type
*/
typedef int DKIM_CBSTAT;
#define DKIM_CBSTAT_CONTINUE 0 /* continue */
#define DKIM_CBSTAT_REJECT 1 /* reject */
#define DKIM_CBSTAT_TRYAGAIN 2 /* try again later */
#define DKIM_CBSTAT_NOTFOUND 3 /* requested record not found */
#define DKIM_CBSTAT_ERROR 4 /* error requesting record */
/*
** DKIM_SIGERROR -- signature errors
*/
typedef int DKIM_SIGERROR;
#define DKIM_SIGERROR_UNKNOWN (-1) /* unknown error */
#define DKIM_SIGERROR_OK 0 /* no error */
#define DKIM_SIGERROR_VERSION 1 /* unsupported version */
#define DKIM_SIGERROR_DOMAIN 2 /* invalid domain (d=/i=) */
#define DKIM_SIGERROR_EXPIRED 3 /* signature expired */
#define DKIM_SIGERROR_FUTURE 4 /* signature in the future */
#define DKIM_SIGERROR_TIMESTAMPS 5 /* x= < t= */
#define DKIM_SIGERROR_MISSING_C 6 /* c= missing */
#define DKIM_SIGERROR_INVALID_HC 7 /* c= invalid (header) */
#define DKIM_SIGERROR_INVALID_BC 8 /* c= invalid (body) */
#define DKIM_SIGERROR_MISSING_A 9 /* a= missing */
#define DKIM_SIGERROR_INVALID_A 10 /* a= invalid */
#define DKIM_SIGERROR_MISSING_H 11 /* h= missing */
#define DKIM_SIGERROR_INVALID_L 12 /* l= invalid */
#define DKIM_SIGERROR_INVALID_Q 13 /* q= invalid */
#define DKIM_SIGERROR_INVALID_QO 14 /* q= option invalid */
#define DKIM_SIGERROR_MISSING_D 15 /* d= missing */
#define DKIM_SIGERROR_EMPTY_D 16 /* d= empty */
#define DKIM_SIGERROR_MISSING_S 17 /* s= missing */
#define DKIM_SIGERROR_EMPTY_S 18 /* s= empty */
#define DKIM_SIGERROR_MISSING_B 19 /* b= missing */
#define DKIM_SIGERROR_EMPTY_B 20 /* b= empty */
#define DKIM_SIGERROR_CORRUPT_B 21 /* b= corrupt */
#define DKIM_SIGERROR_NOKEY 22 /* no key found in DNS */
#define DKIM_SIGERROR_DNSSYNTAX 23 /* DNS reply corrupt */
#define DKIM_SIGERROR_KEYFAIL 24 /* DNS query failed */
#define DKIM_SIGERROR_MISSING_BH 25 /* bh= missing */
#define DKIM_SIGERROR_EMPTY_BH 26 /* bh= empty */
#define DKIM_SIGERROR_CORRUPT_BH 27 /* bh= corrupt */
#define DKIM_SIGERROR_BADSIG 28 /* signature mismatch */
#define DKIM_SIGERROR_SUBDOMAIN 29 /* unauthorized subdomain */
#define DKIM_SIGERROR_MULTIREPLY 30 /* multiple records returned */
#define DKIM_SIGERROR_EMPTY_H 31 /* h= empty */
#define DKIM_SIGERROR_INVALID_H 32 /* h= missing req'd entries */
#define DKIM_SIGERROR_TOOLARGE_L 33 /* l= value exceeds body size */
#define DKIM_SIGERROR_MBSFAILED 34 /* "must be signed" failure */
#define DKIM_SIGERROR_KEYVERSION 35 /* unknown key version */
#define DKIM_SIGERROR_KEYUNKNOWNHASH 36 /* unknown key hash */
#define DKIM_SIGERROR_KEYHASHMISMATCH 37 /* sig-key hash mismatch */
#define DKIM_SIGERROR_NOTEMAILKEY 38 /* not an e-mail key */
#define DKIM_SIGERROR_GRANULARITY 39 /* key granularity mismatch */
#define DKIM_SIGERROR_KEYTYPEMISSING 40 /* key type missing */
#define DKIM_SIGERROR_KEYTYPEUNKNOWN 41 /* key type unknown */
#define DKIM_SIGERROR_KEYREVOKED 42 /* key revoked */
#define DKIM_SIGERROR_KEYDECODE 43 /* key couldn't be decoded */
/*
** DKIM_CANON -- canonicalization method
*/
typedef int dkim_canon_t;
#define DKIM_CANON_UNKNOWN (-1) /* unknown method */
#define DKIM_CANON_SIMPLE 0 /* as specified in DKIM spec */
#define DKIM_CANON_RELAXED 1 /* as specified in DKIM spec */
#define DKIM_CANON_DEFAULT DKIM_CANON_SIMPLE
/*
** DKIM_SIGN -- signing method
*/
typedef int dkim_alg_t;
#define DKIM_SIGN_UNKNOWN (-2) /* unknown method */
#define DKIM_SIGN_DEFAULT (-1) /* use internal default */
#define DKIM_SIGN_RSASHA1 0 /* an RSA-signed SHA1 digest */
#define DKIM_SIGN_RSASHA256 1 /* an RSA-signed SHA256 digest */
/*
** DKIM_QUERY -- query method
*/
typedef int dkim_query_t;
#define DKIM_QUERY_UNKNOWN (-1) /* unknown method */
#define DKIM_QUERY_DNS 0 /* DNS query method (per the draft) */
#define DKIM_QUERY_FILE 1 /* text file method (for testing) */
#define DKIM_QUERY_DEFAULT DKIM_QUERY_DNS
/*
** DKIM_PARAM -- known signature parameters
*/
typedef int dkim_param_t;
#define DKIM_PARAM_UNKNOWN (-1) /* unknown */
#define DKIM_PARAM_SIGNATURE 0 /* b */
#define DKIM_PARAM_SIGNALG 1 /* a */
#define DKIM_PARAM_DOMAIN 2 /* d */
#define DKIM_PARAM_CANONALG 3 /* c */
#define DKIM_PARAM_QUERYMETHO
8000
D 4 /* q */
#define DKIM_PARAM_SELECTOR 5 /* s */
#define DKIM_PARAM_HDRLIST 6 /* h */
#define DKIM_PARAM_VERSION 7 /* v */
#define DKIM_PARAM_IDENTITY 8 /* i */
#define DKIM_PARAM_TIMESTAMP 9 /* t */
#define DKIM_PARAM_EXPIRATION 10 /* x */
#define DKIM_PARAM_COPIEDHDRS 11 /* z */
#define DKIM_PARAM_BODYHASH 12 /* bh */
#define DKIM_PARAM_BODYLENGTH 13 /* l */
/*
** DKIM_POLICY -- policies
*/
typedef int dkim_policy_t;
#define DKIM_POLICY_NONE (-1) /* none/undefined */
#define DKIM_POLICY_UNKNOWN 0 /* unknown */
#define DKIM_POLICY_ALL 1 /* all */
#define DKIM_POLICY_DISCARDABLE 2 /* discardable */
#define DKIM_POLICY_DEFAULT DKIM_POLICY_UNKNOWN
#define DKIM_POLICY_DEFAULTTXT "dkim=unknown"
/*
** DKIM_PRESULT -- policy results
*/
#define DKIM_PRESULT_NONE (-1) /* none/undefined */
#define DKIM_PRESULT_NXDOMAIN 0 /* domain does not exist */
#define DKIM_PRESULT_AUTHOR 1 /* ADSP found for author */
/*
** DKIM_MODE -- mode of a handle
*/
#define DKIM_MODE_UNKNOWN (-1)
#define DKIM_MODE_SIGN 0
#define DKIM_MODE_VERIFY 1
/*
** DKIM_OPTS -- library-specific options
*/
typedef int dkim_opt_t;
#define DKIM_OP_GETOPT 0
#define DKIM_OP_SETOPT 1
typedef int dkim_opts_t;
#define DKIM_OPTS_FLAGS 0
#define DKIM_OPTS_TMPDIR 1
#define DKIM_OPTS_TIMEOUT 2
#define DKIM_OPTS_SENDERHDRS 3
#define DKIM_OPTS_SIGNHDRS 4
#define DKIM_OPTS_VERSION 5 /* unused */
#define DKIM_OPTS_QUERYMETHOD 6
#define DKIM_OPTS_QUERYINFO 7
#define DKIM_OPTS_FIXEDTIME 8
#define DKIM_OPTS_SKIPHDRS 9
#define DKIM_OPTS_ALWAYSHDRS 10
#define DKIM_OPTS_SIGNATURETTL 11
#define DKIM_OPTS_CLOCKDRIFT 12
#define DKIM_OPTS_MUSTBESIGNED 13
#define DKIM_LIBFLAGS_NONE 0x000
#define DKIM_LIBFLAGS_TMPFILES 0x001
#define DKIM_LIBFLAGS_KEEPFILES 0x002
#define DKIM_LIBFLAGS_SIGNLEN 0x004
#define DKIM_LIBFLAGS_CACHE 0x008
#define DKIM_LIBFLAGS_ZTAGS 0x010
#define DKIM_LIBFLAGS_DELAYSIGPROC 0x020
#define DKIM_LIBFLAGS_EOHCHECK 0x040
#define DKIM_LIBFLAGS_ACCEPTV05 0x080
#define DKIM_LIBFLAGS_FIXCRLF 0x100
#define DKIM_LIBFLAGS_ACCEPTDK 0x200
#define DKIM_LIBFLAGS_BADSIGHANDLES 0x400
#define DKIM_LIBFLAGS_VERIFYONE 0x800
#define DKIM_LIBFLAGS_DEFAULT DKIM_LIBFLAGS_NONE
#define DKIM_REP_DEFREJECT 1001
#define DKIM_REP_ROOT "al.dkim-reputation.org"
/*
** DKIM_DNSSEC -- results of DNSSEC queries
*/
#define DKIM_DNSSEC_UNKNOWN (-1)
#define DKIM_DNSSEC_BOGUS 0
#define DKIM_DNSSEC_INSECURE 1
#define DKIM_DNSSEC_SECURE 2
/*
** DKIM_LIB -- library handle
*/
struct dkim_lib;
typedef struct dkim_lib DKIM_LIB;
/*
** DKIM -- DKIM context
*/
struct dkim;
typedef struct dkim DKIM;
/*
** DKIM_SIGKEY_T -- private/public key (unencoded)
*/
typedef unsigned char * dkim_sigkey_t;
/*
** DKIM_SIGINFO -- signature information for use by the caller
*/
struct dkim_siginfo;
typedef struct dkim_siginfo DKIM_SIGINFO;
#define DKIM_SIGFLAG_IGNORE 0x01
#define DKIM_SIGFLAG_PROCESSED 0x02
#define DKIM_SIGFLAG_PASSED 0x04
#define DKIM_SIGFLAG_TESTKEY 0x08
#define DKIM_SIGFLAG_NOSUBDOMAIN 0x10
#define DKIM_SIGBH_UNTESTED (-1)
#define DKIM_SIGBH_MATCH 0
#define DKIM_SIGBH_MISMATCH 1
/*
** DKIM_PSTATE -- policy query state
*/
struct dkim_pstate;
typedef struct dkim_pstate DKIM_PSTATE;
/*
** DKIM_HDRDIFF -- header differences
*/
struct dkim_hdrdiff
{
u_char * hd_old;
u_char * hd_new;
};
/*
** PROTOTYPES
*/
/*
** DKIM_SET_TRUST_ANCHOR -- set trust anchor file path
**
** Parameters:
** lib -- DKIM_LIB handle to update
** tafile -- trust anchor file path
**
** Return value:
** A DKIM_STAT constant.
*/
extern DKIM_STAT dkim_set_trust_anchor __P((DKIM_LIB *lib, char *tafile));
/*
** DKIM_INIT -- initialize the DKIM package
**
** Parameters:
** None.
**
** Return value:
** A DKIM_STAT value.
*/
extern DKIM_LIB *dkim_init __P((void *(*mallocf)(void *closure, size_t nbytes),
void (*freef)(void *closure, void *p)));
/*
** DKIM_CLOSE -- shut down the DKIM package
**
** Parameters:
** lib -- DKIM_LIB handle to shut down
**
** Return value:
** None.
*/
extern void dkim_close __P((DKIM_LIB *lib));
/*
** DKIM_SIGN -- make a new DKIM context for signing
**
** Parameters:
** libhandle -- library handle, returned by dkim_init()
** id -- an opaque printable string for identifying this message, suitable
** for use in logging or debug output; may not be NULL
** memclosure -- memory closure, for use by user-provided malloc/free
** secretkey -- pointer to secret key data to use; if NULL, it will be
** obtained from disk
** selector -- selector being used to sign
** domain -- domain on behalf of which we're signing
** hdr_canon_alg -- canonicalization algorithm to use for headers;
** one of the DKIM_CANON_* macros, or -1 for default
** body_canon_alg -- canonicalization algorithm to use for body;
** one of the DKIM_CANON_* macros, or -1 for default
** sign_alg -- signing algorithm to use; one of the DKIM_SIGN_* macros,
** or -1 for default
** length -- number of bytes of the body to sign (-1 == all)
** statp -- pointer to a DKIM_STAT which is updated by this call
**
** Return value:
** A newly-allocated DKIM handle, or NULL on failure. "statp" will be
** updated.
*/
extern DKIM *dkim_sign __P((DKIM_LIB *libhandle, const char *id,
void *memclosure, const dkim_sigkey_t secretkey,
const char *selector, const char *domain,
dkim_canon_t hdr_canon_alg,
dkim_canon_t body_canon_alg,
dkim_alg_t sign_alg,
off_t length, DKIM_STAT *statp));
/*
** DKIM_VERIFY -- make a new DKIM context for verifying
**
** Parameters:
** libhandle -- library handle, returned by dkim_init()
** id -- an opaque printable string for identifying this message, suitable
** for use in logging or debug output; may not be NULL
** memclosure -- memory closure, for use by user-provided malloc/free
** statp -- pointer to a DKIM_STAT which is updated by this call
**
** Return value:
** A newly-allocated DKIM handle, or NULL on failure. "statp" will be
** updated.
*/
extern DKIM *dkim_verify __P((DKIM_LIB *libhandle, const char *id,
void *memclosure, DKIM_STAT *statp));
/*
** DKIM_RESIGN -- bind a new signing handle to a completed handle
**
** Parameters:
** new -- new signing handle
** old -- old signing/verifying handle
** hdrbind -- bind headers as well as body
**
** Return value:
** DKIM_STAT_OK -- success
** DKIM_STAT_INVALID -- invalid state of one or both handles
** DKIM_STAT_NOTIMPLEMENT -- not enabled at compile-time
**
** Side effects:
** Sets up flags such that the two are bound; dkim_free() on "old"
** now does nothing, and dkim_free() on "new" will free "old" once
** its reference count reaches zero. See documentation for details.
*/
extern DKIM_STAT dkim_resign __P((DKIM *new, DKIM *old, _Bool hdrbind));
/*
** DKIM_HEADER -- process a header
**
** Parameters:
** dkim -- a DKIM handle previously returned by dkim_sign() or
** dkim_verify()
** hdr -- the header to be processed, in canonical format
** len -- number of bytes to process starting at "hdr"
**
** Return value:
** A DKIM_STAT value.
*/
extern DKIM_STAT dkim_header __P((DKIM *dkim, u_char *hdr, size_t len));
/*
** DKIM_EOH -- identify end of headers
**
** Parameters:
** dkim -- a DKIM handle previously returned by dkim_sign() or
** dkim_verify()
**
** Return value:
** A DKIM_STAT value. DKIM_STAT_NOSIG will be returned if we're
** validating a signature but no DKIM signature was found in the headers.
*/
extern DKIM_STAT dkim_eoh __P((DKIM *dkim));
/*
** DKIM_BODY -- process a body chunk
**
** Parameters:
** dkim -- a DKIM handle previously returned by dkim_sign() or
** dkim_verify()
** buf -- the body chunk to be processed, in canonical format
** len -- number of bytes to process starting at "hdr"
**
** Return value:
** A DKIM_STAT value.
*/
extern DKIM_STAT dkim_body __P((DKIM *dkim, u_char *buf, size_t len));
/*
** DKIM_CHUNK -- process a message chunk
**
** Parameters:
** dkim -- DKIM handle
** buf -- data to process
** buflen -- number of bytes at "buf" to process
**
** Return value:
** A DKIM_STAT_* constant.
*/
extern DKIM_STAT dkim_chunk __P((DKIM *dkim, u_char *buf, size_t buflen));
/*
** DKIM_EOM -- identify end of body
**
** Parameters:
** dkim -- a DKIM handle previously returned by dkim_sign() or
** dkim_verify()
** testkey -- TRUE iff the a matching key was found but is marked as a
** test key (returned)
**
** Return value:
** A DKIM_STAT value.
*/
extern DKIM_STAT dkim_eom __P((DKIM *dkim, _Bool *testkey));
/*
** DKIM_KEY_SYNTAX -- process a key record parameter set for valid syntax
**
** Parameters:
** dkim -- DKIM context in which this is performed
** str -- string to be scanned
** len -- number of bytes available at "str"
**
** Return value:
** A DKIM_STAT constant.
*/
extern DKIM_STAT dkim_key_syntax __P((DKIM *dkim, u_char *str, size_t len));
/*
** DKIM_POLICY_SYNTAX -- process a policy record parameter set
** for valid syntax
**
** Parameters:
** dkim -- DKIM context in which this is performed
** str -- string to be scanned
** len -- number of bytes available at "str"
**
** Return value:
** A DKIM_STAT constant.
*/
extern DKIM_STAT dkim_policy_syntax __P((DKIM *dkim, u_char *str, size_t len));
/*
** DKIM_SIG_SYNTAX -- process a signature parameter set for valid syntax
**
** Parameters:
** dkim -- DKIM context in which this is performed
** str -- string to be scanned
** len -- number of bytes available at "str"
**
** Return value:
** A DKIM_STAT constant.
*/
extern DKIM_STAT dkim_sig_syntax __P((DKIM *dkim, u_char *str, size_t len));
/*
** DKIM_GETCACHESTATS -- retrieve cache statistics
**
** Parameters:
** queries -- number of queries handled (returned)
** hits -- number of cache hits (returned)
** expired -- number of expired hits (returned)
**
** Return value:
** DKIM_STAT_OK -- statistics returned
** DKIM_STAT_NOTIMPLEMENT -- function not implemented
**
** Notes:
** Any of the parameters may be NULL if the corresponding datum
** is not of interest.
*/
extern DKIM_STAT dkim_getcachestats __P((u_int *queries, u_int *hits,
u_int *expired));
/*
** DKIM_FLUSH_CACHE -- purge expired records from the database, reclaiming
** space for use by new data
**
** Parameters:
** lib -- DKIM library whose cache should be flushed
**
** Return value:
** -1 -- caching is not in effect
** >= 0 -- number of flushed records
*/
extern int dkim_flush_cache __P((DKIM_LIB *lib));
/*
** DKIM_MINBODY -- return number of bytes still expected
**
** Parameters:
** dkim -- DKIM handle
**
** Return value:
** 0 -- all canonicalizations satisfied
** ULONG_MAX -- at least one canonicalization wants the whole message
** other -- bytes required to satisfy all canonicalizations
*/
extern u_long dkim_minbody __P((DKIM *dkim));
/*
** DKIM_GETSIGLIST -- retrieve the list of signatures
**
** Parameters:
** dkim -- DKIM handle
** sigs -- pointer to a vector of DKIM_SIGINFO pointers (updated)
** nsigs -- pointer to an integer to receive the pointer count (updated)
**
** Return value:
** A DKIM_STAT_* constant.
*/
extern DKIM_STAT dkim_getsiglist __P((DKIM *dkim, DKIM_SIGINFO ***sigs,
int *nsigs));
/*
** DKIM_GETSIGNATURE -- retrieve the "final" signature
**
** Parameters:
** dkim -- DKIM handle
**
** Return value:
** Pointer to a DKIM_SIGINFO handle which is the one libopendkim will
** use to return a "final" result; NULL if none could be determined.
*/
extern DKIM_SIGINFO *dkim_getsignature __P((DKIM *dkim));
/*
** DKIM_GETSIGHDR -- compute and return a signature header for a message
**
** Parameters:
** dkim -- a DKIM handle previously returned by dkim_sign()
** buf -- buffer into which to write the signature
** len -- number of bytes available at "buf"
** initial -- width of the first line
**
** Return value:
** A DKIM_STAT value.
*/
extern DKIM_STAT dkim_getsighdr __P((DKIM *dkim, u_char *buf, size_t len,
size_t initial));
/*
** DKIM_GETSIGHDR_D -- compute and return a signature header for a message,
** but do it dynamically
**
** Parameters:
** dkim -- a DKIM handle previously returned by dkim_sign()
** initial -- width of the first line
** buf -- location of generated header (returned)
** len -- number of bytes available at "buf" (returned)
**
** Return value:
** A DKIM_STAT value.
*/
extern DKIM_STAT dkim_getsighdr_d __P((DKIM *dkim, size_t initial,
u_char **buf, size_t *len));
/*
** DKIM_SIG_HDRSIGNED -- retrieve the header list from a signature
**
** Parameters:
** sig -- DKIM_SIGINFO handle
** hdr -- header name to find
**
** Return value:
** TRUE iff "sig" had a header list in it and the header "hdr"
** appeared in that list.
*/
extern _Bool dkim_sig_hdrsigned __P((DKIM_SIGINFO *sig, char *hdr));
/*
** DKIM_SIG_GETDNSSEC -- retrieve DNSSEC results for a signature
**
** Parameters:
** sig -- DKIM_SIGINFO handle
**
** Return value:
** A DKIM_DNSSEC_* constant.
*/
extern u_int dkim_sig_getdnssec __P((DKIM_SIGINFO *sig));
/*
** DKIM_SIG_GETREPORTINFO -- retrieve reporting information from a key
**
** Parameters:
** dkim -- DKIM handle
** sig -- DKIM_SIGINFO handle
** hfd -- canonicalized header descriptor (or NULL) (returned)
** bfd -- canonicalized body descriptor (or NULL) (returned)
** addr -- address buffer (or NULL)
** addrlen -- size of addr
** fmt -- format buffer (or NULL)
** fmtlen -- size of fmt
** opts -- options buffer (or NULL)
** optslen -- size of opts
** smtp -- SMTP prefix buffer (or NULL)
** smtplen -- size of smtp
** interval -- requested report interval (or NULL)
**
** Return value:
** A DKIM_STAT_* constant.
*/
extern DKIM_STAT dkim_sig_getreportinfo __P((DKIM *dkim, DKIM_SIGINFO *sig,
int *hfd, int *bfd,
u_char *addr, size_t addrlen,
u_char *fmt, size_t fmtlen,
u_char *opts, size_t optslen,
u_char *smtp, size_t smtplen,
u_int *interval));
/*
** DKIM_SIG_GETIDENTITY -- retrieve identity of the signer
**
** Parameters:
** dkim -- DKIM handle
** sig -- DKIM_SIGINFO handle (or NULL to choose final one)
** val -- destination buffer
** vallen -- size of destination buffer
**
** Return value:
** A DKIM_STAT_* constant.
*/
extern DKIM_STAT dkim_sig_getidentity __P((DKIM *dkim, DKIM_SIGINFO *sig,
char *val, size_t vallen));
/*
** DKIM_SIG_GETCANONLEN -- report number of (canonicalized) body bytes that
** were signed
**
** Parameters:
** dkim -- a DKIM handle previously returned by dkim_sign() or
** dkim_verify()
** sig -- a DKIM_SIGINFO handle
** msglen -- total size of the message body (returned)
** canonlen -- total number of canonicalized bytes (returned)
** signlen -- restricted signature length (returned)
**
** Return value:
** A DKIM_STAT value.
**
** Notes:
** msglen or canonlen can be NULL if that information is not of interest
** to the caller.
*/
extern DKIM_STAT dkim_sig_getcanonlen __P((DKIM *dkim, DKIM_SIGINFO *sig,
off_t *msglen, off_t *canonlen,
off_t *signlen));
/*
** DKIM_OPTIONS -- set/get options
**
** Parameters:
** dkimlib -- DKIM library handle
** op -- operation (DKIM_OP_GET or DKIM_OP_SET)
** opt -- which option (a DKIM_OPTS_* constant)
** ptr -- value (in or out)
** len -- bytes available at "ptr"
**
** Return value:
** A DKIM_STAT value.
*/
extern DKIM_STAT dkim_options __P((DKIM_LIB *dkimlib, int op, dkim_opts_t opt,
void *ptr, size_t len));
/*
** DKIM_SIG_GETFLAGS -- retreive signature handle flags
**
** Parameters:
** sig -- DKIM_SIGINFO handle
**
** Return value:
** An unsigned integer which is a bitwise-OR of the DKIM_SIGFLAG_*
** constants currently set in the provided handle.
*/
extern unsigned int dkim_sig_getflags __P((DKIM_SIGINFO *sig));
/*
** DKIM_SIG_GETBH -- retreive signature handle "bh" test state
**
** Parameters:
** sig -- DKIM_SIGINFO handle
**
** Return value:
** An unsigned integer which is one of the DKIM_SIGBH_* constants
** indicating the current state of "bh" evaluation of the signature.
*/
extern unsigned int dkim_sig_getbh __P((DKIM_SIGINFO *sig));
/*
** DKIM_SIG_GETKEYSIZE -- retreive key size after verifying
**
** Parameters:
** sig -- DKIM_SIGINFO handle
** bits -- size of the key in bits (returned)
**
** Return value:
** A DKIM_STAT value.
*/
extern DKIM_STAT dkim_sig_getkeysize __P((DKIM_SIGINFO *sig,
unsigned int *bits));
/*
** DKIM_SIG_GETSIGNALG -- retreive signature algorithm after verifying
**
** Parameters:
** sig -- DKIM_SIGINFO handle
** alg -- a DKIM_SIGN_* value (returned)
**
** Return value:
** A DKIM_STAT value.
*/
extern DKIM_STAT dkim_sig_getsignalg __P((DKIM_SIGINFO *sig, dkim_alg_t *alg));
/*
** DKIM_SIG_GETSIGNTIME -- retreive signature timestamp after verifying
**
** Parameters:
** sig -- DKIM_SIGINFO handle
** when -- timestamp on the signature (returned)
**
** Return value:
** A DKIM_STAT value.
*/
extern DKIM_STAT dkim_sig_getsigntime __P((DKIM_SIGINFO *sig, time_t *when));
/*
** DKIM_SIG_GETSELECTOR -- retrieve selector used to generate the signature
**
** Parameters:
** sig -- DKIM_SIGINFO handle from which to retrieve selector
**
** Return value:
** Selector found in the signature.
*/
extern unsigned char *dkim_sig_getselector __P((DKIM_SIGINFO *sig));
/*
** DKIM_SIG_GETDOMAIN -- retrieve signing domain after verifying
**
** Parameters:
** sig -- DKIM_SIGINFO handle
**
** Return value:
** Pointer to the signing domain.
*/
extern unsigned char *dkim_sig_getdomain __P((DKIM_SIGINFO *sig));
/*
** DKIM_SIG_GETCANONS -- retrieve canonicaliztions after verifying
**
** Parameters:
** sig -- DKIM_SIGINFO handle
**
** Return value:
** DKIM_STAT_OK -- success
*/
extern DKIM_STAT dkim_sig_getcanons __P((DKIM_SIGINFO *sig, dkim_canon_t *hdr,
dkim_canon_t *body));
/*
** DKIM_SET_USER_CONTEXT -- set DKIM handle user context
**
** Parameters:
** dkim -- DKIM signing handle
** ctx -- user context pointer to store
**
** Parameters:
** A DKIM_STAT_* constant.
*/
extern DKIM_STAT dkim_set_user_context __P((DKIM *dkim, const void *ctx));
/*
** DKIM_GET_USER_CONTEXT -- retrieve DKIM handle user context
**
** Parameters:
** dkim -- DKIM signing handle
**
** Parameters:
** User context pointer.
*/
extern const void *dkim_get_user_context __P((DKIM *dkim));
/*
** DKIM_GET_MSGDATE -- retrieve value extracted from the Date: header
**
** Parameters:
** dkim -- DKIM handle
**
** Return value:
** time_t representing the value in the Date: header of the message,
** or 0 if no such header was found or the value in it was unusable
*/
extern time_t dkim_get_msgdate __P((DKIM *dkim));
/*
** DKIM_GETMODE -- return the mode (signing, verifying, etc.) of a handle
**
** Parameters:
** dkim -- DKIM handle
**
** Return value:
** A DKIM_MODE_* constant.
*/
extern int dkim_getmode __P((DKIM *dkim));
/*
** DKIM_GETDOMAIN -- retrieve policy domain from a DKIM context
**
** Parameters:
** dkim -- DKIM handle
**
** Return value:
** Pointer to the domain used for policy checking (if any) or NULL if
** no domain could be determined.
*/
extern u_char *dkim_getdomain __P((DKIM *dkim));
/*
** DKIM_SET_SIGNER -- set DKIM signature's signer
**
** Parameters:
** dkim -- DKIM signing handle
** signer -- signer to store
**
** Parameters:
** A DKIM_STAT_* constant.
*/
extern DKIM_STAT dkim_set_signer __P((DKIM *dkim, const char *signer));
/*
** DKIM_SET_DNS_CALLBACK -- set the DNS wait callback
**
** Parameters:
** libopendkim -- DKIM library handle
** func -- function to call; should take an opaque context pointer
** interval -- how often to call back
**
** Return value:
** DKIM_STAT_OK -- success
** DKIM_STAT_INVALID -- invalid use
** DKIM_STAT_NOTIMPLEMENT -- underlying resolver doesn't support callbacks
*/
extern DKIM_STAT dkim_set_dns_callback __P((DKIM_LIB *libopendkim,
void (*func)(const void *context),
unsigned int interval));
/*
** DKIM_SET_KEY_LOOKUP -- set the key lookup function
**
** Parameters:
** libopendkim -- DKIM library handle
** func -- function to call
**
** Return value:
** DKIM_STAT_OK
*/