blob: 36180d07a4c17af3548576c01897a27d83ddfcdf [file] [log] [blame]
djm@openbsd.org0f3958c2018-07-10 09:13:30 +00001/* $OpenBSD: ssh-gss.h,v 1.14 2018/07/10 09:13:30 djm 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
Darren Tucker0d27ed12004-02-24 10:37:33 +110031#ifdef HAVE_GSSAPI_H
Darren Tucker0efd1552003-08-26 11:49:55 +100032#include <gssapi.h>
Darren Tucker0d27ed12004-02-24 10:37:33 +110033#elif defined(HAVE_GSSAPI_GSSAPI_H)
34#include <gssapi/gssapi.h>
35#endif
Darren Tucker0efd1552003-08-26 11:49:55 +100036
Darren Tucker49aaf4a2003-08-26 11:58:16 +100037#ifdef KRB5
Darren Tucker0d27ed12004-02-24 10:37:33 +110038# ifndef HEIMDAL
39# ifdef HAVE_GSSAPI_GENERIC_H
40# include <gssapi_generic.h>
41# elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
42# include <gssapi/gssapi_generic.h>
43# endif
Darren Tucker49aaf4a2003-08-26 11:58:16 +100044
Darren Tucker03978c62013-02-25 11:24:44 +110045/* Old MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */
Darren Tucker49aaf4a2003-08-26 11:58:16 +100046
Darren Tucker03978c62013-02-25 11:24:44 +110047# if !HAVE_DECL_GSS_C_NT_HOSTBASED_SERVICE
48# define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
49# endif /* !HAVE_DECL_GSS_C_NT_... */
50
51# endif /* !HEIMDAL */
Darren Tucker49aaf4a2003-08-26 11:58:16 +100052#endif /* KRB5 */
53
Darren Tucker0efd1552003-08-26 11:49:55 +100054/* draft-ietf-secsh-gsskeyex-06 */
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
59#define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65
Damien Miller0425d402003-11-17 22:18:21 +110060#define SSH2_MSG_USERAUTH_GSSAPI_MIC 66
Darren Tucker0efd1552003-08-26 11:49:55 +100061
62#define SSH_GSS_OIDTYPE 0x06
63
64typedef struct {
65 char *filename;
66 char *envvar;
67 char *envval;
68 void *data;
69} ssh_gssapi_ccache;
70
71typedef struct {
72 gss_buffer_desc displayname;
73 gss_buffer_desc exportedname;
74 gss_cred_id_t creds;
75 struct ssh_gssapi_mech_struct *mech;
76 ssh_gssapi_ccache store;
77} ssh_gssapi_client;
78
79typedef struct ssh_gssapi_mech_struct {
80 char *enc_name;
81 char *name;
82 gss_OID_desc oid;
83 int (*dochild) (ssh_gssapi_client *);
84 int (*userok) (ssh_gssapi_client *, char *);
85 int (*localname) (ssh_gssapi_client *, char **);
86 void (*storecreds) (ssh_gssapi_client *);
87} ssh_gssapi_mech;
88
89typedef struct {
90 OM_uint32 major; /* both */
91 OM_uint32 minor; /* both */
92 gss_ctx_id_t context; /* both */
93 gss_name_t name; /* both */
94 gss_OID oid; /* client */
95 gss_cred_id_t creds; /* server */
96 gss_name_t client; /* server */
97 gss_cred_id_t client_creds; /* server */
98} Gssctxt;
99
100extern ssh_gssapi_mech *supported_mechs[];
101
Darren Tucker3f9fdc72004-06-22 12:56:01 +1000102int ssh_gssapi_check_oid(Gssctxt *, void *, size_t);
103void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t);
104void ssh_gssapi_set_oid(Gssctxt *, gss_OID);
105void ssh_gssapi_supported_oids(gss_OID_set *);
106ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *);
Damien Millere6a74ae2014-02-27 10:17:49 +1100107void ssh_gssapi_prepare_supported_oids(void);
108OM_uint32 ssh_gssapi_test_oid_supported(OM_uint32 *, gss_OID, int *);
Darren Tucker0efd1552003-08-26 11:49:55 +1000109
djm@openbsd.org0f3958c2018-07-10 09:13:30 +0000110struct sshbuf;
111int ssh_gssapi_get_buffer_desc(struct sshbuf *, gss_buffer_desc *);
112
Darren Tucker3f9fdc72004-06-22 12:56:01 +1000113OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *);
Darren Tucker3f9fdc72004-06-22 12:56:01 +1000114OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int,
115 gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
116OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *,
117 gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
118OM_uint32 ssh_gssapi_getclient(Gssctxt *, ssh_gssapi_client *);
119void ssh_gssapi_error(Gssctxt *);
120char *ssh_gssapi_last_error(Gssctxt *, OM_uint32 *, OM_uint32 *);
121void ssh_gssapi_build_ctx(Gssctxt **);
122void ssh_gssapi_delete_ctx(Gssctxt **);
Damien Miller0425d402003-11-17 22:18:21 +1100123OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
djm@openbsd.orga881e5a2018-07-10 06:43:52 +0000124void ssh_gssapi_buildmic(struct sshbuf *, const char *,
125 const char *, const char *);
Damien Miller3d2d6e92006-08-19 00:46:43 +1000126int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *);
Darren Tucker0efd1552003-08-26 11:49:55 +1000127
128/* In the server */
Darren Tucker8f6d0ed2007-06-12 23:40:39 +1000129OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
Darren Tucker0efd1552003-08-26 11:49:55 +1000130int ssh_gssapi_userok(char *name);
Damien Miller0425d402003-11-17 22:18:21 +1100131OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
Darren Tucker3f9fdc72004-06-22 12:56:01 +1000132void ssh_gssapi_do_child(char ***, u_int *);
Darren Tucker7596d682003-10-02 17:32:30 +1000133void ssh_gssapi_cleanup_creds(void);
Darren Tucker0efd1552003-08-26 11:49:55 +1000134void ssh_gssapi_storecreds(void);
djm@openbsd.org8f574952017-06-24 06:34:38 +0000135const char *ssh_gssapi_displayname(void);
Darren Tucker0efd1552003-08-26 11:49:55 +1000136
137#endif /* GSSAPI */
138
139#endif /* _SSH_GSS_H */