Properly implement neg_mechs & GM_USE_MG_CRED
[metze/heimdal/wip.git] / lib / gssapi / krb5 / external.c
index 7f32380e71b931cbd8e6e143c00c2f52ddd64cc3..045d554976978e966b0564429ba12b02452d32d8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan
+ * Copyright (c) 1997 - 2018 Kungliga Tekniska Högskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  * All rights reserved.
  *
@@ -152,47 +152,6 @@ gss_OID_desc GSSAPI_LIB_VARIABLE __gss_c_nt_export_name_oid_desc =
 gss_OID_desc GSSAPI_LIB_VARIABLE __gss_krb5_nt_principal_name_oid_desc =
     {10, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12\x01\x02\x02\x01") };
 
-/*
- *   This name form shall be represented by the Object Identifier {iso(1)
- *   member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
- *   generic(1) user_name(1)}.  The recommended symbolic name for this
- *   type is "GSS_KRB5_NT_USER_NAME".
- */
-
-/*
- *   This name form shall be represented by the Object Identifier {iso(1)
- *   member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
- *   generic(1) machine_uid_name(2)}.  The recommended symbolic name for
- *   this type is "GSS_KRB5_NT_MACHINE_UID_NAME".
- */
-
-/*
- *   This name form shall be represented by the Object Identifier {iso(1)
- *   member-body(2) United States(840) mit(113554) infosys(1) gssapi(2)
- *   generic(1) string_uid_name(3)}.  The recommended symbolic name for
- *   this type is "GSS_KRB5_NT_STRING_UID_NAME".
- */
-
-/*
- *   To support ongoing experimentation, testing, and evolution of the
- *   specification, the Kerberos V5 GSS-API mechanism as defined in this
- *   and any successor memos will be identified with the following Object
- *   Identifier, as defined in RFC-1510, until the specification is
- *   advanced to the level of Proposed Standard RFC:
- *
- *   {iso(1), org(3), dod(5), internet(1), security(5), kerberosv5(2)}
- *
- *   Upon advancement to the level of Proposed Standard RFC, the Kerberos
- *   V5 GSS-API mechanism will be identified by an Object Identifier
- *   having the value:
- *
- *   {iso(1) member-body(2) United States(840) mit(113554) infosys(1)
- *   gssapi(2) krb5(2)}
- */
-
-gss_OID_desc GSSAPI_LIB_VARIABLE __gss_krb5_mechanism_oid_desc =
-    {9, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12\x01\x02\x02") };
-
 /*
  * draft-ietf-cat-iakerb-09, IAKERB:
  *   The mechanism ID for IAKERB proxy GSS-API Kerberos, in accordance
@@ -216,6 +175,153 @@ gss_OID_desc GSSAPI_LIB_VARIABLE __gss_iakerb_min_msg_mechanism_oid_desc =
  * Context for krb5 calls.
  */
 
+static gss_mo_desc krb5_mo[] = {
+    {
+       GSS_C_MA_SASL_MECH_NAME,
+       GSS_MO_MA,
+       "SASL mech name",
+       rk_UNCONST("GS2-KRB5"),
+       _gss_mo_get_ctx_as_string,
+       NULL
+    },
+    {
+       GSS_C_MA_MECH_NAME,
+       GSS_MO_MA,
+       "Mechanism name",
+       rk_UNCONST("KRB5"),
+       _gss_mo_get_ctx_as_string,
+       NULL
+    },
+    {
+       GSS_C_MA_MECH_DESCRIPTION,
+       GSS_MO_MA,
+       "Mechanism description",
+       rk_UNCONST("Heimdal Kerberos 5 mech"),
+       _gss_mo_get_ctx_as_string,
+       NULL
+    },
+    {
+       GSS_C_MA_MECH_CONCRETE,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_ITOK_FRAMED,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_AUTH_INIT,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_AUTH_TARG,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_DELEG_CRED,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_INTEG_PROT,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_CONF_PROT,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_MIC,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_WRAP,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_PROT_READY,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_REPLAY_DET,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_OOS_DET,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_CBINDINGS,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_PFS,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    },
+    {
+       GSS_C_MA_CTX_TRANS,
+       GSS_MO_MA,
+       NULL,
+       NULL,
+       NULL,
+       NULL
+    }
+};
+
 /*
  *
  */
@@ -223,9 +329,9 @@ gss_OID_desc GSSAPI_LIB_VARIABLE __gss_iakerb_min_msg_mechanism_oid_desc =
 static gssapi_mech_interface_desc krb5_mech = {
     GMI_VERSION,
     "kerberos 5",
-    {9, "\x2a\x86\x48\x86\xf7\x12\x01\x02\x02" },
+    {9, rk_UNCONST("\x2a\x86\x48\x86\xf7\x12\x01\x02\x02") },
     0,
-    _gsskrb5_acquire_cred,
+    NULL, /* gm_acquire_cred */
     _gsskrb5_release_cred,
     _gsskrb5_init_sec_context,
     _gsskrb5_accept_sec_context,
@@ -246,7 +352,7 @@ static gssapi_mech_interface_desc krb5_mech = {
     _gsskrb5_inquire_cred,
     _gsskrb5_inquire_context,
     _gsskrb5_wrap_size_limit,
-    _gsskrb5_add_cred,
+    NULL, /* gm_add_cred */
     _gsskrb5_inquire_cred_by_mech,
     _gsskrb5_export_sec_context,
     _gsskrb5_import_sec_context,
@@ -262,9 +368,34 @@ static gssapi_mech_interface_desc krb5_mech = {
     _gk_wrap_iov,
     _gk_unwrap_iov,
     _gk_wrap_iov_length,
-    _gsskrb5_store_cred,
+    NULL, /* gm_store_cred */
     _gsskrb5_export_cred,
-    _gsskrb5_import_cred
+    _gsskrb5_import_cred,
+    _gsskrb5_acquire_cred_from,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    krb5_mo,
+    sizeof(krb5_mo) / sizeof(krb5_mo[0]),
+    _gsskrb5_localname,
+    _gsskrb5_authorize_localname,
+    NULL, /* gm_display_name_ext */
+    NULL, /* gm_inquire_name */
+    NULL, /* gm_get_name_attribute */
+    NULL, /* gm_set_name_attribute */
+    NULL, /* gm_delete_name_attribute */
+    NULL, /* gm_export_name_composite */
+    _gsskrb5_duplicate_cred,
+    _gsskrb5_add_cred_from,
+    _gsskrb5_store_cred_into,
+    NULL, /* gm_query_mechanism_info */
+    NULL, /* gm_query_meta_data */
+    NULL, /* gm_exchange_meta_data */
+    _gsskrb5_store_cred_into2,
+    NULL  /* gm_compat */
 };
 
 gssapi_mech_interface