42af6a67 |
1 | #define SSH2_GSS_OIDTYPE 0x06 |
2 | typedef void *Ssh_gss_ctx; |
3 | typedef void *Ssh_gss_name; |
4 | |
5 | typedef enum Ssh_gss_stat { |
6 | SSH_GSS_OK = 0, |
7 | SSH_GSS_S_CONTINUE_NEEDED, |
8 | SSH_GSS_NO_MEM, |
9 | SSH_GSS_BAD_HOST_NAME, |
10 | SSH_GSS_FAILURE |
11 | } Ssh_gss_stat; |
12 | |
13 | #define SSH_GSS_S_COMPLETE SSH_GSS_OK |
14 | |
15 | typedef struct Ssh_gss_buf { |
16 | int len; |
17 | char *data; |
18 | } Ssh_gss_buf; |
19 | |
20 | #define SSH_GSS_EMPTY_BUF (Ssh_gss_buf) {0,NULL} |
21 | |
22 | #define SSH_GSS_CLEAR_BUF(buf) do { \ |
23 | (*buf).len = 0; \ |
24 | (*buf).data = NULL; \ |
25 | } while (0) |
26 | |
27 | /* Functions, provided by either wingss.c or uxgss.c */ |
28 | |
29 | /* |
30 | * Do startup-time initialisation for using GSSAPI. (On Windows, |
31 | * for instance, this dynamically loads the GSSAPI DLL and |
32 | * retrieves some function pointers.) |
33 | * |
34 | * Return value is 1 on success, or 0 if initialisation failed. |
35 | * |
36 | * May be called multiple times (since the most convenient place |
37 | * to call it _from_ is the ssh.c setup code), and will harmlessly |
38 | * return success if already initialised. |
39 | */ |
40 | int ssh_gss_init(void); |
41 | |
42 | /* |
43 | * Fills in buf with a string describing the GSSAPI mechanism in |
44 | * use. buf->data is not dynamically allocated. |
45 | */ |
46 | Ssh_gss_stat ssh_gss_indicate_mech(Ssh_gss_buf *buf); |
47 | |
48 | /* |
49 | * Converts a name such as a hostname into a GSSAPI internal form, |
50 | * which is placed in "out". The result should be freed by |
51 | * ssh_gss_release_name(). |
52 | */ |
53 | Ssh_gss_stat ssh_gss_import_name(char *in, Ssh_gss_name *out); |
54 | |
55 | /* |
56 | * Frees the contents of an Ssh_gss_name structure filled in by |
57 | * ssh_gss_import_name(). |
58 | */ |
59 | Ssh_gss_stat ssh_gss_release_name(Ssh_gss_name *name); |
60 | |
61 | /* |
62 | * The main GSSAPI security context setup function. The "out" |
63 | * parameter will need to be freed by ssh_gss_free_tok. |
64 | */ |
65 | Ssh_gss_stat ssh_gss_init_sec_context(Ssh_gss_ctx *ctx, Ssh_gss_name name, int delegate, |
66 | Ssh_gss_buf *in, Ssh_gss_buf *out); |
67 | |
68 | /* |
69 | * Frees the contents of an Ssh_gss_buf filled in by |
70 | * ssh_gss_init_sec_context(). Do not accidentally call this on |
71 | * something filled in by ssh_gss_get_mic() (which requires a |
72 | * different free function) or something filled in by any other |
73 | * way. |
74 | */ |
75 | Ssh_gss_stat ssh_gss_free_tok(Ssh_gss_buf *); |
76 | |
77 | /* |
78 | * Acquires the credentials to perform authentication in the first |
79 | * place. Needs to be freed by ssh_gss_release_cred(). |
80 | */ |
81 | Ssh_gss_stat ssh_gss_acquire_cred(Ssh_gss_ctx *); |
82 | |
83 | /* |
84 | * Frees the contents of an Ssh_gss_ctx filled in by |
85 | * ssh_gss_acquire_cred(). |
86 | */ |
87 | Ssh_gss_stat ssh_gss_release_cred(Ssh_gss_ctx *); |
88 | |
89 | /* |
90 | * Gets a MIC for some input data. "out" needs to be freed by |
91 | * ssh_gss_free_mic(). |
92 | */ |
93 | Ssh_gss_stat ssh_gss_get_mic(Ssh_gss_ctx ctx, Ssh_gss_buf *in, |
94 | Ssh_gss_buf *out); |
95 | |
96 | /* |
97 | * Frees the contents of an Ssh_gss_buf filled in by |
98 | * ssh_gss_get_mic(). Do not accidentally call this on something |
99 | * filled in by ssh_gss_init_sec_context() (which requires a |
100 | * different free function) or something filled in by any other |
101 | * way. |
102 | */ |
103 | Ssh_gss_stat ssh_gss_free_mic(Ssh_gss_buf *); |
104 | |
105 | /* |
106 | * Return an error message after authentication failed. The |
107 | * message string is returned in "buf", with buf->len giving the |
108 | * number of characters of printable message text and buf->data |
109 | * containing one more character which is a trailing NUL. |
110 | * buf->data should be manually freed by the caller. |
111 | */ |
112 | Ssh_gss_stat ssh_gss_display_status(Ssh_gss_ctx, Ssh_gss_buf *buf); |