gssapi_krb5.h 12 KB

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