ssh-gss.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* $OpenBSD: ssh-gss.h,v 1.14 2018/07/10 09:13:30 djm Exp $ */
  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. #ifndef _SSH_GSS_H
  26. #define _SSH_GSS_H
  27. #ifdef GSSAPI
  28. #ifdef HAVE_GSSAPI_H
  29. #include <gssapi.h>
  30. #elif defined(HAVE_GSSAPI_GSSAPI_H)
  31. #include <gssapi/gssapi.h>
  32. #endif
  33. #ifdef KRB5
  34. # ifndef HEIMDAL
  35. # ifdef HAVE_GSSAPI_GENERIC_H
  36. # include <gssapi_generic.h>
  37. # elif defined(HAVE_GSSAPI_GSSAPI_GENERIC_H)
  38. # include <gssapi/gssapi_generic.h>
  39. # endif
  40. /* Old MIT Kerberos doesn't seem to define GSS_NT_HOSTBASED_SERVICE */
  41. # if !HAVE_DECL_GSS_C_NT_HOSTBASED_SERVICE
  42. # define GSS_C_NT_HOSTBASED_SERVICE gss_nt_service_name
  43. # endif /* !HAVE_DECL_GSS_C_NT_... */
  44. # endif /* !HEIMDAL */
  45. /* .k5users support */
  46. extern char **k5users_allowed_cmds;
  47. #endif /* KRB5 */
  48. /* draft-ietf-secsh-gsskeyex-06 */
  49. #define SSH2_MSG_USERAUTH_GSSAPI_RESPONSE 60
  50. #define SSH2_MSG_USERAUTH_GSSAPI_TOKEN 61
  51. #define SSH2_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63
  52. #define SSH2_MSG_USERAUTH_GSSAPI_ERROR 64
  53. #define SSH2_MSG_USERAUTH_GSSAPI_ERRTOK 65
  54. #define SSH2_MSG_USERAUTH_GSSAPI_MIC 66
  55. #define SSH_GSS_OIDTYPE 0x06
  56. typedef struct {
  57. char *filename;
  58. char *envvar;
  59. char *envval;
  60. void *data;
  61. } ssh_gssapi_ccache;
  62. typedef struct {
  63. gss_buffer_desc displayname;
  64. gss_buffer_desc exportedname;
  65. gss_cred_id_t creds;
  66. struct ssh_gssapi_mech_struct *mech;
  67. ssh_gssapi_ccache store;
  68. } ssh_gssapi_client;
  69. typedef struct ssh_gssapi_mech_struct {
  70. char *enc_name;
  71. char *name;
  72. gss_OID_desc oid;
  73. int (*dochild) (ssh_gssapi_client *);
  74. int (*userok) (ssh_gssapi_client *, char *);
  75. int (*localname) (ssh_gssapi_client *, char **);
  76. void (*storecreds) (ssh_gssapi_client *);
  77. } ssh_gssapi_mech;
  78. typedef struct {
  79. OM_uint32 major; /* both */
  80. OM_uint32 minor; /* both */
  81. gss_ctx_id_t context; /* both */
  82. gss_name_t name; /* both */
  83. gss_OID oid; /* client */
  84. gss_cred_id_t creds; /* server */
  85. gss_name_t client; /* server */
  86. gss_cred_id_t client_creds; /* server */
  87. } Gssctxt;
  88. extern ssh_gssapi_mech *supported_mechs[];
  89. int ssh_gssapi_check_oid(Gssctxt *, void *, size_t);
  90. void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t);
  91. void ssh_gssapi_set_oid(Gssctxt *, gss_OID);
  92. void ssh_gssapi_supported_oids(gss_OID_set *);
  93. ssh_gssapi_mech *ssh_gssapi_get_ctype(Gssctxt *);
  94. void ssh_gssapi_prepare_supported_oids(void);
  95. OM_uint32 ssh_gssapi_test_oid_supported(OM_uint32 *, gss_OID, int *);
  96. struct sshbuf;
  97. int ssh_gssapi_get_buffer_desc(struct sshbuf *, gss_buffer_desc *);
  98. OM_uint32 ssh_gssapi_import_name(Gssctxt *, const char *);
  99. OM_uint32 ssh_gssapi_init_ctx(Gssctxt *, int,
  100. gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
  101. OM_uint32 ssh_gssapi_accept_ctx(Gssctxt *,
  102. gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
  103. OM_uint32 ssh_gssapi_getclient(Gssctxt *, ssh_gssapi_client *);
  104. void ssh_gssapi_error(Gssctxt *);
  105. char *ssh_gssapi_last_error(Gssctxt *, OM_uint32 *, OM_uint32 *);
  106. void ssh_gssapi_build_ctx(Gssctxt **);
  107. void ssh_gssapi_delete_ctx(Gssctxt **);
  108. OM_uint32 ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
  109. void ssh_gssapi_buildmic(struct sshbuf *, const char *,
  110. const char *, const char *, const struct sshbuf *);
  111. int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *);
  112. /* In the server */
  113. OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
  114. int ssh_gssapi_userok(char *name);
  115. OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
  116. void ssh_gssapi_do_child(char ***, u_int *);
  117. void ssh_gssapi_cleanup_creds(void);
  118. void ssh_gssapi_storecreds(void);
  119. const char *ssh_gssapi_displayname(void);
  120. #endif /* GSSAPI */
  121. #endif /* _SSH_GSS_H */