1226031Sstas/* 2226031Sstas * Copyright (c) 2006 Kungliga Tekniska H�gskolan 3226031Sstas * (Royal Institute of Technology, Stockholm, Sweden). 4226031Sstas * All rights reserved. 5226031Sstas * 6226031Sstas * Portions Copyright (c) 2009 Apple Inc. All rights reserved. 7226031Sstas * 8226031Sstas * Redistribution and use in source and binary forms, with or without 9226031Sstas * modification, are permitted provided that the following conditions 10226031Sstas * are met: 11226031Sstas * 12226031Sstas * 1. Redistributions of source code must retain the above copyright 13226031Sstas * notice, this list of conditions and the following disclaimer. 14226031Sstas * 15226031Sstas * 2. Redistributions in binary form must reproduce the above copyright 16226031Sstas * notice, this list of conditions and the following disclaimer in the 17226031Sstas * documentation and/or other materials provided with the distribution. 18226031Sstas * 19226031Sstas * 3. Neither the name of the Institute nor the names of its contributors 20226031Sstas * may be used to endorse or promote products derived from this software 21226031Sstas * without specific prior written permission. 22226031Sstas * 23226031Sstas * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 24226031Sstas * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25226031Sstas * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26226031Sstas * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 27226031Sstas * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28226031Sstas * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29226031Sstas * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30226031Sstas * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31226031Sstas * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32226031Sstas * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33226031Sstas * SUCH DAMAGE. 34226031Sstas */ 35226031Sstas 36226031Sstas#include "ntlm.h" 37226031Sstas 38226031SstasOM_uint32 GSSAPI_CALLCONV 39226031Sstas_gss_ntlm_inquire_sec_context_by_oid(OM_uint32 *minor_status, 40226031Sstas const gss_ctx_id_t context_handle, 41226031Sstas const gss_OID desired_object, 42226031Sstas gss_buffer_set_t *data_set) 43226031Sstas{ 44226031Sstas ntlm_ctx ctx = (ntlm_ctx)context_handle; 45226031Sstas 46226031Sstas if (ctx == NULL) { 47226031Sstas *minor_status = 0; 48226031Sstas return GSS_S_NO_CONTEXT; 49226031Sstas } 50226031Sstas 51226031Sstas if (gss_oid_equal(desired_object, GSS_NTLM_GET_SESSION_KEY_X) || 52226031Sstas gss_oid_equal(desired_object, GSS_C_INQ_SSPI_SESSION_KEY)) { 53226031Sstas gss_buffer_desc value; 54226031Sstas 55226031Sstas value.length = ctx->sessionkey.length; 56226031Sstas value.value = ctx->sessionkey.data; 57226031Sstas 58226031Sstas return gss_add_buffer_set_member(minor_status, 59226031Sstas &value, 60226031Sstas data_set); 61226031Sstas } else if (gss_oid_equal(desired_object, GSS_C_INQ_WIN2K_PAC_X)) { 62226031Sstas if (ctx->pac.length == 0) { 63226031Sstas *minor_status = ENOENT; 64226031Sstas return GSS_S_FAILURE; 65226031Sstas } 66226031Sstas 67226031Sstas return gss_add_buffer_set_member(minor_status, 68226031Sstas &ctx->pac, 69226031Sstas data_set); 70226031Sstas 71226031Sstas } else if (gss_oid_equal(desired_object, GSS_C_NTLM_AVGUEST)) { 72226031Sstas gss_buffer_desc value; 73226031Sstas uint32_t num; 74226031Sstas 75226031Sstas if (ctx->kcmflags & KCM_NTLM_FLAG_AV_GUEST) 76226031Sstas num = 1; 77226031Sstas else 78226031Sstas num = 0; 79226031Sstas 80226031Sstas value.length = sizeof(num); 81226031Sstas value.value = # 82226031Sstas 83226031Sstas return gss_add_buffer_set_member(minor_status, 84226031Sstas &value, 85226031Sstas data_set); 86226031Sstas } else { 87226031Sstas *minor_status = 0; 88226031Sstas return GSS_S_FAILURE; 89226031Sstas } 90226031Sstas} 91