1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #ifndef EMACS_GNUTLS_DEFINED
20 #define EMACS_GNUTLS_DEFINED
21
22 #ifdef HAVE_GNUTLS
23 #include <gnutls/gnutls.h>
24 #include <gnutls/x509.h>
25
26 #if 0x030000 <= GNUTLS_VERSION_NUMBER
27 # define HAVE_GNUTLS3
28 # include <gnutls/crypto.h>
29 #endif
30
31 #include "lisp.h"
32
33
34
35 #define GNUTLS_EMACS_HANDSHAKES_LIMIT 6000
36
37 typedef enum
38 {
39
40 GNUTLS_STAGE_EMPTY = 0,
41 GNUTLS_STAGE_CRED_ALLOC,
42 GNUTLS_STAGE_FILES,
43 GNUTLS_STAGE_CALLBACKS,
44 GNUTLS_STAGE_INIT,
45 GNUTLS_STAGE_PRIORITY,
46 GNUTLS_STAGE_CRED_SET,
47
48
49 GNUTLS_STAGE_HANDSHAKE_CANDO = GNUTLS_STAGE_CRED_SET,
50 GNUTLS_STAGE_TRANSPORT_POINTERS_SET,
51 GNUTLS_STAGE_HANDSHAKE_TRIED,
52
53 GNUTLS_STAGE_READY
54 } gnutls_initstage_t;
55
56 #define GNUTLS_EMACS_ERROR_NOT_LOADED (GNUTLS_E_APPLICATION_ERROR_MIN + 1)
57 #define GNUTLS_EMACS_ERROR_INVALID_TYPE GNUTLS_E_APPLICATION_ERROR_MIN
58
59 #define GNUTLS_INITSTAGE(proc) (XPROCESS (proc)->gnutls_initstage)
60
61 #define GNUTLS_PROCESS_USABLE(proc) \
62 (GNUTLS_INITSTAGE (proc) >= GNUTLS_STAGE_READY)
63
64 #define GNUTLS_LOG(level, max, string) \
65 do { \
66 if ((level) <= (max)) \
67 gnutls_log_function (level, "(Emacs) " string); \
68 } while (false)
69
70 #define GNUTLS_LOG2(level, max, string, extra) \
71 do { \
72 if ((level) <= (max)) \
73 gnutls_log_function2 (level, "(Emacs) " string, extra); \
74 } while (false)
75
76 #define GNUTLS_LOG2i(level, max, string, extra) \
77 do { \
78 if ((level) <= (max)) \
79 message ("gnutls.c: [%d] %s %d", level, string, extra); \
80 } while (false)
81
82 extern ptrdiff_t
83 emacs_gnutls_write (struct Lisp_Process *proc, const char *buf, ptrdiff_t nbyte);
84 extern ptrdiff_t
85 emacs_gnutls_read (struct Lisp_Process *proc, char *buf, ptrdiff_t nbyte);
86
87 extern ptrdiff_t emacs_gnutls_record_check_pending (gnutls_session_t state);
88 #ifdef WINDOWSNT
89 extern void emacs_gnutls_transport_set_errno (gnutls_session_t state, int err);
90 extern int w32_gnutls_rnd (gnutls_rnd_level_t, void *, size_t);
91 #endif
92 extern Lisp_Object emacs_gnutls_deinit (Lisp_Object);
93 extern int gnutls_try_handshake (struct Lisp_Process *p);
94 extern Lisp_Object gnutls_verify_boot (Lisp_Object proc, Lisp_Object proplist);
95
96 #endif
97
98 extern void syms_of_gnutls (void);
99
100 #endif