2 * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
14 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 #include <gssapi_generic.h>
39 /* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */
40 #ifndef GSS_C_NT_HOSTBASED_SERVICE
41 #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
42 #endif /* GSS_C_NT_... */
46 /* draft-ietf-secsh-gsskeyex-03 */
47 #define SSH2_MSG_KEXGSS_INIT 30
48 #define SSH2_MSG_KEXGSS_CONTINUE 31
49 #define SSH2_MSG_KEXGSS_COMPLETE 32
50 #define SSH2_MSG_KEXGSS_HOSTKEY 33
51 #define SSH2_MSG_KEXGSS_ERROR 34
52 #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60
53 #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61
54 #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63
55 #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64
56 #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65
58 #define KEX_GSS_SHA1 "gss-group1-sha1-"
70 struct ssh_gssapi_mech_struct *mech;
71 ssh_gssapi_ccache store;
74 typedef struct ssh_gssapi_mech_struct {
78 int (*dochild) (ssh_gssapi_client *);
79 int (*userok) (ssh_gssapi_client *, char *);
80 int (*localname) (ssh_gssapi_client *, char **);
81 void (*storecreds) (ssh_gssapi_client *);
87 OM_uint32 major; /* both */
88 OM_uint32 minor; /* both */
89 gss_ctx_id_t context; /* both */
90 gss_name_t name; /* both */
91 gss_OID oid; /* client */
92 gss_cred_id_t creds; /* server */
93 gss_name_t client; /* server */
94 gss_cred_id_t client_creds; /* server */
97 extern ssh_gssapi_mech *supported_mechs[];
99 char *ssh_gssapi_mechanisms(char *host);
100 char *ssh_gssapi_client_mechanisms(char *host);
101 gss_OID ssh_gssapi_client_id_kex(Gssctxt *ctx, char *name);
102 int ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len);
103 void ssh_gssapi_set_oid_data(Gssctxt *ctx, void *data, size_t len);
104 void ssh_gssapi_set_oid(Gssctxt *ctx, gss_OID oid);
105 void ssh_gssapi_supported_oids(gss_OID_set *oidset);
106 ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *ctxt);
108 OM_uint32 ssh_gssapi_import_name(Gssctxt *ctx, const char *host);
109 OM_uint32 ssh_gssapi_acquire_cred(Gssctxt *ctx);
110 OM_uint32 ssh_gssapi_init_ctx(Gssctxt *ctx, int deleg_creds,
111 gss_buffer_desc *recv_tok,
112 gss_buffer_desc *send_tok, OM_uint32 *flags);
113 OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *ctx,
114 gss_buffer_desc *recv_tok,
115 gss_buffer_desc *send_tok,
117 OM_uint32 ssh_gssapi_getclient(Gssctxt *ctx,
118 ssh_gssapi_mech **mech,
119 gss_buffer_desc *name,
120 gss_cred_id_t *creds);
121 void ssh_gssapi_error(Gssctxt *ctx);
122 char *ssh_gssapi_last_error(Gssctxt *ctxt, OM_uint32 *maj, OM_uint32 *min);
123 void ssh_gssapi_build_ctx(Gssctxt **ctx);
124 void ssh_gssapi_delete_ctx(Gssctxt **ctx);
125 OM_uint32 ssh_gssapi_server_ctx(Gssctxt **ctx,gss_OID oid);
127 int ssh_gssapi_check_mechanism(gss_OID oid, char *host);
130 gss_OID ssh_gssapi_server_id_kex(char *name);
131 int ssh_gssapi_userok(char *name);
132 int ssh_gssapi_localname(char **name);
133 void ssh_gssapi_server(Kex *kex, Buffer *client_kexinit,
134 Buffer *server_kexinit);
136 OM_uint32 ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_desc *buffer,
137 gss_buffer_desc *hash);
139 void ssh_gssapi_do_child(char ***envp, u_int *envsizep);
140 void ssh_gssapi_cleanup_creds(void *ignored);
141 void ssh_gssapi_storecreds();
142 char *ssh_gssapi_server_mechanisms();
145 #endif /* _SSH_GSS_H */