Fixed issue #2495: "Show Reflog" dialog shows empty action for "push" entries
[TortoiseGit.git] / src / TortoisePlink / sshgss.h
blob61f35a299cd7028927c5bfa6f7cee8d0776d4ff6
1 #ifndef PUTTY_SSHGSS_H
2 #define PUTTY_SSHGSS_H
3 #include "putty.h"
4 #include "pgssapi.h"
6 #ifndef NO_GSSAPI
8 #define SSH2_GSS_OIDTYPE 0x06
9 typedef void *Ssh_gss_ctx;
11 typedef enum Ssh_gss_stat {
12 SSH_GSS_OK = 0,
13 SSH_GSS_S_CONTINUE_NEEDED,
14 SSH_GSS_NO_MEM,
15 SSH_GSS_BAD_HOST_NAME,
16 SSH_GSS_FAILURE
17 } Ssh_gss_stat;
19 #define SSH_GSS_S_COMPLETE SSH_GSS_OK
21 #define SSH_GSS_CLEAR_BUF(buf) do { \
22 (*buf).length = 0; \
23 (*buf).value = NULL; \
24 } while (0)
26 typedef gss_buffer_desc Ssh_gss_buf;
27 typedef gss_name_t Ssh_gss_name;
29 /* Functions, provided by either wingss.c or sshgssc.c */
31 struct ssh_gss_library;
34 * Prepare a collection of GSSAPI libraries for use in a single SSH
35 * connection. Returns a structure containing a list of libraries,
36 * with their ids (see struct ssh_gss_library below) filled in so
37 * that the client can go through them in the SSH user's preferred
38 * order.
40 * Must always return non-NULL. (Even if no libraries are available,
41 * it must return an empty structure.)
43 * The free function cleans up the structure, and its associated
44 * libraries (if any).
46 struct ssh_gss_liblist {
47 struct ssh_gss_library *libraries;
48 int nlibraries;
50 struct ssh_gss_liblist *ssh_gss_setup(Conf *conf);
51 void ssh_gss_cleanup(struct ssh_gss_liblist *list);
54 * Fills in buf with a string describing the GSSAPI mechanism in
55 * use. buf->data is not dynamically allocated.
57 typedef Ssh_gss_stat (*t_ssh_gss_indicate_mech)(struct ssh_gss_library *lib,
58 Ssh_gss_buf *buf);
61 * Converts a name such as a hostname into a GSSAPI internal form,
62 * which is placed in "out". The result should be freed by
63 * ssh_gss_release_name().
65 typedef Ssh_gss_stat (*t_ssh_gss_import_name)(struct ssh_gss_library *lib,
66 char *in, Ssh_gss_name *out);
69 * Frees the contents of an Ssh_gss_name structure filled in by
70 * ssh_gss_import_name().
72 typedef Ssh_gss_stat (*t_ssh_gss_release_name)(struct ssh_gss_library *lib,
73 Ssh_gss_name *name);
76 * The main GSSAPI security context setup function. The "out"
77 * parameter will need to be freed by ssh_gss_free_tok.
79 typedef Ssh_gss_stat (*t_ssh_gss_init_sec_context)
80 (struct ssh_gss_library *lib,
81 Ssh_gss_ctx *ctx, Ssh_gss_name name, int delegate,
82 Ssh_gss_buf *in, Ssh_gss_buf *out);
85 * Frees the contents of an Ssh_gss_buf filled in by
86 * ssh_gss_init_sec_context(). Do not accidentally call this on
87 * something filled in by ssh_gss_get_mic() (which requires a
88 * different free function) or something filled in by any other
89 * way.
91 typedef Ssh_gss_stat (*t_ssh_gss_free_tok)(struct ssh_gss_library *lib,
92 Ssh_gss_buf *);
95 * Acquires the credentials to perform authentication in the first
96 * place. Needs to be freed by ssh_gss_release_cred().
98 typedef Ssh_gss_stat (*t_ssh_gss_acquire_cred)(struct ssh_gss_library *lib,
99 Ssh_gss_ctx *);
102 * Frees the contents of an Ssh_gss_ctx filled in by
103 * ssh_gss_acquire_cred().
105 typedef Ssh_gss_stat (*t_ssh_gss_release_cred)(struct ssh_gss_library *lib,
106 Ssh_gss_ctx *);
109 * Gets a MIC for some input data. "out" needs to be freed by
110 * ssh_gss_free_mic().
112 typedef Ssh_gss_stat (*t_ssh_gss_get_mic)(struct ssh_gss_library *lib,
113 Ssh_gss_ctx ctx, Ssh_gss_buf *in,
114 Ssh_gss_buf *out);
117 * Frees the contents of an Ssh_gss_buf filled in by
118 * ssh_gss_get_mic(). Do not accidentally call this on something
119 * filled in by ssh_gss_init_sec_context() (which requires a
120 * different free function) or something filled in by any other
121 * way.
123 typedef Ssh_gss_stat (*t_ssh_gss_free_mic)(struct ssh_gss_library *lib,
124 Ssh_gss_buf *);
127 * Return an error message after authentication failed. The
128 * message string is returned in "buf", with buf->len giving the
129 * number of characters of printable message text and buf->data
130 * containing one more character which is a trailing NUL.
131 * buf->data should be manually freed by the caller.
133 typedef Ssh_gss_stat (*t_ssh_gss_display_status)(struct ssh_gss_library *lib,
134 Ssh_gss_ctx, Ssh_gss_buf *buf);
136 struct ssh_gss_library {
138 * Identifying number in the enumeration used by the
139 * configuration code to specify a preference order.
141 int id;
144 * Filled in at initialisation time, if there's anything
145 * interesting to say about how GSSAPI was initialised (e.g.
146 * which of a number of alternative libraries was used).
148 const char *gsslogmsg;
151 * Function pointers implementing the SSH wrapper layer on top
152 * of GSSAPI. (Defined in sshgssc, typically, though Windows
153 * provides an alternative layer to sit on top of the annoyingly
154 * different SSPI.)
156 t_ssh_gss_indicate_mech indicate_mech;
157 t_ssh_gss_import_name import_name;
158 t_ssh_gss_release_name release_name;
159 t_ssh_gss_init_sec_context init_sec_context;
160 t_ssh_gss_free_tok free_tok;
161 t_ssh_gss_acquire_cred acquire_cred;
162 t_ssh_gss_release_cred release_cred;
163 t_ssh_gss_get_mic get_mic;
164 t_ssh_gss_free_mic free_mic;
165 t_ssh_gss_display_status display_status;
168 * Additional data for the wrapper layers.
170 union {
171 struct gssapi_functions gssapi;
173 * The SSPI wrappers don't need to store their Windows API
174 * function pointers in this structure, because there can't
175 * be more than one set of them available.
177 } u;
180 * Wrapper layers will often also need to store a library handle
181 * of some sort for cleanup time.
183 void *handle;
186 #endif /* NO_GSSAPI */
188 #endif /*PUTTY_SSHGSS_H*/