gssapi_ext.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. /*
  2. * Copyright 2008 by the Massachusetts Institute of Technology.
  3. * All Rights Reserved.
  4. *
  5. * Export of this software from the United States of America may
  6. * require a specific license from the United States Government.
  7. * It is the responsibility of any person or organization contemplating
  8. * export to obtain such a license before exporting.
  9. *
  10. * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
  11. * distribute this software and its documentation for any purpose and
  12. * without fee is hereby granted, provided that the above copyright
  13. * notice appear in all copies and that both that copyright notice and
  14. * this permission notice appear in supporting documentation, and that
  15. * the name of M.I.T. not be used in advertising or publicity pertaining
  16. * to distribution of the software without specific, written prior
  17. * permission. Furthermore if you modify this software you must label
  18. * your software as modified software and not distribute it in such a
  19. * fashion that it might be confused with the original M.I.T. software.
  20. * M.I.T. makes no representations about the suitability of
  21. * this software for any purpose. It is provided "as is" without express
  22. * or implied warranty.
  23. */
  24. #ifndef GSSAPI_EXT_H_
  25. #define GSSAPI_EXT_H_
  26. #include <gssapi/gssapi.h>
  27. #ifdef __cplusplus
  28. extern "C" {
  29. #endif /* __cplusplus */
  30. /*
  31. * Solaris extensions
  32. */
  33. #ifndef _WIN32
  34. OM_uint32 KRB5_CALLCONV
  35. gss_pname_to_uid
  36. (OM_uint32 *minor,
  37. const gss_name_t name,
  38. const gss_OID mech_type,
  39. uid_t *uidOut);
  40. #endif
  41. /**
  42. * Provides a platform-specific name for a GSSAPI name as interpreted by a
  43. * given mechanism.
  44. *
  45. * @param name The gss name resulting from accept_sec_context
  46. * @param mech_type The mechanism that will be asked to map @a name to a
  47. * local name
  48. * @param localname Pointer to a buffer_desc allocated by the caller
  49. * that will be filled in with the local name on successful
  50. * completion.
  51. */
  52. OM_uint32 KRB5_CALLCONV
  53. gss_localname
  54. (OM_uint32 *minor,
  55. const gss_name_t name,
  56. gss_const_OID mech_type,
  57. gss_buffer_t localname);
  58. /** Determine whether a mechanism name is authorized to act as a username.
  59. *
  60. * @param [in] name Mechanism name
  61. * @param [in] username System username
  62. *
  63. * This is a simple wrapper around gss_authorize_localname(). It only supports
  64. * system usernames as local names, and cannot distinguish between lack of
  65. * authorization and other errors.
  66. *
  67. * @retval 1 @a name is authorized to act as @a username
  68. * @retval 0 @a name is not authorized or an error occurred
  69. */
  70. int KRB5_CALLCONV
  71. gss_userok(const gss_name_t name,
  72. const char *username);
  73. /** Determine whether a mechanism name is authorized to act as a local name.
  74. *
  75. * @param [out] minor Minor status code
  76. * @param [in] name Mechanism name
  77. * @param [in] user Local name
  78. *
  79. * @a name is a mechanism name, typically the result of a completed
  80. * gss_accept_sec_context(). @a user is an internal name representing a local
  81. * name, such as a name imported by gss_import_name() with an @a
  82. * input_name_type of @c GSS_C_NT_USER_NAME.
  83. *
  84. * @return Return GSS_S_COMPLETE if @a name is authorized to act as @a user,
  85. * GSS_S_UNAUTHORIZED if not, or an appropriate GSS error code if an error
  86. * occured.
  87. *
  88. * @sa gss_userok
  89. */
  90. OM_uint32 KRB5_CALLCONV
  91. gss_authorize_localname(OM_uint32 *minor,
  92. const gss_name_t name,
  93. const gss_name_t user);
  94. OM_uint32 KRB5_CALLCONV
  95. gss_acquire_cred_with_password(
  96. OM_uint32 *, /* minor_status */
  97. const gss_name_t, /* desired_name */
  98. const gss_buffer_t, /* password */
  99. OM_uint32, /* time_req */
  100. const gss_OID_set, /* desired_mechs */
  101. gss_cred_usage_t, /* cred_usage */
  102. gss_cred_id_t *, /* output_cred_handle */
  103. gss_OID_set *, /* actual_mechs */
  104. OM_uint32 *); /* time_rec */
  105. OM_uint32 KRB5_CALLCONV
  106. gss_add_cred_with_password(
  107. OM_uint32 *, /* minor_status */
  108. const gss_cred_id_t,/* input_cred_handle */
  109. const gss_name_t, /* desired_name */
  110. const gss_OID, /* desired_mech */
  111. const gss_buffer_t, /* password */
  112. gss_cred_usage_t, /* cred_usage */
  113. OM_uint32, /* initiator_time_req */
  114. OM_uint32, /* acceptor_time_req */
  115. gss_cred_id_t *, /* output_cred_handle */
  116. gss_OID_set *, /* actual_mechs */
  117. OM_uint32 *, /* initiator_time_rec */
  118. OM_uint32 *); /* acceptor_time_rec */
  119. /*
  120. * GGF extensions
  121. */
  122. typedef struct gss_buffer_set_desc_struct {
  123. size_t count;
  124. gss_buffer_desc *elements;
  125. } gss_buffer_set_desc, *gss_buffer_set_t;
  126. #define GSS_C_NO_BUFFER_SET ((gss_buffer_set_t) 0)
  127. OM_uint32 KRB5_CALLCONV gss_create_empty_buffer_set
  128. (OM_uint32 * /*minor_status*/,
  129. gss_buffer_set_t * /*buffer_set*/);
  130. OM_uint32 KRB5_CALLCONV gss_add_buffer_set_member
  131. (OM_uint32 * /*minor_status*/,
  132. const gss_buffer_t /*member_buffer*/,
  133. gss_buffer_set_t * /*buffer_set*/);
  134. OM_uint32 KRB5_CALLCONV gss_release_buffer_set
  135. (OM_uint32 * /*minor_status*/,
  136. gss_buffer_set_t * /*buffer_set*/);
  137. OM_uint32 KRB5_CALLCONV gss_inquire_sec_context_by_oid
  138. (OM_uint32 * /*minor_status*/,
  139. const gss_ctx_id_t /*context_handle*/,
  140. const gss_OID /*desired_object*/,
  141. gss_buffer_set_t * /*data_set*/);
  142. OM_uint32 KRB5_CALLCONV gss_inquire_cred_by_oid
  143. (OM_uint32 * /*minor_status*/,
  144. const gss_cred_id_t /*cred_handle*/,
  145. const gss_OID /*desired_object*/,
  146. gss_buffer_set_t * /*data_set*/);
  147. OM_uint32 KRB5_CALLCONV gss_set_sec_context_option
  148. (OM_uint32 * /*minor_status*/,
  149. gss_ctx_id_t * /*cred_handle*/,
  150. const gss_OID /*desired_object*/,
  151. const gss_buffer_t /*value*/);
  152. OM_uint32 KRB5_CALLCONV gss_set_cred_option
  153. (OM_uint32 * /*minor_status*/,
  154. gss_cred_id_t * /*cred*/,
  155. const gss_OID /*desired_object*/,
  156. const gss_buffer_t /*value*/);
  157. OM_uint32 KRB5_CALLCONV gssspi_mech_invoke
  158. (OM_uint32 * /*minor_status*/,
  159. const gss_OID /*desired_mech*/,
  160. const gss_OID /*desired_object*/,
  161. gss_buffer_t /*value*/);
  162. /*
  163. * AEAD extensions
  164. */
  165. OM_uint32 KRB5_CALLCONV gss_wrap_aead
  166. (OM_uint32 * /*minor_status*/,
  167. gss_ctx_id_t /*context_handle*/,
  168. int /*conf_req_flag*/,
  169. gss_qop_t /*qop_req*/,
  170. gss_buffer_t /*input_assoc_buffer*/,
  171. gss_buffer_t /*input_payload_buffer*/,
  172. int * /*conf_state*/,
  173. gss_buffer_t /*output_message_buffer*/);
  174. OM_uint32 KRB5_CALLCONV gss_unwrap_aead
  175. (OM_uint32 * /*minor_status*/,
  176. gss_ctx_id_t /*context_handle*/,
  177. gss_buffer_t /*input_message_buffer*/,
  178. gss_buffer_t /*input_assoc_buffer*/,
  179. gss_buffer_t /*output_payload_buffer*/,
  180. int * /*conf_state*/,
  181. gss_qop_t * /*qop_state*/);
  182. /*
  183. * SSPI extensions
  184. */
  185. #define GSS_C_DCE_STYLE 0x1000
  186. #define GSS_C_IDENTIFY_FLAG 0x2000
  187. #define GSS_C_EXTENDED_ERROR_FLAG 0x4000
  188. /*
  189. * Returns a buffer set with the first member containing the
  190. * session key for SSPI compatibility. The optional second
  191. * member contains an OID identifying the session key type.
  192. */
  193. GSS_DLLIMP extern gss_OID GSS_C_INQ_SSPI_SESSION_KEY;
  194. OM_uint32 KRB5_CALLCONV gss_complete_auth_token
  195. (OM_uint32 *minor_status,
  196. const gss_ctx_id_t context_handle,
  197. gss_buffer_t input_message_buffer);
  198. typedef struct gss_iov_buffer_desc_struct {
  199. OM_uint32 type;
  200. gss_buffer_desc buffer;
  201. } gss_iov_buffer_desc, *gss_iov_buffer_t;
  202. #define GSS_C_NO_IOV_BUFFER ((gss_iov_buffer_t)0)
  203. #define GSS_IOV_BUFFER_TYPE_EMPTY 0
  204. #define GSS_IOV_BUFFER_TYPE_DATA 1 /* Packet data */
  205. #define GSS_IOV_BUFFER_TYPE_HEADER 2 /* Mechanism header */
  206. #define GSS_IOV_BUFFER_TYPE_MECH_PARAMS 3 /* Mechanism specific parameters */
  207. #define GSS_IOV_BUFFER_TYPE_TRAILER 7 /* Mechanism trailer */
  208. #define GSS_IOV_BUFFER_TYPE_PADDING 9 /* Padding */
  209. #define GSS_IOV_BUFFER_TYPE_STREAM 10 /* Complete wrap token */
  210. #define GSS_IOV_BUFFER_TYPE_SIGN_ONLY 11 /* Sign only packet data */
  211. #define GSS_IOV_BUFFER_FLAG_MASK 0xFFFF0000
  212. #define GSS_IOV_BUFFER_FLAG_ALLOCATE 0x00010000 /* indicates GSS should allocate */
  213. #define GSS_IOV_BUFFER_FLAG_ALLOCATED 0x00020000 /* indicates caller should free */
  214. #define GSS_IOV_BUFFER_TYPE(_type) ((_type) & ~(GSS_IOV_BUFFER_FLAG_MASK))
  215. #define GSS_IOV_BUFFER_FLAGS(_type) ((_type) & GSS_IOV_BUFFER_FLAG_MASK)
  216. /*
  217. * Sign and optionally encrypt a sequence of buffers. The buffers
  218. * shall be ordered HEADER | DATA | PADDING | TRAILER. Suitable
  219. * space for the header, padding and trailer should be provided
  220. * by calling gss_wrap_iov_length(), or the ALLOCATE flag should
  221. * be set on those buffers.
  222. *
  223. * Encryption is in-place. SIGN_ONLY buffers are untouched. Only
  224. * a single PADDING buffer should be provided. The order of the
  225. * buffers in memory does not matter. Buffers in the IOV should
  226. * be arranged in the order above, and in the case of multiple
  227. * DATA buffers the sender and receiver should agree on the
  228. * order.
  229. *
  230. * With GSS_C_DCE_STYLE it is acceptable to not provide PADDING
  231. * and TRAILER, but the caller must guarantee the plaintext data
  232. * being encrypted is correctly padded, otherwise an error will
  233. * be returned.
  234. *
  235. * While applications that have knowledge of the underlying
  236. * cryptosystem may request a specific configuration of data
  237. * buffers, the only generally supported configurations are:
  238. *
  239. * HEADER | DATA | PADDING | TRAILER
  240. *
  241. * which will emit GSS_Wrap() compatible tokens, and:
  242. *
  243. * HEADER | SIGN_ONLY | DATA | PADDING | TRAILER
  244. *
  245. * for AEAD.
  246. *
  247. * The typical (special cased) usage for DCE is as follows:
  248. *
  249. * SIGN_ONLY_1 | DATA | SIGN_ONLY_2 | HEADER
  250. */
  251. OM_uint32 KRB5_CALLCONV gss_wrap_iov
  252. (
  253. OM_uint32 *, /* minor_status */
  254. gss_ctx_id_t, /* context_handle */
  255. int, /* conf_req_flag */
  256. gss_qop_t, /* qop_req */
  257. int *, /* conf_state */
  258. gss_iov_buffer_desc *, /* iov */
  259. int); /* iov_count */
  260. /*
  261. * Verify and optionally decrypt a sequence of buffers. To process
  262. * a GSS-API message without separate buffer, pass STREAM | DATA.
  263. * Upon return DATA will contain the decrypted or integrity
  264. * protected message. Only a single DATA buffer may be provided
  265. * with this usage. DATA by default will point into STREAM, but if
  266. * the ALLOCATE flag is set a copy will be returned.
  267. *
  268. * Otherwise, decryption is in-place. SIGN_ONLY buffers are
  269. * untouched.
  270. */
  271. OM_uint32 KRB5_CALLCONV gss_unwrap_iov
  272. (
  273. OM_uint32 *, /* minor_status */
  274. gss_ctx_id_t, /* context_handle */
  275. int *, /* conf_state */
  276. gss_qop_t *, /* qop_state */
  277. gss_iov_buffer_desc *, /* iov */
  278. int); /* iov_count */
  279. /*
  280. * Query HEADER, PADDING and TRAILER buffer lengths. DATA buffers
  281. * should be provided so the correct padding length can be determined.
  282. */
  283. OM_uint32 KRB5_CALLCONV gss_wrap_iov_length
  284. (
  285. OM_uint32 *, /* minor_status */
  286. gss_ctx_id_t, /* context_handle */
  287. int, /* conf_req_flag */
  288. gss_qop_t, /* qop_req */
  289. int *, /* conf_state */
  290. gss_iov_buffer_desc *, /* iov */
  291. int); /* iov_count */
  292. /*
  293. * Release buffers that have the ALLOCATED flag set.
  294. */
  295. OM_uint32 KRB5_CALLCONV gss_release_iov_buffer
  296. (
  297. OM_uint32 *, /* minor_status */
  298. gss_iov_buffer_desc *, /* iov */
  299. int); /* iov_count */
  300. /*
  301. * Protocol transition
  302. */
  303. OM_uint32 KRB5_CALLCONV
  304. gss_acquire_cred_impersonate_name(
  305. OM_uint32 *, /* minor_status */
  306. const gss_cred_id_t, /* impersonator_cred_handle */
  307. const gss_name_t, /* desired_name */
  308. OM_uint32, /* time_req */
  309. const gss_OID_set, /* desired_mechs */
  310. gss_cred_usage_t, /* cred_usage */
  311. gss_cred_id_t *, /* output_cred_handle */
  312. gss_OID_set *, /* actual_mechs */
  313. OM_uint32 *); /* time_rec */
  314. OM_uint32 KRB5_CALLCONV
  315. gss_add_cred_impersonate_name(
  316. OM_uint32 *, /* minor_status */
  317. gss_cred_id_t, /* input_cred_handle */
  318. const gss_cred_id_t, /* impersonator_cred_handle */
  319. const gss_name_t, /* desired_name */
  320. const gss_OID, /* desired_mech */
  321. gss_cred_usage_t, /* cred_usage */
  322. OM_uint32, /* initiator_time_req */
  323. OM_uint32, /* acceptor_time_req */
  324. gss_cred_id_t *, /* output_cred_handle */
  325. gss_OID_set *, /* actual_mechs */
  326. OM_uint32 *, /* initiator_time_rec */
  327. OM_uint32 *); /* acceptor_time_rec */
  328. /*
  329. * Naming extensions
  330. */
  331. GSS_DLLIMP extern gss_buffer_t GSS_C_ATTR_LOCAL_LOGIN_USER;
  332. OM_uint32 KRB5_CALLCONV gss_display_name_ext
  333. (
  334. OM_uint32 *, /* minor_status */
  335. gss_name_t, /* name */
  336. gss_OID, /* display_as_name_type */
  337. gss_buffer_t /* display_name */
  338. );
  339. OM_uint32 KRB5_CALLCONV gss_inquire_name
  340. (
  341. OM_uint32 *, /* minor_status */
  342. gss_name_t, /* name */
  343. int *, /* name_is_MN */
  344. gss_OID *, /* MN_mech */
  345. gss_buffer_set_t * /* attrs */
  346. );
  347. OM_uint32 KRB5_CALLCONV gss_get_name_attribute
  348. (
  349. OM_uint32 *, /* minor_status */
  350. gss_name_t, /* name */
  351. gss_buffer_t, /* attr */
  352. int *, /* authenticated */
  353. int *, /* complete */
  354. gss_buffer_t, /* value */
  355. gss_buffer_t, /* display_value */
  356. int * /* more */
  357. );
  358. OM_uint32 KRB5_CALLCONV gss_set_name_attribute
  359. (
  360. OM_uint32 *, /* minor_status */
  361. gss_name_t, /* name */
  362. int, /* complete */
  363. gss_buffer_t, /* attr */
  364. gss_buffer_t /* value */
  365. );
  366. OM_uint32 KRB5_CALLCONV gss_delete_name_attribute
  367. (
  368. OM_uint32 *, /* minor_status */
  369. gss_name_t, /* name */
  370. gss_buffer_t /* attr */
  371. );
  372. OM_uint32 KRB5_CALLCONV gss_export_name_composite
  373. (
  374. OM_uint32 *, /* minor_status */
  375. gss_name_t, /* name */
  376. gss_buffer_t /* exp_composite_name */
  377. );
  378. typedef struct gss_any *gss_any_t;
  379. OM_uint32 KRB5_CALLCONV gss_map_name_to_any
  380. (
  381. OM_uint32 *, /* minor_status */
  382. gss_name_t, /* name */
  383. int, /* authenticated */
  384. gss_buffer_t, /* type_id */
  385. gss_any_t * /* output */
  386. );
  387. OM_uint32 KRB5_CALLCONV gss_release_any_name_mapping
  388. (
  389. OM_uint32 *, /* minor_status */
  390. gss_name_t, /* name */
  391. gss_buffer_t, /* type_id */
  392. gss_any_t * /* input */
  393. );
  394. /* draft-josefsson-gss-capsulate */
  395. OM_uint32 KRB5_CALLCONV gss_encapsulate_token
  396. (
  397. gss_const_buffer_t, /* input_token */
  398. gss_const_OID, /* token_oid */
  399. gss_buffer_t /* output_token */
  400. );
  401. OM_uint32 KRB5_CALLCONV gss_decapsulate_token
  402. (
  403. gss_const_buffer_t, /* input_token */
  404. gss_const_OID, /* token_oid */
  405. gss_buffer_t /* output_token */
  406. );
  407. int KRB5_CALLCONV gss_oid_equal
  408. (
  409. gss_const_OID, /* first_oid */
  410. gss_const_OID /* second_oid */
  411. );
  412. #ifdef __cplusplus
  413. }
  414. #endif
  415. #endif /* GSSAPI_EXT_H_ */