gsasl  2.2.1
gs2helper.c
Go to the documentation of this file.
1 /* gs2helper.c --- GS2 helper functions common to client and server.
2  * Copyright (C) 2010-2024 Simon Josefsson
3  *
4  * This file is part of GNU SASL Library.
5  *
6  * GNU SASL Library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License
8  * as published by the Free Software Foundation; either version 2.1 of
9  * the License, or (at your option) any later version.
10  *
11  * GNU SASL Library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with GNU SASL Library; if not, write to the Free
18  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include <config.h>
24 
25 /* Get strcmp. */
26 #include <string.h>
27 
28 /* Get malloc, free. */
29 #include <stdlib.h>
30 
31 /* Get specification. */
32 #include "gs2helper.h"
33 
34 /* Populate mech_oid with OID for the current SASL mechanism name. A
35  bit silly given that we only support Kerberos V5 today, but will be
36  useful when that changes. */
37 int
38 gs2_get_oid (Gsasl_session *sctx, gss_OID *mech_oid)
39 {
40  gss_buffer_desc sasl_mech_name;
41  OM_uint32 maj_stat, min_stat;
42 
43  sasl_mech_name.value = (void *) gsasl_mechanism_name (sctx);
44  if (!sasl_mech_name.value)
46  sasl_mech_name.length = strlen (sasl_mech_name.value);
47 
48  maj_stat = gss_inquire_mech_for_saslname (&min_stat, &sasl_mech_name,
49  mech_oid);
50  if (GSS_ERROR (maj_stat))
52 
53  return GSASL_OK;
54 }
int gs2_get_oid(Gsasl_session *sctx, gss_OID *mech_oid)
Definition: gs2helper.c:38
@ GSASL_OK
Definition: gsasl.h:129
@ GSASL_GSSAPI_INQUIRE_MECH_FOR_SASLNAME_ERROR
Definition: gsasl.h:170
@ GSASL_AUTHENTICATION_ERROR
Definition: gsasl.h:138
_GSASL_API const char * gsasl_mechanism_name(Gsasl_session *sctx)
Definition: mechname.c:39