]> andersk Git - gssapi-openssh.git/blob - openssh/ssh-gss.h
merge OpenSSH 3.9p1 to trunk
[gssapi-openssh.git] / openssh / ssh-gss.h
1 /*      $OpenBSD: ssh-gss.h,v 1.5 2004/06/21 17:36:31 avsm Exp $        */
2 /*
3  * Copyright (c) 2001-2003 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 #include "kex.h"
32 #include "buffer.h"
33
34 #ifdef HAVE_GSSAPI_H
35 #include <gssapi.h>
36 #elif defined(HAVE_GSSAPI_GSSAPI_H)
37 #include <gssapi/gssapi.h>
38 #endif
39
40 #ifndef MECHGLUE
41 #ifdef KRB5
42 # ifndef HEIMDAL
43 #  ifdef HAVE_GSSAPI_GENERIC_H
44 #   include <gssapi_generic.h>
45 #  elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
46 #   include <gssapi/gssapi_generic.h>
47 #  endif
48
49 /* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */
50
51 #ifndef GSS_C_NT_HOSTBASED_SERVICE
52 #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
53 #endif /* GSS_C_NT_... */
54 #endif /* !HEIMDAL */
55 #endif /* KRB5 */
56 #endif /* !MECHGLUE */
57
58 /* draft-ietf-secsh-gsskeyex-06 */
59 #define SSH2_MSG_KEXGSS_INIT                            30
60 #define SSH2_MSG_KEXGSS_CONTINUE                        31
61 #define SSH2_MSG_KEXGSS_COMPLETE                        32
62 #define SSH2_MSG_KEXGSS_HOSTKEY                         33
63 #define SSH2_MSG_KEXGSS_ERROR                           34
64 #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE               60
65 #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN                  61
66 #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE      63
67 #define SSH2_MSG_USERAUTH_GSSAPI_ERROR                  64
68 #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK                 65
69 #define SSH2_MSG_USERAUTH_GSSAPI_MIC                    66
70
71 #define SSH_GSS_OIDTYPE 0x06
72
73 #define KEX_GSS_SHA1                                    "gss-group1-sha1-"
74
75 typedef struct {
76         char *filename;
77         char *envvar;
78         char *envval;
79         void *data;
80 } ssh_gssapi_ccache;
81
82 typedef struct {
83         gss_buffer_desc displayname;
84         gss_buffer_desc exportedname;
85         gss_cred_id_t creds;
86         struct ssh_gssapi_mech_struct *mech;
87         ssh_gssapi_ccache store;
88 } ssh_gssapi_client;
89
90 typedef struct ssh_gssapi_mech_struct {
91         char *enc_name;
92         char *name;
93         gss_OID_desc oid;
94         int (*dochild) (ssh_gssapi_client *);
95         int (*userok) (ssh_gssapi_client *, char *);
96         int (*localname) (ssh_gssapi_client *, char **);
97         void (*storecreds) (ssh_gssapi_client *);
98 } ssh_gssapi_mech;
99
100 typedef struct {
101         OM_uint32       major; /* both */
102         OM_uint32       minor; /* both */
103         gss_ctx_id_t    context; /* both */
104         gss_name_t      name; /* both */
105         gss_OID         oid; /* both */
106         gss_cred_id_t   creds; /* server */
107         gss_name_t      client; /* server */
108         gss_cred_id_t   client_creds; /* server */
109 } Gssctxt;
110
111 extern ssh_gssapi_mech *supported_mechs[];
112
113 char *ssh_gssapi_client_mechanisms(char *);
114 gss_OID ssh_gssapi_client_id_kex(Gssctxt *, char *);
115
116 int  ssh_gssapi_check_oid(Gssctxt *, void *, size_t);
117 void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t);
118 void ssh_gssapi_set_oid(Gssctxt *, gss_OID);
119 void ssh_gssapi_supported_oids(gss_OID_set *);
120 ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *);
121
122 OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *);
123 OM_uint32 ssh_gssapi_acquire_cred(Gssctxt *);
124 OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int,
125     gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
126 OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *,
127     gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
128 OM_uint32 ssh_gssapi_getclient(Gssctxt *, ssh_gssapi_client *);
129 void ssh_gssapi_error(Gssctxt *);
130 char *ssh_gssapi_last_error(Gssctxt *, OM_uint32 *, OM_uint32 *);
131 void ssh_gssapi_build_ctx(Gssctxt **);
132 void ssh_gssapi_delete_ctx(Gssctxt **);
133 OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
134 OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
135 void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *);
136
137 int ssh_gssapi_check_mechanism(gss_OID oid, char *host);
138
139 /* In the server */
140 char *ssh_gssapi_server_mechanisms();
141 gss_OID ssh_gssapi_server_id_kex(char *name);
142 int ssh_gssapi_localname(char **name);
143
144 int ssh_gssapi_userok(char *name);
145 OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
146 void ssh_gssapi_do_child(char ***, u_int *);
147 void ssh_gssapi_cleanup_creds(void);
148 void ssh_gssapi_storecreds(void);
149
150 #ifdef MECHGLUE
151 gss_cred_id_t __gss_get_mechanism_cred
152    (gss_cred_id_t,      /* union_cred */
153     gss_OID             /* mech_type */
154    );
155 #endif
156
157 #endif /* GSSAPI */
158
159 #endif /* _SSH_GSS_H */
This page took 0.039961 seconds and 5 git commands to generate.