]>
Commit | Line | Data |
---|---|---|
5598e598 | 1 | /* |
23987cb8 | 2 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. |
5598e598 | 3 | * |
4 | * Redistribution and use in source and binary forms, with or without | |
5 | * modification, are permitted provided that the following conditions | |
6 | * are met: | |
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. | |
12 | * | |
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. | |
23 | */ | |
24 | ||
b59afbfe | 25 | #ifndef _SSH_GSS_H |
26 | #define _SSH_GSS_H | |
27 | ||
5598e598 | 28 | #ifdef GSSAPI |
29 | ||
30 | #include "kex.h" | |
31 | #include "buffer.h" | |
32 | ||
33 | #include <gssapi.h> | |
34 | ||
8f0688f5 | 35 | #ifndef MECHGLUE |
5598e598 | 36 | #ifdef KRB5 |
37 | #ifndef HEIMDAL | |
38 | #include <gssapi_generic.h> | |
39 | ||
40 | /* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */ | |
7cac2b65 | 41 | |
5598e598 | 42 | #ifndef GSS_C_NT_HOSTBASED_SERVICE |
43 | #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name | |
44 | #endif /* GSS_C_NT_... */ | |
45 | #endif /* !HEIMDAL */ | |
46 | #endif /* KRB5 */ | |
8f0688f5 | 47 | #endif /* !MECHGLUE */ |
5598e598 | 48 | |
7cac2b65 | 49 | /* draft-ietf-secsh-gsskeyex-06 */ |
b59afbfe | 50 | #define SSH2_MSG_KEXGSS_INIT 30 |
51 | #define SSH2_MSG_KEXGSS_CONTINUE 31 | |
52 | #define SSH2_MSG_KEXGSS_COMPLETE 32 | |
53 | #define SSH2_MSG_KEXGSS_HOSTKEY 33 | |
54 | #define SSH2_MSG_KEXGSS_ERROR 34 | |
7cac2b65 | 55 | #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60 |
56 | #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61 | |
57 | #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 | |
58 | #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 | |
e23e524c | 59 | #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 |
b59afbfe | 60 | |
7cac2b65 | 61 | #define SSH_GSS_OIDTYPE 0x06 |
62 | ||
b59afbfe | 63 | #define KEX_GSS_SHA1 "gss-group1-sha1-" |
5598e598 | 64 | |
23987cb8 | 65 | typedef struct { |
7cac2b65 | 66 | char *filename; |
67 | char *envvar; | |
68 | char *envval; | |
69 | void *data; | |
23987cb8 | 70 | } ssh_gssapi_ccache; |
71 | ||
72 | typedef struct { | |
7cac2b65 | 73 | gss_buffer_desc displayname; |
74 | gss_buffer_desc exportedname; | |
75 | gss_cred_id_t creds; | |
23987cb8 | 76 | struct ssh_gssapi_mech_struct *mech; |
77 | ssh_gssapi_ccache store; | |
78 | } ssh_gssapi_client; | |
5598e598 | 79 | |
23987cb8 | 80 | typedef struct ssh_gssapi_mech_struct { |
7cac2b65 | 81 | char *enc_name; |
82 | char *name; | |
83 | gss_OID_desc oid; | |
23987cb8 | 84 | int (*dochild) (ssh_gssapi_client *); |
85 | int (*userok) (ssh_gssapi_client *, char *); | |
86 | int (*localname) (ssh_gssapi_client *, char **); | |
87 | void (*storecreds) (ssh_gssapi_client *); | |
5598e598 | 88 | } ssh_gssapi_mech; |
89 | ||
90 | typedef struct { | |
23987cb8 | 91 | OM_uint32 major; /* both */ |
92 | OM_uint32 minor; /* both */ | |
5598e598 | 93 | gss_ctx_id_t context; /* both */ |
94 | gss_name_t name; /* both */ | |
6f9f4dab | 95 | gss_OID oid; /* both */ |
5598e598 | 96 | gss_cred_id_t creds; /* server */ |
97 | gss_name_t client; /* server */ | |
98 | gss_cred_id_t client_creds; /* server */ | |
99 | } Gssctxt; | |
100 | ||
23987cb8 | 101 | extern ssh_gssapi_mech *supported_mechs[]; |
5598e598 | 102 | |
08c2f275 | 103 | char *ssh_gssapi_mechanisms(char *host); |
23987cb8 | 104 | char *ssh_gssapi_client_mechanisms(char *host); |
105 | gss_OID ssh_gssapi_client_id_kex(Gssctxt *ctx, char *name); | |
106 | int ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len); | |
5598e598 | 107 | void ssh_gssapi_set_oid_data(Gssctxt *ctx, void *data, size_t len); |
108 | void ssh_gssapi_set_oid(Gssctxt *ctx, gss_OID oid); | |
109 | void ssh_gssapi_supported_oids(gss_OID_set *oidset); | |
23987cb8 | 110 | ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *ctxt); |
5598e598 | 111 | |
af6d5f4c | 112 | OM_uint32 ssh_gssapi_import_name(Gssctxt *ctx, const char *host); |
5598e598 | 113 | OM_uint32 ssh_gssapi_acquire_cred(Gssctxt *ctx); |
114 | OM_uint32 ssh_gssapi_init_ctx(Gssctxt *ctx, int deleg_creds, | |
7cac2b65 | 115 | gss_buffer_desc *recv_tok, gss_buffer_desc *send_tok, OM_uint32 *flags); |
5598e598 | 116 | OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *ctx, |
7cac2b65 | 117 | gss_buffer_desc *recv_tok, gss_buffer_desc *send_tok, OM_uint32 *flags); |
118 | OM_uint32 ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *); | |
23987cb8 | 119 | void ssh_gssapi_error(Gssctxt *ctx); |
120 | char *ssh_gssapi_last_error(Gssctxt *ctxt, OM_uint32 *maj, OM_uint32 *min); | |
b59afbfe | 121 | void ssh_gssapi_build_ctx(Gssctxt **ctx); |
122 | void ssh_gssapi_delete_ctx(Gssctxt **ctx); | |
7cac2b65 | 123 | OM_uint32 ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid); |
5598e598 | 124 | |
23987cb8 | 125 | int ssh_gssapi_check_mechanism(gss_OID oid, char *host); |
126 | ||
5598e598 | 127 | /* In the server */ |
e23e524c | 128 | gss_OID ssh_gssapi_server_id_kex(char *name); |
b59afbfe | 129 | int ssh_gssapi_userok(char *name); |
e23e524c | 130 | int ssh_gssapi_localname(char **name); |
5598e598 | 131 | void ssh_gssapi_server(Kex *kex, Buffer *client_kexinit, |
132 | Buffer *server_kexinit); | |
b59afbfe | 133 | |
134 | OM_uint32 ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_desc *buffer, | |
135 | gss_buffer_desc *hash); | |
136 | ||
7cac2b65 | 137 | void ssh_gssapi_do_child(char ***envp, u_int *envsizep); |
5598e598 | 138 | void ssh_gssapi_cleanup_creds(void *ignored); |
7cac2b65 | 139 | void ssh_gssapi_storecreds(void); |
23987cb8 | 140 | char *ssh_gssapi_server_mechanisms(); |
b59afbfe | 141 | |
f9ee7be6 | 142 | #ifdef MECHGLUE |
143 | gss_cred_id_t __gss_get_mechanism_cred | |
144 | (gss_cred_id_t, /* union_cred */ | |
145 | gss_OID /* mech_type */ | |
146 | ); | |
b59afbfe | 147 | #endif |
076a92b0 | 148 | |
5598e598 | 149 | #endif /* GSSAPI */ |
b59afbfe | 150 | |
151 | #endif /* _SSH_GSS_H */ |