delete_sec_context.c \
display_name.c \
display_name_ext.c \
+ display_status.c \
duplicate_name.c \
eap_mech.c \
export_name.c \
OM_uint32
gss_display_name(OM_uint32 *minor,
- gss_name_t input_name,
+ gss_name_t name,
gss_buffer_t output_name_buffer,
gss_OID *output_name_type)
{
- GSSEAP_NOT_IMPLEMENTED;
+ OM_uint32 major, tmpMinor;
+ krb5_context krbContext;
+ char *krbName;
+
+ GSSEAP_KRB_INIT(&krbContext);
+
+ output_name_buffer->length = 0;
+ output_name_buffer->value = NULL;
+
+ if (name == GSS_C_NO_NAME) {
+ *minor = EINVAL;
+ return GSS_S_CALL_INACCESSIBLE_READ | GSS_S_BAD_NAME;
+ }
+
+ *minor = krb5_unparse_name(krbContext, name->krbPrincipal, &krbName);
+ if (*minor != 0) {
+ return GSS_S_FAILURE;
+ }
+
+ major = makeStringBuffer(minor, krbName, output_name_buffer);
+ if (GSS_ERROR(major)) {
+ krb5_free_unparsed_name(krbContext, krbName);
+ return major;
+ }
+
+ krb5_free_unparsed_name(krbContext, krbName);
+
+ *output_name_type = (gss_OID)GSS_EAP_NT_PRINCIPAL_NAME;
+
+ return GSS_S_COMPLETE;
}
--- /dev/null
+/*
+ * Copyright (c) 2010, JANET(UK)
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * 3. Neither the name of JANET(UK) nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "gssapiP_eap.h"
+
+OM_uint32
+gss_display_status(OM_uint32 *minor,
+ OM_uint32 status_value,
+ int status_type,
+ gss_OID mech_type,
+ OM_uint32 *message_context,
+ gss_buffer_t status_string)
+{
+ OM_uint32 major, tmpMinor;
+ krb5_context krbContext;
+ const char *errMsg;
+
+ status_string->length = 0;
+ status_string->value = NULL;
+
+ if (mech_type != GSS_C_NO_OID &&
+ !gssEapIsMechanismOid(mech_type)) {
+ return GSS_S_BAD_MECH;
+ }
+
+ if (status_type != GSS_C_MECH_CODE) {
+ /* we rely on the mechglue for GSS_C_GSS_CODE */
+ return GSS_S_BAD_STATUS;
+ }
+
+ /* XXX we need to support RADIUS codes too? */
+ GSSEAP_KRB_INIT(&krbContext);
+
+ errMsg = krb5_get_error_message(krbContext, status_value);
+ if (errMsg != NULL) {
+ major = makeStringBuffer(minor, errMsg, status_string);
+ krb5_free_error_message(krbContext, errMsg);
+ } else {
+ major = GSS_S_COMPLETE;
+ }
+
+ return GSS_S_COMPLETE;
+}
extern "C" {
#endif /* __cplusplus */
-/* preferred mechanism */
-extern const gss_OID_desc *const gss_mech_eap;
+extern const gss_OID_desc *const GSS_EAP_MECHANISM;
+extern const gss_OID_desc *const GSS_EAP_AES128_CTS_HMAC_SHA1_96_MECHANISM;
+extern const gss_OID_desc *const GSS_EAP_AES256_CTS_HMAC_SHA1_96_MECHANISM;
-/* concrete mechanisms */
-extern const gss_OID_desc *const gss_mech_eap_aes128_cts_hmac_sha1_96;
-extern const gss_OID_desc *const gss_mech_eap_aes256_cts_hmac_sha1_96;
+/* name type */
+extern const gss_OID_desc *const GSS_EAP_NT_PRINCIPAL_NAME;
#ifdef __cplusplus
}
return ((uint64_t)load_uint32_be(p) << 32) | load_uint32_be(p + 4);
}
+static OM_uint32
+makeStringBuffer(OM_uint32 *minor,
+ const char *string,
+ gss_buffer_t buffer)
+{
+ size_t len = strlen(string);
+
+ buffer->value = GSSEAP_MALLOC(len + 1);
+ if (buffer->value == NULL) {
+ *minor = ENOMEM;
+ return GSS_S_FAILURE;
+ }
+ memcpy(buffer->value, string, len + 1);
+ buffer->length = len;
+
+ *minor = 0;
+ return GSS_S_COMPLETE;
+}
+
#endif /* _UTIL_H_ */
{ 12, "\x06\x0A\x2B\x06\x01\x04\x01\xA9\x4A\x15\x01\x12" }
};
-const gss_OID_desc *const gss_mech_eap =
+const gss_OID_desc *const GSS_EAP_MECHANISM =
&gssEapConcreteMechs[0];
-const gss_OID_desc *const gss_mech_eap_aes128_cts_hmac_sha1_96 =
+const gss_OID_desc *const GSS_EAP_AES128_CTS_HMAC_SHA1_96_MECHANISM =
&gssEapConcreteMechs[1];
-const gss_OID_desc *const gss_mech_eap_aes256_cts_hmac_sha1_96 =
+const gss_OID_desc *const GSS_EAP_AES256_CTS_HMAC_SHA1_96_MECHANISM =
&gssEapConcreteMechs[2];
int
gssEapIsMechanismOid(const gss_OID oid)
{
- if (oidEqual(oid, gss_mech_eap)) {
+ if (oidEqual(oid, GSS_EAP_MECHANISM)) {
return TRUE;
} else if (oid->length > gssEapMechPrefix.length &&
memcmp(oid->elements, gssEapMechPrefix.elements,
}
if (*pInternalizedOid == GSS_C_NO_OID) {
+ if (oidEqual(oid, GSS_EAP_NT_PRINCIPAL_NAME))
+ *pInternalizedOid = (const gss_OID)GSS_EAP_NT_PRINCIPAL_NAME;
+ }
+
+ if (*pInternalizedOid == GSS_C_NO_OID) {
*pInternalizedOid = oid;
}
}
#include "gssapiP_eap.h"
+static const gss_OID_desc gssEapNtPrincipalName = {
+ /* 1.3.6.1.4.1.5322.21.2.1 */
+ 12, "\x06\x0A\x2B\x06\x01\x04\x01\xA9\x4A\x15\x02\x01"
+};
+
+const gss_OID_desc *const GSS_EAP_NT_PRINCIPAL_NAME =
+ &gssEapNtPrincipalName;
+
OM_uint32
gssEapAllocName(OM_uint32 *minor, gss_name_t *pName)
{