auth_gss.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* include/gssrpc/auth_gss.h */
  2. /*
  3. Copyright (c) 2000 The Regents of the University of Michigan.
  4. All rights reserved.
  5. Copyright (c) 2000 Dug Song <dugsong@UMICH.EDU>.
  6. All rights reserved, all wrongs reversed.
  7. Redistribution and use in source and binary forms, with or without
  8. modification, are permitted provided that the following conditions
  9. are met:
  10. 1. Redistributions of source code must retain the above copyright
  11. notice, this list of conditions and the following disclaimer.
  12. 2. Redistributions in binary form must reproduce the above copyright
  13. notice, this list of conditions and the following disclaimer in the
  14. documentation and/or other materials provided with the distribution.
  15. 3. Neither the name of the University nor the names of its
  16. contributors may be used to endorse or promote products derived
  17. from this software without specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
  19. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  20. MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  22. FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  23. CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  24. SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
  25. BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  26. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  27. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  28. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. Id: auth_gss.h,v 1.13 2002/05/08 16:54:33 andros Exp
  30. */
  31. #ifndef GSSRPC_AUTH_GSS_H
  32. #define GSSRPC_AUTH_GSS_H
  33. #include <gssrpc/rpc.h>
  34. #include <gssrpc/clnt.h>
  35. #ifdef HAVE_HEIMDAL
  36. #include <gssapi.h>
  37. #else
  38. #include <gssapi/gssapi.h>
  39. #endif
  40. GSSRPC__BEGIN_DECLS
  41. /* RPCSEC_GSS control procedures. */
  42. typedef enum {
  43. RPCSEC_GSS_DATA = 0,
  44. RPCSEC_GSS_INIT = 1,
  45. RPCSEC_GSS_CONTINUE_INIT = 2,
  46. RPCSEC_GSS_DESTROY = 3
  47. } rpc_gss_proc_t;
  48. /* RPCSEC_GSS services. */
  49. typedef enum {
  50. RPCSEC_GSS_SVC_NONE = 1,
  51. RPCSEC_GSS_SVC_INTEGRITY = 2,
  52. RPCSEC_GSS_SVC_PRIVACY = 3
  53. } rpc_gss_svc_t;
  54. #define RPCSEC_GSS_VERSION 1
  55. /* RPCSEC_GSS security triple. */
  56. struct rpc_gss_sec {
  57. gss_OID mech; /* mechanism */
  58. gss_qop_t qop; /* quality of protection */
  59. rpc_gss_svc_t svc; /* service */
  60. gss_cred_id_t cred; /* cred handle */
  61. uint32_t req_flags; /* req flags for init_sec_context */
  62. };
  63. /* Private data required for kernel implementation */
  64. struct authgss_private_data {
  65. gss_ctx_id_t pd_ctx; /* Session context handle */
  66. gss_buffer_desc pd_ctx_hndl; /* Credentials context handle */
  67. uint32_t pd_seq_win; /* Sequence window */
  68. };
  69. /* Krb 5 default mechanism
  70. #define KRB5OID "1.2.840.113554.1.2.2"
  71. gss_OID_desc krb5oid = {
  72. 20, KRB5OID
  73. };
  74. */
  75. /*
  76. struct rpc_gss_sec krb5mech = {
  77. (gss_OID)&krb5oid,
  78. GSS_QOP_DEFAULT,
  79. RPCSEC_GSS_SVC_NONE
  80. };
  81. */
  82. /* Credentials. */
  83. struct rpc_gss_cred {
  84. u_int gc_v; /* version */
  85. rpc_gss_proc_t gc_proc; /* control procedure */
  86. uint32_t gc_seq; /* sequence number */
  87. rpc_gss_svc_t gc_svc; /* service */
  88. gss_buffer_desc gc_ctx; /* context handle */
  89. };
  90. /* Context creation response. */
  91. struct rpc_gss_init_res {
  92. gss_buffer_desc gr_ctx; /* context handle */
  93. uint32_t gr_major; /* major status */
  94. uint32_t gr_minor; /* minor status */
  95. uint32_t gr_win; /* sequence window */
  96. gss_buffer_desc gr_token; /* token */
  97. };
  98. /* Maximum sequence number value. */
  99. #define MAXSEQ 0x80000000
  100. /* Prototypes. */
  101. bool_t xdr_rpc_gss_buf (XDR *xdrs, gss_buffer_t, u_int maxsize);
  102. bool_t xdr_rpc_gss_cred (XDR *xdrs, struct rpc_gss_cred *p);
  103. bool_t xdr_rpc_gss_init_args (XDR *xdrs, gss_buffer_desc *p);
  104. bool_t xdr_rpc_gss_init_res (XDR *xdrs, struct rpc_gss_init_res *p);
  105. bool_t xdr_rpc_gss_data (XDR *xdrs, xdrproc_t xdr_func,
  106. caddr_t xdr_ptr, gss_ctx_id_t ctx,
  107. gss_qop_t qop, rpc_gss_svc_t svc,
  108. uint32_t seq);
  109. bool_t xdr_rpc_gss_wrap_data (XDR *xdrs, xdrproc_t xdr_func, caddr_t
  110. xdr_ptr, gss_ctx_id_t ctx, gss_qop_t qop,
  111. rpc_gss_svc_t svc, uint32_t seq);
  112. bool_t xdr_rpc_gss_unwrap_data (XDR *xdrs, xdrproc_t xdr_func, caddr_t
  113. xdr_ptr, gss_ctx_id_t ctx, gss_qop_t qop,
  114. rpc_gss_svc_t svc, uint32_t seq);
  115. AUTH *authgss_create (CLIENT *, gss_name_t, struct rpc_gss_sec *);
  116. AUTH *authgss_create_default (CLIENT *, char *, struct rpc_gss_sec *);
  117. bool_t authgss_service (AUTH *auth, int svc);
  118. bool_t authgss_get_private_data (AUTH *auth, struct authgss_private_data *);
  119. #ifdef GSSRPC__IMPL
  120. void log_debug (const char *fmt, ...);
  121. void log_status (char *m, OM_uint32 major, OM_uint32 minor);
  122. void log_hexdump (const u_char *buf, int len, int offset);
  123. #endif
  124. GSSRPC__END_DECLS
  125. #endif /* !defined(GSSRPC_AUTH_GSS_H) */