xref: /freebsd/crypto/krb5/src/lib/gssapi/mechglue/g_inq_context_oid.c (revision 7f2fe78b9dd5f51c821d771b63d2e096f6fd49e9)
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 
25 /* Glue routine for gss_inquire_sec_context_by_oid */
26 
27 #include "mglueP.h"
28 
29 OM_uint32 KRB5_CALLCONV
gss_inquire_sec_context_by_oid(OM_uint32 * minor_status,const gss_ctx_id_t context_handle,const gss_OID desired_object,gss_buffer_set_t * data_set)30 gss_inquire_sec_context_by_oid (OM_uint32 *minor_status,
31 	                        const gss_ctx_id_t context_handle,
32 	                        const gss_OID desired_object,
33 	                        gss_buffer_set_t *data_set)
34 {
35     OM_uint32		status;
36     gss_union_ctx_id_t	ctx;
37     gss_mechanism	mech;
38 
39     if (minor_status != NULL)
40 	*minor_status = 0;
41 
42     if (data_set != NULL)
43 	*data_set = GSS_C_NO_BUFFER_SET;
44 
45     if (minor_status == NULL || data_set == NULL)
46 	return GSS_S_CALL_INACCESSIBLE_WRITE;
47 
48     if (context_handle == GSS_C_NO_CONTEXT)
49 	return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_NO_CONTEXT;
50 
51     /*
52      * select the approprate underlying mechanism routine and
53      * call it.
54      */
55 
56     ctx = (gss_union_ctx_id_t) context_handle;
57     mech = gssint_get_mechanism (ctx->mech_type);
58 
59     if (mech != NULL) {
60 	if (mech->gss_inquire_sec_context_by_oid != NULL) {
61 	    status = mech->gss_inquire_sec_context_by_oid(minor_status,
62 							  ctx->internal_ctx_id,
63 							  desired_object,
64 							  data_set);
65 	    if (status != GSS_S_COMPLETE)
66 		map_error(minor_status, mech);
67 	} else
68 	    status = GSS_S_UNAVAILABLE;
69 
70 	return status;
71     }
72 
73     return GSS_S_BAD_MECH;
74 }
75