Add support for mechanisms with no integrity
[openssh.git] / ssh-gss.h
1 /* $OpenBSD: ssh-gss.h,v 1.10 2007/06/12 08:20:00 djm Exp $ */
2 /*
3  * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25
26 #ifndef _SSH_GSS_H
27 #define _SSH_GSS_H
28
29 #ifdef GSSAPI
30
31 #ifdef HAVE_GSSAPI_H
32 #include <gssapi.h>
33 #elif defined(HAVE_GSSAPI_GSSAPI_H)
34 #include <gssapi/gssapi.h>
35 #endif
36
37 #ifdef HAVE_GSSAPI_EXT_H
38 #include <gssapi_ext.h>
39 #elif defined(HAVE_GSSAPI_GSSAPI_EXT_H)
40 #include <gssapi/gssapi_ext.h>
41 #endif
42
43 /* draft-ietf-secsh-gsskeyex-06 */
44 #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE               60
45 #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN                  61
46 #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE      63
47 #define SSH2_MSG_USERAUTH_GSSAPI_ERROR                  64
48 #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK                 65
49 #define SSH2_MSG_USERAUTH_GSSAPI_MIC                    66
50
51 #define SSH_GSS_OIDTYPE 0x06
52
53 #define SSH2_MSG_KEXGSS_INIT                            30
54 #define SSH2_MSG_KEXGSS_CONTINUE                        31
55 #define SSH2_MSG_KEXGSS_COMPLETE                        32
56 #define SSH2_MSG_KEXGSS_HOSTKEY                         33
57 #define SSH2_MSG_KEXGSS_ERROR                           34
58 #define SSH2_MSG_KEXGSS_GROUPREQ                        40
59 #define SSH2_MSG_KEXGSS_GROUP                           41
60 #define KEX_GSS_GRP1_SHA1_ID                            "gss-group1-sha1-"
61 #define KEX_GSS_GRP14_SHA1_ID                           "gss-group14-sha1-"
62 #define KEX_GSS_GEX_SHA1_ID                             "gss-gex-sha1-"
63
64 typedef struct {
65         char *filename;
66         char *envvar;
67         char *envval;
68         struct passwd *owner;
69         void *data;
70 } ssh_gssapi_ccache;
71
72 typedef struct {
73         gss_buffer_desc displayname;
74         gss_buffer_desc exportedname;
75         gss_cred_id_t creds;
76         gss_name_t name;
77         ssh_gssapi_ccache store;
78         int used;
79         int updated;
80 } ssh_gssapi_client;
81
82 typedef struct {
83         OM_uint32       major; /* both */
84         OM_uint32       minor; /* both */
85         gss_ctx_id_t    context; /* both */
86         gss_name_t      name; /* both */
87         gss_OID         oid; /* client */
88         gss_cred_id_t   creds; /* server */
89         gss_name_t      client; /* server */
90         gss_cred_id_t   client_creds; /* both */
91 } Gssctxt;
92
93 extern Gssctxt *gss_kex_context;
94
95 int  ssh_gssapi_check_oid(Gssctxt *, void *, size_t);
96 void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t);
97 void ssh_gssapi_set_oid(Gssctxt *, gss_OID);
98 void ssh_gssapi_supported_oids(gss_OID_set *);
99
100 OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *);
101 OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int,
102     gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
103 OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *,
104     gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
105 OM_uint32 ssh_gssapi_getclient(Gssctxt *, ssh_gssapi_client *);
106 void ssh_gssapi_error(Gssctxt *);
107 char *ssh_gssapi_last_error(Gssctxt *, OM_uint32 *, OM_uint32 *);
108 void ssh_gssapi_build_ctx(Gssctxt **);
109 void ssh_gssapi_delete_ctx(Gssctxt **);
110 OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
111 void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *);
112 int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *, const char *);
113 OM_uint32 ssh_gssapi_client_identity(Gssctxt *, const char *);
114 int ssh_gssapi_credentials_updated(Gssctxt *);
115
116 /* In the server */
117 typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *, 
118     const char *);
119 char *ssh_gssapi_client_mechanisms(const char *, const char *);
120 char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *,
121     const char *);
122 gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int);
123 int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *, 
124     const char *);
125 OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
126 int ssh_gssapi_userok(char *name, struct passwd *);
127 OM_uint32 ssh_gssapi_localname(char **name);
128 OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
129 void ssh_gssapi_do_child(char ***, u_int *);
130 void ssh_gssapi_cleanup_creds(void);
131 void ssh_gssapi_storecreds(void);
132
133 char *ssh_gssapi_server_mechanisms(void);
134 int ssh_gssapi_oid_table_ok();
135
136 #endif /* GSSAPI */
137
138 #endif /* _SSH_GSS_H */