gssapi_krb5.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. /* This is the gssapi_krb5.h prologue. */
  2. #include <stdint.h>
  3. /* End of gssapi_krb5.h prologue. */
  4. /* -*- mode: c; indent-tabs-mode: nil -*- */
  5. /*
  6. * Copyright 1993 by OpenVision Technologies, Inc.
  7. *
  8. * Permission to use, copy, modify, distribute, and sell this software
  9. * and its documentation for any purpose is hereby granted without fee,
  10. * provided that the above copyright notice appears in all copies and
  11. * that both that copyright notice and this permission notice appear in
  12. * supporting documentation, and that the name of OpenVision not be used
  13. * in advertising or publicity pertaining to distribution of the software
  14. * without specific, written prior permission. OpenVision makes no
  15. * representations about the suitability of this software for any
  16. * purpose. It is provided "as is" without express or implied warranty.
  17. *
  18. * OPENVISION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  19. * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  20. * EVENT SHALL OPENVISION BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  21. * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
  22. * USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
  23. * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  24. * PERFORMANCE OF THIS SOFTWARE.
  25. */
  26. #ifndef _GSSAPI_KRB5_H_
  27. #define _GSSAPI_KRB5_H_
  28. #include <gssapi/gssapi.h>
  29. #include <gssapi/gssapi_ext.h>
  30. #include <krb5.h>
  31. /* C++ friendlyness */
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif /* __cplusplus */
  35. /* Reserved static storage for GSS_oids. See rfc 1964 for more details. */
  36. /* 2.1.1. Kerberos Principal Name Form: */
  37. GSS_DLLIMP extern const gss_OID_desc * const GSS_KRB5_NT_PRINCIPAL_NAME;
  38. /* This name form shall be represented by the Object Identifier {iso(1)
  39. * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
  40. * krb5(2) krb5_name(1)}. The recommended symbolic name for this type
  41. * is "GSS_KRB5_NT_PRINCIPAL_NAME". */
  42. /* 2.1.2. Host-Based Service Name Form */
  43. #define GSS_KRB5_NT_HOSTBASED_SERVICE_NAME GSS_C_NT_HOSTBASED_SERVICE
  44. /* This name form shall be represented by the Object Identifier {iso(1)
  45. * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
  46. * generic(1) service_name(4)}. The previously recommended symbolic
  47. * name for this type is "GSS_KRB5_NT_HOSTBASED_SERVICE_NAME". The
  48. * currently preferred symbolic name for this type is
  49. * "GSS_C_NT_HOSTBASED_SERVICE". */
  50. /* 2.2.1. User Name Form */
  51. #define GSS_KRB5_NT_USER_NAME GSS_C_NT_USER_NAME
  52. /* This name form shall be represented by the Object Identifier {iso(1)
  53. * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
  54. * generic(1) user_name(1)}. The recommended symbolic name for this
  55. * type is "GSS_KRB5_NT_USER_NAME". */
  56. /* 2.2.2. Machine UID Form */
  57. #define GSS_KRB5_NT_MACHINE_UID_NAME GSS_C_NT_MACHINE_UID_NAME
  58. /* This name form shall be represented by the Object Identifier {iso(1)
  59. * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
  60. * generic(1) machine_uid_name(2)}. The recommended symbolic name for
  61. * this type is "GSS_KRB5_NT_MACHINE_UID_NAME". */
  62. /* 2.2.3. String UID Form */
  63. #define GSS_KRB5_NT_STRING_UID_NAME GSS_C_NT_STRING_UID_NAME
  64. /* This name form shall be represented by the Object Identifier {iso(1)
  65. * member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
  66. * generic(1) string_uid_name(3)}. The recommended symbolic name for
  67. * this type is "GSS_KRB5_NT_STRING_UID_NAME". */
  68. GSS_DLLIMP extern const gss_OID_desc * const gss_mech_krb5;
  69. GSS_DLLIMP extern const gss_OID_desc * const gss_mech_krb5_old;
  70. GSS_DLLIMP extern const gss_OID_desc * const gss_mech_krb5_wrong;
  71. GSS_DLLIMP extern const gss_OID_desc * const gss_mech_iakerb;
  72. GSS_DLLIMP extern const gss_OID_set_desc * const gss_mech_set_krb5;
  73. GSS_DLLIMP extern const gss_OID_set_desc * const gss_mech_set_krb5_old;
  74. GSS_DLLIMP extern const gss_OID_set_desc * const gss_mech_set_krb5_both;
  75. GSS_DLLIMP extern const gss_OID_desc * const gss_nt_krb5_name;
  76. GSS_DLLIMP extern const gss_OID_desc * const gss_nt_krb5_principal;
  77. GSS_DLLIMP extern const gss_OID_desc krb5_gss_oid_array[];
  78. #define gss_krb5_nt_general_name gss_nt_krb5_name
  79. #define gss_krb5_nt_principal gss_nt_krb5_principal
  80. #define gss_krb5_nt_service_name gss_nt_service_name
  81. #define gss_krb5_nt_user_name gss_nt_user_name
  82. #define gss_krb5_nt_machine_uid_name gss_nt_machine_uid_name
  83. #define gss_krb5_nt_string_uid_name gss_nt_string_uid_name
  84. #if defined(_WIN32)
  85. typedef unsigned __int64 gss_uint64;
  86. #else /*windows*/
  87. #include <inttypes.h>
  88. typedef uint64_t gss_uint64;
  89. #endif
  90. typedef struct gss_krb5_lucid_key {
  91. OM_uint32 type; /* key encryption type */
  92. OM_uint32 length; /* length of key data */
  93. void * data; /* actual key data */
  94. } gss_krb5_lucid_key_t;
  95. typedef struct gss_krb5_rfc1964_keydata {
  96. OM_uint32 sign_alg; /* signing algorthm */
  97. OM_uint32 seal_alg; /* seal/encrypt algorthm */
  98. gss_krb5_lucid_key_t ctx_key;
  99. /* Context key
  100. (Kerberos session key or subkey) */
  101. } gss_krb5_rfc1964_keydata_t;
  102. typedef struct gss_krb5_cfx_keydata {
  103. OM_uint32 have_acceptor_subkey;
  104. /* 1 if there is an acceptor_subkey
  105. present, 0 otherwise */
  106. gss_krb5_lucid_key_t ctx_key;
  107. /* Context key
  108. (Kerberos session key or subkey) */
  109. gss_krb5_lucid_key_t acceptor_subkey;
  110. /* acceptor-asserted subkey or
  111. 0's if no acceptor subkey */
  112. } gss_krb5_cfx_keydata_t;
  113. typedef struct gss_krb5_lucid_context_v1 {
  114. OM_uint32 version; /* Structure version number (1)
  115. MUST be at beginning of struct! */
  116. OM_uint32 initiate; /* Are we the initiator? */
  117. OM_uint32 endtime; /* expiration time of context */
  118. gss_uint64 send_seq; /* sender sequence number */
  119. gss_uint64 recv_seq; /* receive sequence number */
  120. OM_uint32 protocol; /* 0: rfc1964,
  121. 1: draft-ietf-krb-wg-gssapi-cfx-07 */
  122. /*
  123. * if (protocol == 0) rfc1964_kd should be used
  124. * and cfx_kd contents are invalid and should be zero
  125. * if (protocol == 1) cfx_kd should be used
  126. * and rfc1964_kd contents are invalid and should be zero
  127. */
  128. gss_krb5_rfc1964_keydata_t rfc1964_kd;
  129. gss_krb5_cfx_keydata_t cfx_kd;
  130. } gss_krb5_lucid_context_v1_t;
  131. /*
  132. * Mask for determining the version of a lucid context structure. Callers
  133. * should not require this.
  134. */
  135. typedef struct gss_krb5_lucid_context_version {
  136. OM_uint32 version; /* Structure version number */
  137. } gss_krb5_lucid_context_version_t;
  138. /* Alias for Heimdal compat. */
  139. #define gsskrb5_register_acceptor_identity krb5_gss_register_acceptor_identity
  140. OM_uint32 KRB5_CALLCONV krb5_gss_register_acceptor_identity(const char *);
  141. OM_uint32 KRB5_CALLCONV gss_krb5_get_tkt_flags(
  142. OM_uint32 *minor_status,
  143. gss_ctx_id_t context_handle,
  144. krb5_flags *ticket_flags);
  145. OM_uint32 KRB5_CALLCONV gss_krb5_copy_ccache(
  146. OM_uint32 *minor_status,
  147. gss_cred_id_t cred_handle,
  148. krb5_ccache out_ccache);
  149. OM_uint32 KRB5_CALLCONV gss_krb5_ccache_name(
  150. OM_uint32 *minor_status, const char *name,
  151. const char **out_name);
  152. /*
  153. * gss_krb5_set_allowable_enctypes
  154. *
  155. * This function may be called by a context initiator after calling
  156. * gss_acquire_cred(), but before calling gss_init_sec_context(),
  157. * to restrict the set of enctypes which will be negotiated during
  158. * context establishment to those in the provided array.
  159. *
  160. * 'cred' must be a valid credential handle obtained via
  161. * gss_acquire_cred(). It may not be GSS_C_NO_CREDENTIAL.
  162. * gss_acquire_cred() may have been called to get a handle to
  163. * the default credential.
  164. *
  165. * The purpose of this function is to limit the keys that may
  166. * be exported via gss_krb5_export_lucid_sec_context(); thus it
  167. * should limit the enctypes of all keys that will be needed
  168. * after the security context has been established.
  169. * (i.e. context establishment may use a session key with a
  170. * stronger enctype than in the provided array, however a
  171. * subkey must be established within the enctype limits
  172. * established by this function.)
  173. *
  174. */
  175. OM_uint32 KRB5_CALLCONV
  176. gss_krb5_set_allowable_enctypes(OM_uint32 *minor_status,
  177. gss_cred_id_t cred,
  178. OM_uint32 num_ktypes,
  179. krb5_enctype *ktypes);
  180. /*
  181. * Returns a non-opaque (lucid) version of the internal context
  182. * information.
  183. *
  184. * Note that context_handle must not be used again by the caller
  185. * after this call. The GSS implementation is free to release any
  186. * resources associated with the original context. It is up to the
  187. * GSS implementation whether it returns pointers to existing data,
  188. * or copies of the data. The caller should treat the returned
  189. * lucid context as read-only.
  190. *
  191. * The caller must call gss_krb5_free_lucid_context() to free
  192. * the context and allocated resources when it is finished with it.
  193. *
  194. * 'version' is an integer indicating the requested version of the lucid
  195. * context. If the implementation does not understand the requested version,
  196. * it will return an error.
  197. *
  198. * For example:
  199. * void *return_ctx;
  200. * gss_krb5_lucid_context_v1_t *ctx;
  201. * OM_uint32 min_stat, maj_stat;
  202. * OM_uint32 vers;
  203. * gss_ctx_id_t *ctx_handle;
  204. *
  205. * maj_stat = gss_krb5_export_lucid_sec_context(&min_stat,
  206. * ctx_handle, 1, &return_ctx);
  207. * // Verify success
  208. * ctx = (gss_krb5_lucid_context_v1_t *) return_ctx;
  209. */
  210. OM_uint32 KRB5_CALLCONV
  211. gss_krb5_export_lucid_sec_context(OM_uint32 *minor_status,
  212. gss_ctx_id_t *context_handle,
  213. OM_uint32 version,
  214. void **kctx);
  215. /*
  216. * Frees the allocated storage associated with an
  217. * exported struct gss_krb5_lucid_context.
  218. */
  219. OM_uint32 KRB5_CALLCONV
  220. gss_krb5_free_lucid_sec_context(OM_uint32 *minor_status,
  221. void *kctx);
  222. OM_uint32 KRB5_CALLCONV
  223. gsskrb5_extract_authz_data_from_sec_context(OM_uint32 *minor_status,
  224. const gss_ctx_id_t context_handle,
  225. int ad_type,
  226. gss_buffer_t ad_data);
  227. OM_uint32 KRB5_CALLCONV
  228. gss_krb5_set_cred_rcache(OM_uint32 *minor_status,
  229. gss_cred_id_t cred,
  230. krb5_rcache rcache);
  231. OM_uint32 KRB5_CALLCONV
  232. gsskrb5_extract_authtime_from_sec_context(OM_uint32 *, gss_ctx_id_t, krb5_timestamp *);
  233. OM_uint32 KRB5_CALLCONV
  234. gss_krb5_import_cred(OM_uint32 *minor_status,
  235. krb5_ccache id,
  236. krb5_principal keytab_principal,
  237. krb5_keytab keytab,
  238. gss_cred_id_t *cred);
  239. #ifdef __cplusplus
  240. }
  241. #endif /* __cplusplus */
  242. #endif /* _GSSAPI_KRB5_H_ */