blob: 2b6fe21306202c28c674e6515bf9d833ba95a61b [file] [log] [blame]
Damien Miller0425d402003-11-17 22:18:21 +11001/* $OpenBSD: ssh-gss.h,v 1.4 2003/11/17 11:06:07 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
Damien Miller0425d402003-11-17 22:18:21 +110053#define SSH2_MSG_USERAUTH_GSSAPI_MIC 66
Darren Tucker0efd1552003-08-26 11:49:55 +100054
55#define SSH_GSS_OIDTYPE 0x06
56
57typedef struct {
58 char *filename;
59 char *envvar;
60 char *envval;
61 void *data;
62} ssh_gssapi_ccache;
63
64typedef struct {
65 gss_buffer_desc displayname;
66 gss_buffer_desc exportedname;
67 gss_cred_id_t creds;
68 struct ssh_gssapi_mech_struct *mech;
69 ssh_gssapi_ccache store;
70} ssh_gssapi_client;
71
72typedef struct ssh_gssapi_mech_struct {
73 char *enc_name;
74 char *name;
75 gss_OID_desc oid;
76 int (*dochild) (ssh_gssapi_client *);
77 int (*userok) (ssh_gssapi_client *, char *);
78 int (*localname) (ssh_gssapi_client *, char **);
79 void (*storecreds) (ssh_gssapi_client *);
80} ssh_gssapi_mech;
81
82typedef struct {
83 OM_uint32 major; /* both */
84 OM_uint32 minor; /* both */
85 gss_ctx_id_t context; /* both */
86 gss_name_t name; /* both */
87 gss_OID oid; /* client */
88 gss_cred_id_t creds; /* server */
89 gss_name_t client; /* server */
90 gss_cred_id_t client_creds; /* server */
91} Gssctxt;
92
93extern ssh_gssapi_mech *supported_mechs[];
94
95int ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len);
96void ssh_gssapi_set_oid_data(Gssctxt *ctx, void *data, size_t len);
97void ssh_gssapi_set_oid(Gssctxt *ctx, gss_OID oid);
98void ssh_gssapi_supported_oids(gss_OID_set *oidset);
99ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *ctxt);
100
101OM_uint32 ssh_gssapi_import_name(Gssctxt *ctx, const char *host);
102OM_uint32 ssh_gssapi_acquire_cred(Gssctxt *ctx);
103OM_uint32 ssh_gssapi_init_ctx(Gssctxt *ctx, int deleg_creds,
104 gss_buffer_desc *recv_tok, gss_buffer_desc *send_tok, OM_uint32 *flags);
105OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *ctx,
106 gss_buffer_desc *recv_tok, gss_buffer_desc *send_tok, OM_uint32 *flags);
107OM_uint32 ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *);
108void ssh_gssapi_error(Gssctxt *ctx);
109char *ssh_gssapi_last_error(Gssctxt *ctxt, OM_uint32 *maj, OM_uint32 *min);
110void ssh_gssapi_build_ctx(Gssctxt **ctx);
111void ssh_gssapi_delete_ctx(Gssctxt **ctx);
Damien Miller0425d402003-11-17 22:18:21 +1100112OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
Darren Tucker0efd1552003-08-26 11:49:55 +1000113OM_uint32 ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid);
Damien Miller0425d402003-11-17 22:18:21 +1100114void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *);
Darren Tucker0efd1552003-08-26 11:49:55 +1000115
116/* In the server */
117int ssh_gssapi_userok(char *name);
Damien Miller0425d402003-11-17 22:18:21 +1100118OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
Darren Tucker0efd1552003-08-26 11:49:55 +1000119void ssh_gssapi_do_child(char ***envp, u_int *envsizep);
Darren Tucker7596d682003-10-02 17:32:30 +1000120void ssh_gssapi_cleanup_creds(void);
Darren Tucker0efd1552003-08-26 11:49:55 +1000121void ssh_gssapi_storecreds(void);
122
123#endif /* GSSAPI */
124
125#endif /* _SSH_GSS_H */