Darren Tucker | 8f6d0ed | 2007-06-12 23:40:39 +1000 | [diff] [blame] | 1 | /* $OpenBSD: ssh-gss.h,v 1.10 2007/06/12 08:20:00 djm Exp $ */ |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 2 | /* |
| 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 Tucker | 0d27ed1 | 2004-02-24 10:37:33 +1100 | [diff] [blame] | 31 | #ifdef HAVE_GSSAPI_H |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 32 | #include <gssapi.h> |
Darren Tucker | 0d27ed1 | 2004-02-24 10:37:33 +1100 | [diff] [blame] | 33 | #elif defined(HAVE_GSSAPI_GSSAPI_H) |
| 34 | #include <gssapi/gssapi.h> |
| 35 | #endif |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 36 | |
Darren Tucker | 49aaf4a | 2003-08-26 11:58:16 +1000 | [diff] [blame] | 37 | #ifdef KRB5 |
Darren Tucker | 0d27ed1 | 2004-02-24 10:37:33 +1100 | [diff] [blame] | 38 | # 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 Tucker | 49aaf4a | 2003-08-26 11:58:16 +1000 | [diff] [blame] | 44 | |
| 45 | /* MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */ |
| 46 | |
| 47 | #ifndef GSS_C_NT_HOSTBASED_SERVICE |
| 48 | #define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name |
| 49 | #endif /* GSS_C_NT_... */ |
| 50 | #endif /* !HEIMDAL */ |
| 51 | #endif /* KRB5 */ |
| 52 | |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 53 | /* draft-ietf-secsh-gsskeyex-06 */ |
| 54 | #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60 |
| 55 | #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61 |
| 56 | #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 |
| 57 | #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 |
| 58 | #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 |
Damien Miller | 0425d40 | 2003-11-17 22:18:21 +1100 | [diff] [blame] | 59 | #define SSH2_MSG_USERAUTH_GSSAPI_MIC 66 |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 60 | |
| 61 | #define SSH_GSS_OIDTYPE 0x06 |
| 62 | |
| 63 | typedef struct { |
| 64 | char *filename; |
| 65 | char *envvar; |
| 66 | char *envval; |
| 67 | void *data; |
| 68 | } ssh_gssapi_ccache; |
| 69 | |
| 70 | typedef struct { |
| 71 | gss_buffer_desc displayname; |
| 72 | gss_buffer_desc exportedname; |
| 73 | gss_cred_id_t creds; |
| 74 | struct ssh_gssapi_mech_struct *mech; |
| 75 | ssh_gssapi_ccache store; |
| 76 | } ssh_gssapi_client; |
| 77 | |
| 78 | typedef struct ssh_gssapi_mech_struct { |
| 79 | char *enc_name; |
| 80 | char *name; |
| 81 | gss_OID_desc oid; |
| 82 | int (*dochild) (ssh_gssapi_client *); |
| 83 | int (*userok) (ssh_gssapi_client *, char *); |
| 84 | int (*localname) (ssh_gssapi_client *, char **); |
| 85 | void (*storecreds) (ssh_gssapi_client *); |
| 86 | } ssh_gssapi_mech; |
| 87 | |
| 88 | typedef struct { |
| 89 | OM_uint32 major; /* both */ |
| 90 | OM_uint32 minor; /* both */ |
| 91 | gss_ctx_id_t context; /* both */ |
| 92 | gss_name_t name; /* both */ |
| 93 | gss_OID oid; /* client */ |
| 94 | gss_cred_id_t creds; /* server */ |
| 95 | gss_name_t client; /* server */ |
| 96 | gss_cred_id_t client_creds; /* server */ |
| 97 | } Gssctxt; |
| 98 | |
| 99 | extern ssh_gssapi_mech *supported_mechs[]; |
| 100 | |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 101 | int ssh_gssapi_check_oid(Gssctxt *, void *, size_t); |
| 102 | void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t); |
| 103 | void ssh_gssapi_set_oid(Gssctxt *, gss_OID); |
| 104 | void ssh_gssapi_supported_oids(gss_OID_set *); |
| 105 | ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *); |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 106 | |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 107 | OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *); |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 108 | OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int, |
| 109 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); |
| 110 | OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *, |
| 111 | gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); |
| 112 | OM_uint32 ssh_gssapi_getclient(Gssctxt *, ssh_gssapi_client *); |
| 113 | void ssh_gssapi_error(Gssctxt *); |
| 114 | char *ssh_gssapi_last_error(Gssctxt *, OM_uint32 *, OM_uint32 *); |
| 115 | void ssh_gssapi_build_ctx(Gssctxt **); |
| 116 | void ssh_gssapi_delete_ctx(Gssctxt **); |
Damien Miller | 0425d40 | 2003-11-17 22:18:21 +1100 | [diff] [blame] | 117 | OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); |
Damien Miller | 0425d40 | 2003-11-17 22:18:21 +1100 | [diff] [blame] | 118 | void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); |
Damien Miller | 3d2d6e9 | 2006-08-19 00:46:43 +1000 | [diff] [blame] | 119 | int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *); |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 120 | |
| 121 | /* In the server */ |
Darren Tucker | 8f6d0ed | 2007-06-12 23:40:39 +1000 | [diff] [blame] | 122 | OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 123 | int ssh_gssapi_userok(char *name); |
Damien Miller | 0425d40 | 2003-11-17 22:18:21 +1100 | [diff] [blame] | 124 | OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); |
Darren Tucker | 3f9fdc7 | 2004-06-22 12:56:01 +1000 | [diff] [blame] | 125 | void ssh_gssapi_do_child(char ***, u_int *); |
Darren Tucker | 7596d68 | 2003-10-02 17:32:30 +1000 | [diff] [blame] | 126 | void ssh_gssapi_cleanup_creds(void); |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 127 | void ssh_gssapi_storecreds(void); |
| 128 | |
| 129 | #endif /* GSSAPI */ |
| 130 | |
| 131 | #endif /* _SSH_GSS_H */ |