]>
Commit | Line | Data |
---|---|---|
7364bd04 | 1 | /* |
2 | * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. | |
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 | ||
25 | #ifndef _SSH_GSS_H | |
26 | #define _SSH_GSS_H | |
27 | ||
28 | #ifdef GSSAPI | |
29 | ||
30 | #include "buffer.h" | |
31 | ||
32 | #include <gssapi.h> | |
33 | ||
749560dd | 34 | #ifdef KRB5 |
35 | #ifndef HEIMDAL | |
36 | #include <gssapi_generic.h> | |
37 | ||
38 | /* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */ | |
39 | ||
40 | #ifndef GSS_C_NT_HOSTBASED_SERVICE | |
41 | #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name | |
42 | #endif /* GSS_C_NT_... */ | |
43 | #endif /* !HEIMDAL */ | |
44 | #endif /* KRB5 */ | |
45 | ||
7364bd04 | 46 | /* draft-ietf-secsh-gsskeyex-06 */ |
47 | #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60 | |
48 | #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61 | |
49 | #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 | |
50 | #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 | |
51 | #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 | |
52 | ||
53 | #define SSH_GSS_OIDTYPE 0x06 | |
54 | ||
55 | typedef struct { | |
56 | char *filename; | |
57 | char *envvar; | |
58 | char *envval; | |
59 | void *data; | |
60 | } ssh_gssapi_ccache; | |
61 | ||
62 | typedef struct { | |
63 | gss_buffer_desc displayname; | |
64 | gss_buffer_desc exportedname; | |
65 | gss_cred_id_t creds; | |
66 | struct ssh_gssapi_mech_struct *mech; | |
67 | ssh_gssapi_ccache store; | |
68 | } ssh_gssapi_client; | |
69 | ||
70 | typedef struct ssh_gssapi_mech_struct { | |
71 | char *enc_name; | |
72 | char *name; | |
73 | gss_OID_desc oid; | |
74 | int (*dochild) (ssh_gssapi_client *); | |
75 | int (*userok) (ssh_gssapi_client *, char *); | |
76 | int (*localname) (ssh_gssapi_client *, char **); | |
77 | void (*storecreds) (ssh_gssapi_client *); | |
78 | } ssh_gssapi_mech; | |
79 | ||
80 | typedef struct { | |
81 | OM_uint32 major; /* both */ | |
82 | OM_uint32 minor; /* both */ | |
83 | gss_ctx_id_t context; /* both */ | |
84 | gss_name_t name; /* both */ | |
85 | gss_OID oid; /* client */ | |
86 | gss_cred_id_t creds; /* server */ | |
87 | gss_name_t client; /* server */ | |
88 | gss_cred_id_t client_creds; /* server */ | |
89 | } Gssctxt; | |
90 | ||
91 | extern ssh_gssapi_mech *supported_mechs[]; | |
92 | ||
93 | int ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len); | |
94 | void ssh_gssapi_set_oid_data(Gssctxt *ctx, void *data, size_t len); | |
95 | void ssh_gssapi_set_oid(Gssctxt *ctx, gss_OID oid); | |
96 | void ssh_gssapi_supported_oids(gss_OID_set *oidset); | |
97 | ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *ctxt); | |
98 | ||
99 | OM_uint32 ssh_gssapi_import_name(Gssctxt *ctx, const char *host); | |
100 | OM_uint32 ssh_gssapi_acquire_cred(Gssctxt *ctx); | |
101 | OM_uint32 ssh_gssapi_init_ctx(Gssctxt *ctx, int deleg_creds, | |
102 | gss_buffer_desc *recv_tok, gss_buffer_desc *send_tok, OM_uint32 *flags); | |
103 | OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *ctx, | |
104 | gss_buffer_desc *recv_tok, gss_buffer_desc *send_tok, OM_uint32 *flags); | |
105 | OM_uint32 ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *); | |
106 | void ssh_gssapi_error(Gssctxt *ctx); | |
107 | char *ssh_gssapi_last_error(Gssctxt *ctxt, OM_uint32 *maj, OM_uint32 *min); | |
108 | void ssh_gssapi_build_ctx(Gssctxt **ctx); | |
109 | void ssh_gssapi_delete_ctx(Gssctxt **ctx); | |
110 | OM_uint32 ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid); | |
111 | ||
112 | /* In the server */ | |
113 | int ssh_gssapi_userok(char *name); | |
114 | ||
115 | void ssh_gssapi_do_child(char ***envp, u_int *envsizep); | |
116 | void ssh_gssapi_cleanup_creds(void *ignored); | |
117 | void ssh_gssapi_storecreds(void); | |
118 | ||
119 | #endif /* GSSAPI */ | |
120 | ||
121 | #endif /* _SSH_GSS_H */ |