xref: /freebsd/crypto/krb5/src/lib/gssapi/krb5/rel_oid.c (revision f1c4c3daccbaf3820f0e2224de53df12fc952fcc)
1 /* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /* lib/gssapi/krb5/rel_oid.c - Release an OID */
3 /*
4  * Copyright 1995, 2007 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_gss_release_oid(OM_uint32 * minor_status,gss_OID * oid)30 krb5_gss_release_oid(OM_uint32 *minor_status, gss_OID *oid)
31 {
32     /*
33      * The V2 API says the following!
34      *
35      * gss_release_oid[()] will recognize any of the GSSAPI's own OID values,
36      * and will silently ignore attempts to free these OIDs; for other OIDs
37      * it will call the C free() routine for both the OID data and the
38      * descriptor.  This allows applications to freely mix their own heap-
39      * allocated OID values with OIDs returned by GSS-API.
40      */
41     if (krb5_gss_internal_release_oid(minor_status, oid) != GSS_S_COMPLETE) {
42         /* Pawn it off on the generic routine */
43         return(generic_gss_release_oid(minor_status, oid));
44     }
45     else {
46         *oid = GSS_C_NO_OID;
47         *minor_status = 0;
48         return(GSS_S_COMPLETE);
49     }
50 }
51 
52 OM_uint32 KRB5_CALLCONV
krb5_gss_internal_release_oid(OM_uint32 * minor_status,gss_OID * oid)53 krb5_gss_internal_release_oid(OM_uint32 *minor_status, gss_OID *oid)
54 {
55     /*
56      * This function only knows how to release internal OIDs. It will
57      * return GSS_S_CONTINUE_NEEDED for any OIDs it does not recognize.
58      */
59 
60     *minor_status = 0;
61     if ((*oid != gss_mech_krb5) &&
62         (*oid != gss_mech_krb5_old) &&
63         (*oid != gss_mech_krb5_wrong) &&
64         (*oid != gss_mech_iakerb) &&
65         (*oid != gss_nt_krb5_name) &&
66         (*oid != gss_nt_krb5_principal)) {
67         /* We don't know about this OID */
68         return(GSS_S_CONTINUE_NEEDED);
69     }
70     else {
71         *oid = GSS_C_NO_OID;
72         return(GSS_S_COMPLETE);
73     }
74 }
75