]>
Commit | Line | Data |
---|---|---|
fa0f0f45 | 1 | /* $OpenBSD: ssh-gss.h,v 1.10 2007/06/12 08:20:00 djm Exp $ */ |
5598e598 | 2 | /* |
23987cb8 | 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 | ||
b59afbfe | 26 | #ifndef _SSH_GSS_H |
27 | #define _SSH_GSS_H | |
28 | ||
5598e598 | 29 | #ifdef GSSAPI |
30 | ||
540d72c3 | 31 | #ifdef HAVE_GSSAPI_H |
5598e598 | 32 | #include <gssapi.h> |
540d72c3 | 33 | #elif defined(HAVE_GSSAPI_GSSAPI_H) |
34 | #include <gssapi/gssapi.h> | |
35 | #endif | |
5598e598 | 36 | |
8f0688f5 | 37 | #ifndef MECHGLUE |
5598e598 | 38 | #ifdef KRB5 |
540d72c3 | 39 | # ifndef HEIMDAL |
40 | # ifdef HAVE_GSSAPI_GENERIC_H | |
41 | # include <gssapi_generic.h> | |
42 | # elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H) | |
43 | # include <gssapi/gssapi_generic.h> | |
44 | # endif | |
5598e598 | 45 | |
46 | /* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */ | |
7cac2b65 | 47 | |
5598e598 | 48 | #ifndef GSS_C_NT_HOSTBASED_SERVICE |
49 | #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name | |
50 | #endif /* GSS_C_NT_... */ | |
51 | #endif /* !HEIMDAL */ | |
52 | #endif /* KRB5 */ | |
8f0688f5 | 53 | #endif /* !MECHGLUE */ |
5598e598 | 54 | |
7cac2b65 | 55 | /* draft-ietf-secsh-gsskeyex-06 */ |
7cac2b65 | 56 | #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60 |
57 | #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61 | |
58 | #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 | |
59 | #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 | |
e23e524c | 60 | #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 |
540d72c3 | 61 | #define SSH2_MSG_USERAUTH_GSSAPI_MIC 66 |
b59afbfe | 62 | |
7cac2b65 | 63 | #define SSH_GSS_OIDTYPE 0x06 |
64 | ||
f713db99 | 65 | #define SSH2_MSG_KEXGSS_INIT 30 |
66 | #define SSH2_MSG_KEXGSS_CONTINUE 31 | |
67 | #define SSH2_MSG_KEXGSS_COMPLETE 32 | |
68 | #define SSH2_MSG_KEXGSS_HOSTKEY 33 | |
69 | #define SSH2_MSG_KEXGSS_ERROR 34 | |
fe4ad273 | 70 | #define SSH2_MSG_KEXGSS_GROUPREQ 40 |
71 | #define SSH2_MSG_KEXGSS_GROUP 41 | |
72 | #define KEX_GSS_GRP1_SHA1_ID "gss-group1-sha1-" | |
f713db99 | 73 | #define KEX_GSS_GRP14_SHA1_ID "gss-group14-sha1-" |
fe4ad273 | 74 | #define KEX_GSS_GEX_SHA1_ID "gss-gex-sha1-" |
5598e598 | 75 | |
23987cb8 | 76 | typedef struct { |
7cac2b65 | 77 | char *filename; |
78 | char *envvar; | |
79 | char *envval; | |
80 | void *data; | |
23987cb8 | 81 | } ssh_gssapi_ccache; |
82 | ||
83 | typedef struct { | |
7cac2b65 | 84 | gss_buffer_desc displayname; |
85 | gss_buffer_desc exportedname; | |
86 | gss_cred_id_t creds; | |
23987cb8 | 87 | struct ssh_gssapi_mech_struct *mech; |
88 | ssh_gssapi_ccache store; | |
682b256d | 89 | gss_ctx_id_t context; |
23987cb8 | 90 | } ssh_gssapi_client; |
5598e598 | 91 | |
23987cb8 | 92 | typedef struct ssh_gssapi_mech_struct { |
7cac2b65 | 93 | char *enc_name; |
94 | char *name; | |
95 | gss_OID_desc oid; | |
23987cb8 | 96 | int (*dochild) (ssh_gssapi_client *); |
97 | int (*userok) (ssh_gssapi_client *, char *); | |
98 | int (*localname) (ssh_gssapi_client *, char **); | |
99 | void (*storecreds) (ssh_gssapi_client *); | |
5598e598 | 100 | } ssh_gssapi_mech; |
101 | ||
102 | typedef struct { | |
23987cb8 | 103 | OM_uint32 major; /* both */ |
104 | OM_uint32 minor; /* both */ | |
5598e598 | 105 | gss_ctx_id_t context; /* both */ |
106 | gss_name_t name; /* both */ | |
6f9f4dab | 107 | gss_OID oid; /* both */ |
5598e598 | 108 | gss_cred_id_t creds; /* server */ |
109 | gss_name_t client; /* server */ | |
110 | gss_cred_id_t client_creds; /* server */ | |
111 | } Gssctxt; | |
112 | ||
23987cb8 | 113 | extern ssh_gssapi_mech *supported_mechs[]; |
fe4ad273 | 114 | extern Gssctxt *gss_kex_context; |
7e82606e | 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 *); | |
7e82606e | 123 | OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int, |
124 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); | |
125 | OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *, | |
126 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); | |
127 | OM_uint32 ssh_gssapi_getclient(Gssctxt *, ssh_gssapi_client *); | |
128 | void ssh_gssapi_error(Gssctxt *); | |
129 | char *ssh_gssapi_last_error(Gssctxt *, OM_uint32 *, OM_uint32 *); | |
130 | void ssh_gssapi_build_ctx(Gssctxt **); | |
131 | void ssh_gssapi_delete_ctx(Gssctxt **); | |
540d72c3 | 132 | OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); |
540d72c3 | 133 | void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); |
30460aeb | 134 | int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *); |
5598e598 | 135 | |
e23e524c | 136 | int ssh_gssapi_localname(char **name); |
7e82606e | 137 | |
7a5ea9c3 | 138 | /* In the server */ |
30460aeb | 139 | typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *); |
fe4ad273 | 140 | char *ssh_gssapi_client_mechanisms(const char *host); |
f713db99 | 141 | char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *); |
142 | gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int); | |
7a5ea9c3 | 143 | int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *); |
fa0f0f45 | 144 | OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); |
7e82606e | 145 | int ssh_gssapi_userok(char *name); |
540d72c3 | 146 | OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); |
7e82606e | 147 | void ssh_gssapi_do_child(char ***, u_int *); |
540d72c3 | 148 | void ssh_gssapi_cleanup_creds(void); |
7cac2b65 | 149 | void ssh_gssapi_storecreds(void); |
fe4ad273 | 150 | char * ssh_gssapi_server_mechanisms(void); |
151 | int ssh_gssapi_oid_table_ok(); | |
b59afbfe | 152 | |
f9ee7be6 | 153 | #ifdef MECHGLUE |
154 | gss_cred_id_t __gss_get_mechanism_cred | |
155 | (gss_cred_id_t, /* union_cred */ | |
156 | gss_OID /* mech_type */ | |
157 | ); | |
b59afbfe | 158 | #endif |
076a92b0 | 159 | |
5598e598 | 160 | #endif /* GSSAPI */ |
b59afbfe | 161 | |
162 | #endif /* _SSH_GSS_H */ |