blob: c76648ee0b5433f5d194a2469ddd709cce75a3b7 [file] [log] [blame]
Darren Tuckere3ca82e2003-10-03 18:02:30 +10001/* $OpenBSD: ssh-gss.h,v 1.3 2003/10/02 08:26:53 markus Exp $ */
Darren Tucker0efd1552003-08-26 11:49:55 +10002/*
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 "buffer.h"
32
33#include <gssapi.h>
34
Darren Tucker49aaf4a2003-08-26 11:58:16 +100035#ifdef KRB5
36#ifndef HEIMDAL
37#include <gssapi_generic.h>
38
39/* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */
40
41#ifndef GSS_C_NT_HOSTBASED_SERVICE
42#define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
43#endif /* GSS_C_NT_... */
44#endif /* !HEIMDAL */
45#endif /* KRB5 */
46
Darren Tucker0efd1552003-08-26 11:49:55 +100047/* draft-ietf-secsh-gsskeyex-06 */
48#define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60
49#define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61
50#define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63
51#define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64
52#define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65
53
54#define SSH_GSS_OIDTYPE 0x06
55
56typedef struct {
57 char *filename;
58 char *envvar;
59 char *envval;
60 void *data;
61} ssh_gssapi_ccache;
62
63typedef struct {
64 gss_buffer_desc displayname;
65 gss_buffer_desc exportedname;
66 gss_cred_id_t creds;
67 struct ssh_gssapi_mech_struct *mech;
68 ssh_gssapi_ccache store;
69} ssh_gssapi_client;
70
71typedef struct ssh_gssapi_mech_struct {
72 char *enc_name;
73 char *name;
74 gss_OID_desc oid;
75 int (*dochild) (ssh_gssapi_client *);
76 int (*userok) (ssh_gssapi_client *, char *);
77 int (*localname) (ssh_gssapi_client *, char **);
78 void (*storecreds) (ssh_gssapi_client *);
79} ssh_gssapi_mech;
80
81typedef struct {
82 OM_uint32 major; /* both */
83 OM_uint32 minor; /* both */
84 gss_ctx_id_t context; /* both */
85 gss_name_t name; /* both */
86 gss_OID oid; /* client */
87 gss_cred_id_t creds; /* server */
88 gss_name_t client; /* server */
89 gss_cred_id_t client_creds; /* server */
90} Gssctxt;
91
92extern ssh_gssapi_mech *supported_mechs[];
93
94int ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len);
95void ssh_gssapi_set_oid_data(Gssctxt *ctx, void *data, size_t len);
96void ssh_gssapi_set_oid(Gssctxt *ctx, gss_OID oid);
97void ssh_gssapi_supported_oids(gss_OID_set *oidset);
98ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *ctxt);
99
100OM_uint32 ssh_gssapi_import_name(Gssctxt *ctx, const char *host);
101OM_uint32 ssh_gssapi_acquire_cred(Gssctxt *ctx);
102OM_uint32 ssh_gssapi_init_ctx(Gssctxt *ctx, int deleg_creds,
103 gss_buffer_desc *recv_tok, gss_buffer_desc *send_tok, OM_uint32 *flags);
104OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *ctx,
105 gss_buffer_desc *recv_tok, gss_buffer_desc *send_tok, OM_uint32 *flags);
106OM_uint32 ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *);
107void ssh_gssapi_error(Gssctxt *ctx);
108char *ssh_gssapi_last_error(Gssctxt *ctxt, OM_uint32 *maj, OM_uint32 *min);
109void ssh_gssapi_build_ctx(Gssctxt **ctx);
110void ssh_gssapi_delete_ctx(Gssctxt **ctx);
111OM_uint32 ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid);
112
113/* In the server */
114int ssh_gssapi_userok(char *name);
115
116void ssh_gssapi_do_child(char ***envp, u_int *envsizep);
Darren Tucker7596d682003-10-02 17:32:30 +1000117void ssh_gssapi_cleanup_creds(void);
Darren Tucker0efd1552003-08-26 11:49:55 +1000118void ssh_gssapi_storecreds(void);
119
120#endif /* GSSAPI */
121
122#endif /* _SSH_GSS_H */