xref: /freebsd/crypto/krb5/src/lib/gssapi/krb5/inq_names.c (revision f1c4c3daccbaf3820f0e2224de53df12fc952fcc)
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* lib/gssapi/krb5/inq_names.c - Return nametypes supported by krb5 mech */
3 /*
4  * Copyright 1995 by the Massachusetts Institute of Technology.
5  * All Rights Reserved.
6  *
7  * Export of this software from the United States of America may
8  *   require a specific license from the United States Government.
9  *   It is the responsibility of any person or organization contemplating
10  *   export to obtain such a license before exporting.
11  *
12  * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
13  * distribute this software and its documentation for any purpose and
14  * without fee is hereby granted, provided that the above copyright
15  * notice appear in all copies and that both that copyright notice and
16  * this permission notice appear in supporting documentation, and that
17  * the name of M.I.T. not be used in advertising or publicity pertaining
18  * to distribution of the software without specific, written prior
19  * permission.  Furthermore if you modify this software you must label
20  * your software as modified software and not distribute it in such a
21  * fashion that it might be confused with the original M.I.T. software.
22  * M.I.T. makes no representations about the suitability of
23  * this software for any purpose.  It is provided "as is" without express
24  * or implied warranty.
25  */
26 
27 #include "gssapiP_krb5.h"
28 
29 OM_uint32 KRB5_CALLCONV
krb5_gss_inquire_names_for_mech(OM_uint32 * minor_status,gss_OID mechanism,gss_OID_set * name_types)30 krb5_gss_inquire_names_for_mech(OM_uint32 *minor_status, gss_OID mechanism,
31                                 gss_OID_set *name_types)
32 {
33     OM_uint32   major, minor;
34 
35     /*
36      * We only know how to handle our own mechanism.
37      */
38     if ((mechanism != GSS_C_NULL_OID) &&
39         !g_OID_equal(gss_mech_krb5, mechanism) &&
40         !g_OID_equal(gss_mech_krb5_old, mechanism) &&
41         !g_OID_equal(gss_mech_krb5_wrong, mechanism) &&
42         !g_OID_equal(gss_mech_iakerb, mechanism)) {
43         *minor_status = 0;
44         return(GSS_S_BAD_MECH);
45     }
46 
47     /* We're okay.  Create an empty OID set */
48     major = generic_gss_create_empty_oid_set(minor_status, name_types);
49     if (major == GSS_S_COMPLETE) {
50         /* Now add our members. */
51         if (
52             ((major = generic_gss_add_oid_set_member(minor_status,
53                                                      gss_nt_user_name,
54                                                      name_types)
55             ) == GSS_S_COMPLETE) &&
56             ((major = generic_gss_add_oid_set_member(minor_status,
57                                                      gss_nt_machine_uid_name,
58                                                      name_types)
59             ) == GSS_S_COMPLETE) &&
60             ((major = generic_gss_add_oid_set_member(minor_status,
61                                                      gss_nt_string_uid_name,
62                                                      name_types)
63             ) == GSS_S_COMPLETE) &&
64             ((major = generic_gss_add_oid_set_member(minor_status,
65                                                      gss_nt_service_name,
66                                                      name_types)
67             ) == GSS_S_COMPLETE) &&
68             ((major = generic_gss_add_oid_set_member(minor_status,
69                                                      gss_nt_service_name_v2,
70                                                      name_types)
71             ) == GSS_S_COMPLETE) &&
72             ((major = generic_gss_add_oid_set_member(minor_status,
73                                                      gss_nt_exported_name,
74                                                      name_types)
75             ) == GSS_S_COMPLETE) &&
76             ((major = generic_gss_add_oid_set_member(minor_status,
77                                                      gss_nt_krb5_name,
78                                                      name_types)
79             ) == GSS_S_COMPLETE) &&
80             ((major = generic_gss_add_oid_set_member(minor_status,
81                                                      GSS_C_NT_COMPOSITE_EXPORT,
82                                                      name_types)
83             ) == GSS_S_COMPLETE)
84         ) {
85             major = generic_gss_add_oid_set_member(minor_status,
86                                                    gss_nt_krb5_principal,
87                                                    name_types);
88         }
89 
90         /*
91          * If we choked, then release the set, but don't overwrite the minor
92          * status with the release call.
93          */
94         if (major != GSS_S_COMPLETE)
95             (void) generic_gss_release_oid_set(&minor, name_types);
96     }
97     return(major);
98 }
99