2 * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
4 #ifndef _GSSAPIP_SPNEGO_H_
5 #define _GSSAPIP_SPNEGO_H_
11 #include <gssapi/gssapi.h>
12 #include <gssapi/gssapi_ext.h>
15 #define SEC_CONTEXT_TOKEN 1
16 #define SPNEGO_SIZE_OF_INT 4
18 #define ACCEPT_COMPLETE 0
19 #define ACCEPT_INCOMPLETE 1
22 #define ACCEPT_DEFECTIVE_TOKEN 0xffffffffUL
25 * constants for der encoding/decoding routines.
29 #define OCTET_STRING 0x04
32 #define SEQUENCE_OF 0x30
33 #define BIT_STRING 0x03
34 #define BIT_STRING_LENGTH 0x02
35 #define BIT_STRING_PADDING 0x01
36 #define ENUMERATED 0x0a
37 #define ENUMERATION_LENGTH 1
38 #define HEADER_ID 0x60
39 #define GENERAL_STRING 0x1b
42 * SPNEGO specific error codes (minor status codes)
44 #define ERR_SPNEGO_NO_MECHS_AVAILABLE 0x20000001
45 #define ERR_SPNEGO_NO_CREDS_ACQUIRED 0x20000002
46 #define ERR_SPNEGO_NO_MECH_FROM_ACCEPTOR 0x20000003
47 #define ERR_SPNEGO_NEGOTIATION_FAILED 0x20000004
48 #define ERR_SPNEGO_NO_TOKEN_FROM_ACCEPTOR 0x20000005
51 * send_token_flag is used to indicate in later steps what type
52 * of token, if any should be sent or processed.
53 * NO_TOKEN_SEND = no token should be sent
54 * INIT_TOKEN_SEND = initial token will be sent
55 * CONT_TOKEN_SEND = continuing tokens to be sent
56 * CHECK_MIC = no token to be sent, but have a MIC to check.
57 * ERROR_TOKEN_SEND = error token from peer needs to be sent.
60 typedef enum {NO_TOKEN_SEND
, INIT_TOKEN_SEND
, CONT_TOKEN_SEND
,
61 CHECK_MIC
, ERROR_TOKEN_SEND
} send_token_flag
;
65 * { iso(1) org(3) dod(6) internet(1) security(5)
66 * mechanism(5) spnego(2) }
69 #define SPNEGO_OID_LENGTH 6
70 #define SPNEGO_OID "\053\006\001\005\005\002"
72 typedef void *spnego_token_t
;
74 /* spnego name structure for internal representation. */
80 } spnego_name_desc
, *spnego_name_t
;
82 /* Structure for context handle */
85 gss_buffer_desc DER_mechTypes
;
86 gss_OID internal_mech
;
87 gss_ctx_id_t ctx_handle
;
89 gss_cred_id_t default_cred
;
97 gss_name_t internal_name
;
100 } spnego_gss_ctx_id_rec
, *spnego_gss_ctx_id_t
;
103 * The magic number must be less than a standard pagesize
104 * to avoid a possible collision with a real address.
106 #define SPNEGO_MAGIC_ID 0x00000fed
108 /* SPNEGO oid declarations */
109 extern const gss_OID_desc
* const gss_mech_spnego
;
110 extern const gss_OID_set_desc
* const gss_mech_set_spnego
;
114 #define dsyslog(a) syslog(LOG_DEBUG, a)
117 #define SPNEGO_STATIC
121 * declarations of internal name mechanism functions
124 OM_uint32 spnego_gss_acquire_cred
126 OM_uint32
*, /* minor_status */
127 gss_name_t
, /* desired_name */
128 OM_uint32
, /* time_req */
129 gss_OID_set
, /* desired_mechs */
130 gss_cred_usage_t
, /* cred_usage */
131 gss_cred_id_t
*, /* output_cred_handle */
132 gss_OID_set
*, /* actual_mechs */
133 OM_uint32
* /* time_rec */
136 OM_uint32 glue_spnego_gss_acquire_cred
139 OM_uint32
*, /* minor_status */
140 gss_name_t
, /* desired_name */
141 OM_uint32
, /* time_req */
142 gss_OID_set
, /* desired_mechs */
143 gss_cred_usage_t
, /* cred_usage */
144 gss_cred_id_t
*, /* output_cred_handle */
145 gss_OID_set
*, /* actual_mechs */
146 OM_uint32
* /* time_rec */
149 OM_uint32 spnego_gss_release_cred
151 OM_uint32
*, /* minor_status */
153 gss_cred_id_t
* /* cred_handle */
156 OM_uint32 glue_spnego_gss_release_cred
159 OM_uint32
*, /* minor_status */
161 gss_cred_id_t
* /* cred_handle */
164 OM_uint32 spnego_gss_init_sec_context
166 OM_uint32
*, /* minor_status */
167 gss_cred_id_t
, /* claimant_cred_handle */
168 gss_ctx_id_t
*, /* context_handle */
169 gss_name_t
, /* target_name */
170 gss_OID
, /* mech_type */
171 OM_uint32
, /* req_flags */
172 OM_uint32
, /* time_req */
173 gss_channel_bindings_t
, /* input_chan_bindings */
174 gss_buffer_t
, /* input_token */
175 gss_OID
*, /* actual_mech_type */
176 gss_buffer_t
, /* output_token */
177 OM_uint32
*, /* ret_flags */
178 OM_uint32
* /* time_rec */
181 OM_uint32 glue_spnego_gss_init_sec_context
184 OM_uint32
*, /* minor_status */
185 gss_cred_id_t
, /* claimant_cred_handle */
186 gss_ctx_id_t
*, /* context_handle */
187 gss_name_t
, /* target_name */
188 gss_OID
, /* mech_type */
189 OM_uint32
, /* req_flags */
190 OM_uint32
, /* time_req */
191 gss_channel_bindings_t
, /* input_chan_bindings */
192 gss_buffer_t
, /* input_token */
193 gss_OID
*, /* actual_mech_type */
194 gss_buffer_t
, /* output_token */
195 OM_uint32
*, /* ret_flags */
196 OM_uint32
* /* time_rec */
200 OM_uint32 spnego_gss_accept_sec_context
202 OM_uint32
*, /* minor_status */
203 gss_ctx_id_t
*, /* context_handle */
204 gss_cred_id_t
, /* verifier_cred_handle */
205 gss_buffer_t
, /* input_token_buffer */
206 gss_channel_bindings_t
, /* input_chan_bindings */
207 gss_name_t
*, /* src_name */
208 gss_OID
*, /* mech_type */
209 gss_buffer_t
, /* output_token */
210 OM_uint32
*, /* ret_flags */
211 OM_uint32
*, /* time_rec */
213 gss_cred_id_t
* /* delegated_cred_handle */
215 OM_uint32 glue_spnego_gss_accept_sec_context
218 OM_uint32
*, /* minor_status */
219 gss_ctx_id_t
*, /* context_handle */
220 gss_cred_id_t
, /* verifier_cred_handle */
221 gss_buffer_t
, /* input_token_buffer */
222 gss_channel_bindings_t
, /* input_chan_bindings */
223 gss_name_t
*, /* src_name */
224 gss_OID
*, /* mech_type */
225 gss_buffer_t
, /* output_token */
226 OM_uint32
*, /* ret_flags */
227 OM_uint32
*, /* time_rec */
229 gss_cred_id_t
* /* delegated_cred_handle */
232 #endif /* LEAN_CLIENT */
234 OM_uint32 spnego_gss_compare_name
236 OM_uint32
*, /* minor_status */
237 const gss_name_t
, /* name1 */
238 const gss_name_t
, /* name2 */
239 int * /* name_equal */
242 OM_uint32 glue_spnego_gss_compare_name
245 OM_uint32
*, /* minor_status */
246 const gss_name_t
, /* name1 */
247 const gss_name_t
, /* name2 */
248 int * /* name_equal */
251 OM_uint32 spnego_gss_display_name
253 OM_uint32
*, /* minor_status */
254 gss_name_t
, /* input_name */
255 gss_buffer_t
, /* output_name_buffer */
256 gss_OID
* /* output_name_type */
259 OM_uint32 glue_spnego_gss_display_name
262 OM_uint32
*, /* minor_status */
263 gss_name_t
, /* input_name */
264 gss_buffer_t
, /* output_name_buffer */
265 gss_OID
* /* output_name_type */
268 OM_uint32 spnego_gss_display_status
270 OM_uint32
*, /* minor_status */
271 OM_uint32
, /* status_value */
272 int, /* status_type */
273 gss_OID
, /* mech_type */
274 OM_uint32
*, /* message_context */
275 gss_buffer_t
/* status_string */
278 OM_uint32 spnego_gss_display_status2
280 OM_uint32
*, /* minor_status */
281 OM_uint32
, /* status_value */
282 int, /* status_type */
283 gss_OID
, /* mech_type */
284 OM_uint32
*, /* message_context */
285 gss_buffer_t
/* status_string */
288 OM_uint32 glue_spnego_gss_display_status
291 OM_uint32
*, /* minor_status */
292 OM_uint32
, /* status_value */
293 int, /* status_type */
294 gss_OID
, /* mech_type */
295 OM_uint32
*, /* message_context */
296 gss_buffer_t
/* status_string */
299 OM_uint32 spnego_gss_import_name
301 OM_uint32
*, /* minor_status */
302 gss_buffer_t
, /* input_name_buffer */
303 gss_OID
, /* input_name_type */
305 gss_name_t
* /* output_name */
308 OM_uint32 glue_spnego_gss_import_name
311 OM_uint32
*, /* minor_status */
312 gss_buffer_t
, /* input_name_buffer */
313 gss_OID
, /* input_name_type */
315 gss_name_t
* /* output_name */
317 OM_uint32 spnego_gss_release_name
319 OM_uint32
*, /* minor_status */
321 gss_name_t
* /* input_name */
324 OM_uint32 glue_spnego_gss_release_name
328 OM_uint32
*, /* minor_status */
330 gss_name_t
* /* input_name */
333 OM_uint32 spnego_gss_inquire_names_for_mech
335 OM_uint32
*, /* minor_status */
336 gss_OID
, /* mechanism */
337 gss_OID_set
* /* name_types */
340 OM_uint32 glue_spnego_gss_inquire_names_for_mech
343 OM_uint32
*, /* minor_status */
344 gss_OID
, /* mechanism */
345 gss_OID_set
* /* name_types */
348 OM_uint32 spnego_gss_unwrap
350 OM_uint32
*minor_status
,
351 gss_ctx_id_t context_handle
,
352 gss_buffer_t input_message_buffer
,
353 gss_buffer_t output_message_buffer
,
358 OM_uint32 spnego_gss_wrap
360 OM_uint32
*minor_status
,
361 gss_ctx_id_t context_handle
,
364 gss_buffer_t input_message_buffer
,
366 gss_buffer_t output_message_buffer
369 OM_uint32 spnego_gss_process_context_token
371 OM_uint32
*minor_status
,
372 const gss_ctx_id_t context_handle
,
373 const gss_buffer_t token_buffer
376 OM_uint32 spnego_gss_delete_sec_context
378 OM_uint32
*minor_status
,
379 gss_ctx_id_t
*context_handle
,
380 gss_buffer_t output_token
383 OM_uint32 glue_spnego_gss_delete_sec_context
387 OM_uint32
*minor_status
,
388 gss_ctx_id_t
*context_handle
,
389 gss_buffer_t output_token
392 OM_uint32 spnego_gss_context_time
394 OM_uint32
*minor_status
,
395 const gss_ctx_id_t context_handle
,
398 OM_uint32 glue_spnego_gss_context_time
401 OM_uint32
*minor_status
,
402 const gss_ctx_id_t context_handle
,
407 OM_uint32 spnego_gss_export_sec_context
409 OM_uint32
*minor_status
,
410 gss_ctx_id_t
*context_handle
,
411 gss_buffer_t interprocess_token
414 OM_uint32 glue_spnego_gss_export_sec_context
417 OM_uint32
*minor_status
,
418 gss_ctx_id_t
*context_handle
,
419 gss_buffer_t interprocess_token
422 OM_uint32 spnego_gss_import_sec_context
424 OM_uint32
*minor_status
,
425 const gss_buffer_t interprocess_token
,
426 gss_ctx_id_t
*context_handle
428 OM_uint32 glue_spnego_gss_import_sec_context
431 OM_uint32
*minor_status
,
432 const gss_buffer_t interprocess_token
,
433 gss_ctx_id_t
*context_handle
435 #endif /* LEAN_CLIENT */
437 OM_uint32 glue_spnego_gss_inquire_context
440 OM_uint32
*minor_status
,
441 const gss_ctx_id_t context_handle
,
442 gss_name_t
*src_name
,
443 gss_name_t
*targ_name
,
444 OM_uint32
*lifetime_rec
,
446 OM_uint32
*ctx_flags
,
447 int *locally_initiated
,
451 OM_uint32 spnego_gss_inquire_context
453 OM_uint32
*minor_status
,
454 const gss_ctx_id_t context_handle
,
455 gss_name_t
*src_name
,
456 gss_name_t
*targ_name
,
457 OM_uint32
*lifetime_rec
,
459 OM_uint32
*ctx_flags
,
460 int *locally_initiated
,
464 OM_uint32 spnego_gss_wrap_size_limit
466 OM_uint32
*minor_status
,
467 const gss_ctx_id_t context_handle
,
470 OM_uint32 req_output_size
,
471 OM_uint32
*max_input_size
474 OM_uint32 glue_spnego_gss_wrap_size_limit
477 OM_uint32
*minor_status
,
478 const gss_ctx_id_t context_handle
,
481 OM_uint32 req_output_size
,
482 OM_uint32
*max_input_size
485 OM_uint32 spnego_gss_get_mic
487 OM_uint32
*minor_status
,
488 const gss_ctx_id_t context_handle
,
490 const gss_buffer_t message_buffer
,
491 gss_buffer_t message_token
494 OM_uint32 spnego_gss_verify_mic
496 OM_uint32
*minor_status
,
497 const gss_ctx_id_t context_handle
,
498 const gss_buffer_t msg_buffer
,
499 const gss_buffer_t token_buffer
,
504 spnego_gss_inquire_sec_context_by_oid
506 OM_uint32
*minor_status
,
507 const gss_ctx_id_t context_handle
,
508 const gss_OID desired_object
,
509 gss_buffer_set_t
*data_set
513 #if 0 /* SUNW17PACresync - will be needed for full MIT 1.7 resync */
514 OM_uint32 spnego_gss_wrap_aead
516 OM_uint32
*minor_status
,
517 gss_ctx_id_t context_handle
,
520 gss_buffer_t input_assoc_buffer
,
521 gss_buffer_t input_payload_buffer
,
523 gss_buffer_t output_message_buffer
526 OM_uint32 spnego_gss_unwrap_aead
528 OM_uint32
*minor_status
,
529 gss_ctx_id_t context_handle
,
530 gss_buffer_t input_message_buffer
,
531 gss_buffer_t input_assoc_buffer
,
532 gss_buffer_t output_payload_buffer
,
537 OM_uint32 spnego_gss_wrap_iov
539 OM_uint32
*minor_status
,
540 gss_ctx_id_t context_handle
,
544 gss_iov_buffer_desc
*iov
,
548 OM_uint32 spnego_gss_unwrap_iov
550 OM_uint32
*minor_status
,
551 gss_ctx_id_t context_handle
,
553 gss_qop_t
*qop_state
,
554 gss_iov_buffer_desc
*iov
,
558 OM_uint32 spnego_gss_wrap_iov_length
560 OM_uint32
*minor_status
,
561 gss_ctx_id_t context_handle
,
565 gss_iov_buffer_desc
*iov
,
570 spnego_gss_complete_auth_token
572 OM_uint32
*minor_status
,
573 const gss_ctx_id_t context_handle
,
574 gss_buffer_t input_message_buffer
580 * Cloned the krb5_*_error_message and krb5_gss_*_error_info APIs
581 * to give similar functionality to SPNEGO mech.
582 * See new files in this dir:
583 * spnego_disp_status.c
587 typedef int spnego_error_code
;
588 void spnego_set_error_message (spnego_gss_ctx_id_t
, spnego_error_code
, const char *, ...);
589 const char * spnego_get_error_message (spnego_gss_ctx_id_t
, spnego_error_code
);
590 void spnego_free_error_message (spnego_gss_ctx_id_t
, const char *);
591 void spnego_clear_error_message (spnego_gss_ctx_id_t
);
593 void spnego_gss_save_error_info(OM_uint32 minor_code
, spnego_gss_ctx_id_t ctx
);
594 char *spnego_gss_get_error_message(OM_uint32 minor_code
);
595 void spnego_gss_delete_error_info(void *p
);
597 OM_uint32
krb5_gss_display_status2();
602 #endif /* _GSSAPIP_SPNEGO_H_ */