Damien Miller | 0425d40 | 2003-11-17 22:18:21 +1100 | [diff] [blame] | 1 | /* $OpenBSD: ssh-gss.h,v 1.4 2003/11/17 11:06:07 markus 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 | |
| 31 | #include "buffer.h" |
| 32 | |
| 33 | #include <gssapi.h> |
| 34 | |
Darren Tucker | 49aaf4a | 2003-08-26 11:58:16 +1000 | [diff] [blame] | 35 | #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 Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 47 | /* 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 Miller | 0425d40 | 2003-11-17 22:18:21 +1100 | [diff] [blame] | 53 | #define SSH2_MSG_USERAUTH_GSSAPI_MIC 66 |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 54 | |
| 55 | #define SSH_GSS_OIDTYPE 0x06 |
| 56 | |
| 57 | typedef struct { |
| 58 | char *filename; |
| 59 | char *envvar; |
| 60 | char *envval; |
| 61 | void *data; |
| 62 | } ssh_gssapi_ccache; |
| 63 | |
| 64 | typedef 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 | |
| 72 | typedef 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 | |
| 82 | typedef 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 | |
| 93 | extern ssh_gssapi_mech *supported_mechs[]; |
| 94 | |
| 95 | int ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len); |
| 96 | void ssh_gssapi_set_oid_data(Gssctxt *ctx, void *data, size_t len); |
| 97 | void ssh_gssapi_set_oid(Gssctxt *ctx, gss_OID oid); |
| 98 | void ssh_gssapi_supported_oids(gss_OID_set *oidset); |
| 99 | ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *ctxt); |
| 100 | |
| 101 | OM_uint32 ssh_gssapi_import_name(Gssctxt *ctx, const char *host); |
| 102 | OM_uint32 ssh_gssapi_acquire_cred(Gssctxt *ctx); |
| 103 | OM_uint32 ssh_gssapi_init_ctx(Gssctxt *ctx, int deleg_creds, |
| 104 | gss_buffer_desc *recv_tok, gss_buffer_desc *send_tok, OM_uint32 *flags); |
| 105 | OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *ctx, |
| 106 | gss_buffer_desc *recv_tok, gss_buffer_desc *send_tok, OM_uint32 *flags); |
| 107 | OM_uint32 ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *); |
| 108 | void ssh_gssapi_error(Gssctxt *ctx); |
| 109 | char *ssh_gssapi_last_error(Gssctxt *ctxt, OM_uint32 *maj, OM_uint32 *min); |
| 110 | void ssh_gssapi_build_ctx(Gssctxt **ctx); |
| 111 | void ssh_gssapi_delete_ctx(Gssctxt **ctx); |
Damien Miller | 0425d40 | 2003-11-17 22:18:21 +1100 | [diff] [blame] | 112 | OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 113 | OM_uint32 ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid); |
Damien Miller | 0425d40 | 2003-11-17 22:18:21 +1100 | [diff] [blame] | 114 | void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 115 | |
| 116 | /* In the server */ |
| 117 | int ssh_gssapi_userok(char *name); |
Damien Miller | 0425d40 | 2003-11-17 22:18:21 +1100 | [diff] [blame] | 118 | OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 119 | void ssh_gssapi_do_child(char ***envp, u_int *envsizep); |
Darren Tucker | 7596d68 | 2003-10-02 17:32:30 +1000 | [diff] [blame] | 120 | void ssh_gssapi_cleanup_creds(void); |
Darren Tucker | 0efd155 | 2003-08-26 11:49:55 +1000 | [diff] [blame] | 121 | void ssh_gssapi_storecreds(void); |
| 122 | |
| 123 | #endif /* GSSAPI */ |
| 124 | |
| 125 | #endif /* _SSH_GSS_H */ |