1 /* $NetBSD: ssh-gss.h,v 1.6 2016/12/25 00:07:47 christos Exp $ */ 2 /* $OpenBSD: ssh-gss.h,v 1.11 2014/02/26 20:28:44 djm Exp $ */ 3 /* 4 * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR 16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 */ 26 27 #ifndef _SSH_GSS_H 28 #define _SSH_GSS_H 29 30 #ifdef GSSAPI 31 32 #include <gssapi.h> 33 34 /* draft-ietf-secsh-gsskeyex-06 */ 35 #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60 36 #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61 37 #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63 38 #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64 39 #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65 40 #define SSH2_MSG_USERAUTH_GSSAPI_MIC 66 41 42 #define SSH_GSS_OIDTYPE 0x06 43 44 typedef struct { 45 char *filename; 46 char *envvar; 47 char *envval; 48 void *data; 49 } ssh_gssapi_ccache; 50 51 typedef struct { 52 gss_buffer_desc displayname; 53 gss_buffer_desc exportedname; 54 gss_cred_id_t creds; 55 struct ssh_gssapi_mech_struct *mech; 56 ssh_gssapi_ccache store; 57 } ssh_gssapi_client; 58 59 typedef struct ssh_gssapi_mech_struct { 60 const char *enc_name; 61 const char *name; 62 gss_OID_desc oid; 63 int (*dochild) (ssh_gssapi_client *); 64 int (*userok) (ssh_gssapi_client *, char *); 65 int (*localname) (ssh_gssapi_client *, char **); 66 void (*storecreds) (ssh_gssapi_client *); 67 } ssh_gssapi_mech; 68 69 typedef struct { 70 OM_uint32 major; /* both */ 71 OM_uint32 minor; /* both */ 72 gss_ctx_id_t context; /* both */ 73 gss_name_t name; /* both */ 74 gss_OID oid; /* client */ 75 gss_cred_id_t creds; /* server */ 76 gss_name_t client; /* server */ 77 gss_cred_id_t client_creds; /* server */ 78 } Gssctxt; 79 80 extern ssh_gssapi_mech *supported_mechs[]; 81 82 int ssh_gssapi_check_oid(Gssctxt *, void *, size_t); 83 void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t); 84 void ssh_gssapi_set_oid(Gssctxt *, gss_OID); 85 void ssh_gssapi_supported_oids(gss_OID_set *); 86 ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *); 87 void ssh_gssapi_prepare_supported_oids(void); 88 OM_uint32 ssh_gssapi_test_oid_supported(OM_uint32 *, gss_OID, int *); 89 90 OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *); 91 OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int, 92 gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); 93 OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *, 94 gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *); 95 OM_uint32 ssh_gssapi_getclient(Gssctxt *, ssh_gssapi_client *); 96 void ssh_gssapi_error(Gssctxt *); 97 char *ssh_gssapi_last_error(Gssctxt *, OM_uint32 *, OM_uint32 *); 98 void ssh_gssapi_build_ctx(Gssctxt **); 99 void ssh_gssapi_delete_ctx(Gssctxt **); 100 OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t); 101 void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *); 102 int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *); 103 104 /* In the server */ 105 OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID); 106 int ssh_gssapi_userok(char *name); 107 OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t); 108 void ssh_gssapi_do_child(char ***, u_int *); 109 void ssh_gssapi_cleanup_creds(void); 110 void ssh_gssapi_storecreds(void); 111 112 #endif /* GSSAPI */ 113 114 #endif /* _SSH_GSS_H */ 115