]>
Commit | Line | Data |
---|---|---|
1b56ff3d | 1 | /* $OpenBSD: ssh-gss.h,v 1.5 2004/06/21 17:36:31 avsm Exp $ */ |
5598e598 | 2 | /* |
88928908 | 3 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. |
5598e598 | 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 | ||
ff2d7a98 | 26 | #ifndef _SSH_GSS_H |
27 | #define _SSH_GSS_H | |
28 | ||
5598e598 | 29 | #ifdef GSSAPI |
30 | ||
31 | #include "kex.h" | |
32 | #include "buffer.h" | |
33 | ||
416fd2a8 | 34 | #ifdef HAVE_GSSAPI_H |
5598e598 | 35 | #include <gssapi.h> |
416fd2a8 | 36 | #elif defined(HAVE_GSSAPI_GSSAPI_H) |
37 | #include <gssapi/gssapi.h> | |
38 | #endif | |
5598e598 | 39 | |
c2397a66 | 40 | #ifndef MECHGLUE |
5598e598 | 41 | #ifdef KRB5 |
416fd2a8 | 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 | |
5598e598 | 48 | |
49 | /* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */ | |
70791e56 | 50 | |
5598e598 | 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 */ | |
c2397a66 | 56 | #endif /* !MECHGLUE */ |
5598e598 | 57 | |
70791e56 | 58 | /* draft-ietf-secsh-gsskeyex-06 */ |
70791e56 | 59 | #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60 |
60 | #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61 | |
61 | #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 | |
62 | #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 | |
88928908 | 63 | #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 |
416fd2a8 | 64 | #define SSH2_MSG_USERAUTH_GSSAPI_MIC 66 |
ff2d7a98 | 65 | |
70791e56 | 66 | #define SSH_GSS_OIDTYPE 0x06 |
67 | ||
34fee935 | 68 | #define SSH2_MSG_KEXGSS_INIT 30 |
69 | #define SSH2_MSG_KEXGSS_CONTINUE 31 | |
70 | #define SSH2_MSG_KEXGSS_COMPLETE 32 | |
71 | #define SSH2_MSG_KEXGSS_HOSTKEY 33 | |
72 | #define SSH2_MSG_KEXGSS_ERROR 34 | |
73 | #define SSH2_MSG_KEXGSS_GROUPREQ 40 | |
74 | #define SSH2_MSG_KEXGSS_GROUP 41 | |
75 | #define KEX_GSS_GRP1_SHA1_ID "gss-group1-sha1-" | |
76 | #define KEX_GSS_GEX_SHA1_ID "gss-gex-sha1-" | |
5598e598 | 77 | |
88928908 | 78 | typedef struct { |
70791e56 | 79 | char *filename; |
80 | char *envvar; | |
81 | char *envval; | |
82 | void *data; | |
88928908 | 83 | } ssh_gssapi_ccache; |
5598e598 | 84 | |
88928908 | 85 | typedef struct { |
70791e56 | 86 | gss_buffer_desc displayname; |
87 | gss_buffer_desc exportedname; | |
88 | gss_cred_id_t creds; | |
88928908 | 89 | struct ssh_gssapi_mech_struct *mech; |
90 | ssh_gssapi_ccache store; | |
91 | } ssh_gssapi_client; | |
92 | ||
93 | typedef struct ssh_gssapi_mech_struct { | |
70791e56 | 94 | char *enc_name; |
95 | char *name; | |
96 | gss_OID_desc oid; | |
88928908 | 97 | int (*dochild) (ssh_gssapi_client *); |
98 | int (*userok) (ssh_gssapi_client *, char *); | |
99 | int (*localname) (ssh_gssapi_client *, char **); | |
100 | void (*storecreds) (ssh_gssapi_client *); | |
5598e598 | 101 | } ssh_gssapi_mech; |
102 | ||
103 | typedef struct { | |
88928908 | 104 | OM_uint32 major; /* both */ |
105 | OM_uint32 minor; /* both */ | |
5598e598 | 106 | gss_ctx_id_t context; /* both */ |
107 | gss_name_t name; /* both */ | |
67e2750c | 108 | gss_OID oid; /* both */ |
5598e598 | 109 | gss_cred_id_t creds; /* server */ |
110 | gss_name_t client; /* server */ | |
111 | gss_cred_id_t client_creds; /* server */ | |
112 | } Gssctxt; | |
113 | ||
88928908 | 114 | extern ssh_gssapi_mech *supported_mechs[]; |
34fee935 | 115 | extern Gssctxt *gss_kex_context; |
1b56ff3d | 116 | |
117 | int ssh_gssapi_check_oid(Gssctxt *, void *, size_t); | |
118 | void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t); | |
119 | void ssh_gssapi_set_oid(Gssctxt *, gss_OID); | |
120 | void ssh_gssapi_supported_oids(gss_OID_set *); | |
121 | ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *); | |
122 | ||
123 | OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *); | |
124 | OM_uint32 ssh_gssapi_acquire_cred(Gssctxt *); | |
125 | OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int, | |
126 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); | |
127 | OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *, | |
128 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); | |
129 | OM_uint32 ssh_gssapi_getclient(Gssctxt *, ssh_gssapi_client *); | |
130 | void ssh_gssapi_error(Gssctxt *); | |
131 | char *ssh_gssapi_last_error(Gssctxt *, OM_uint32 *, OM_uint32 *); | |
132 | void ssh_gssapi_build_ctx(Gssctxt **); | |
133 | void ssh_gssapi_delete_ctx(Gssctxt **); | |
416fd2a8 | 134 | OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); |
1b56ff3d | 135 | OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); |
416fd2a8 | 136 | void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); |
5598e598 | 137 | |
88928908 | 138 | int ssh_gssapi_localname(char **name); |
1b56ff3d | 139 | |
34fee935 | 140 | typedef int ssh_gssapi_check_fn(gss_OID, void *); |
141 | char *ssh_gssapi_client_mechanisms(const char *host); | |
142 | char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, void *); | |
143 | int ssh_gssapi_check_mechanism(gss_OID, void *); | |
144 | gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int *); | |
145 | ||
146 | int ssh_gssapi_server_check_mech(gss_OID, void *); | |
1b56ff3d | 147 | int ssh_gssapi_userok(char *name); |
416fd2a8 | 148 | OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); |
1b56ff3d | 149 | void ssh_gssapi_do_child(char ***, u_int *); |
416fd2a8 | 150 | void ssh_gssapi_cleanup_creds(void); |
70791e56 | 151 | void ssh_gssapi_storecreds(void); |
34fee935 | 152 | char * ssh_gssapi_server_mechanisms(void); |
153 | int ssh_gssapi_oid_table_ok(); | |
ff2d7a98 | 154 | |
c2397a66 | 155 | #ifdef MECHGLUE |
156 | gss_cred_id_t __gss_get_mechanism_cred | |
157 | (gss_cred_id_t, /* union_cred */ | |
158 | gss_OID /* mech_type */ | |
159 | ); | |
ff2d7a98 | 160 | #endif |
f2fd21a2 | 161 | |
5598e598 | 162 | #endif /* GSSAPI */ |
ff2d7a98 | 163 | |
164 | #endif /* _SSH_GSS_H */ |