xref: /freebsd/crypto/krb5/src/lib/gssapi/mechglue/g_mech_invoke.c (revision b670c9bafc0e31c7609969bf374b2e80bdc00211)
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 gssspi_mech_invoke */
26 
27 #include "mglueP.h"
28 #ifdef HAVE_STDLIB_H
29 #include <stdlib.h>
30 #endif
31 #include <string.h>
32 #include <errno.h>
33 
34 OM_uint32 KRB5_CALLCONV
35 gssspi_mech_invoke (OM_uint32 *minor_status,
36 		    const gss_OID desired_mech,
37 		    const gss_OID desired_object,
38 		    gss_buffer_t value)
39 {
40     OM_uint32		status;
41     gss_OID		selected_mech = GSS_C_NO_OID;
42     gss_mechanism	mech;
43 
44     if (minor_status == NULL)
45 	return GSS_S_CALL_INACCESSIBLE_WRITE;
46 
47     *minor_status = 0;
48 
49     /*
50      * select the approprate underlying mechanism routine and
51      * call it.
52      */
53 
54     status = gssint_select_mech_type(minor_status, desired_mech,
55 				     &selected_mech);
56     if (status != GSS_S_COMPLETE)
57 	return status;
58 
59     mech = gssint_get_mechanism(selected_mech);
60     if (mech == NULL || mech->gssspi_mech_invoke == NULL) {
61 	return GSS_S_BAD_MECH;
62     }
63 
64     status = mech->gssspi_mech_invoke(minor_status,
65 				      gssint_get_public_oid(selected_mech),
66 				      desired_object,
67 				      value);
68     if (status != GSS_S_COMPLETE)
69 	map_error(minor_status, mech);
70 
71     return status;
72 }
73