|
|
287c72 |
From 8182f9f08b2593ff8749078ffd3daef9bf39a7fe Mon Sep 17 00:00:00 2001
|
|
|
31ace6 |
From: Isaac Boukris <iboukris@gmail.com>
|
|
|
31ace6 |
Date: Fri, 20 Mar 2020 00:17:28 +0100
|
|
|
31ace6 |
Subject: [PATCH] Add channel bindings tests
|
|
|
31ace6 |
|
|
|
31ace6 |
[ghudson@mit.edu: adjusted test program to output channel-bound state
|
|
|
31ace6 |
instead of optionally enforcing it; adjusted tests to check program
|
|
|
31ace6 |
output; split out tests into separate Python script; made cosmetic
|
|
|
31ace6 |
changes]
|
|
|
31ace6 |
|
|
|
31ace6 |
ticket: 8900
|
|
|
31ace6 |
(cherry picked from commit b0b21b6d25b06f3e2b365dfe9dd4c99b3d43bf57)
|
|
|
31ace6 |
[rharwood@redhat.com: .gitignore]
|
|
|
31ace6 |
(cherry picked from commit 3e92520c1417f22447751cd9172d5ab30c2e0ad8)
|
|
|
31ace6 |
---
|
|
|
31ace6 |
src/plugins/gssapi/negoextest/main.c | 18 +++++
|
|
|
31ace6 |
src/tests/gssapi/Makefile.in | 49 ++++++------
|
|
|
31ace6 |
src/tests/gssapi/common.c | 25 ++++--
|
|
|
31ace6 |
src/tests/gssapi/common.h | 9 +++
|
|
|
31ace6 |
src/tests/gssapi/deps | 4 +
|
|
|
31ace6 |
src/tests/gssapi/t_bindings.c | 111 +++++++++++++++++++++++++++
|
|
|
31ace6 |
src/tests/gssapi/t_bindings.py | 43 +++++++++++
|
|
|
31ace6 |
src/tests/gssapi/t_negoex.py | 7 ++
|
|
|
31ace6 |
8 files changed, 237 insertions(+), 29 deletions(-)
|
|
|
31ace6 |
create mode 100644 src/tests/gssapi/t_bindings.c
|
|
|
31ace6 |
create mode 100644 src/tests/gssapi/t_bindings.py
|
|
|
31ace6 |
|
|
|
31ace6 |
diff --git a/src/plugins/gssapi/negoextest/main.c b/src/plugins/gssapi/negoextest/main.c
|
|
|
31ace6 |
index 6c340f41b..72fc5273a 100644
|
|
|
31ace6 |
--- a/src/plugins/gssapi/negoextest/main.c
|
|
|
31ace6 |
+++ b/src/plugins/gssapi/negoextest/main.c
|
|
|
31ace6 |
@@ -57,6 +57,15 @@ gss_init_sec_context(OM_uint32 *minor_status,
|
|
|
31ace6 |
const char *envstr;
|
|
|
31ace6 |
uint8_t hops, mech_last_octet;
|
|
|
31ace6 |
|
|
|
31ace6 |
+ envstr = getenv("GSS_INIT_BINDING");
|
|
|
31ace6 |
+ if (envstr != NULL) {
|
|
|
31ace6 |
+ assert(strlen(envstr) > 0);
|
|
|
31ace6 |
+ assert(input_chan_bindings != GSS_C_NO_CHANNEL_BINDINGS);
|
|
|
31ace6 |
+ assert(strlen(envstr) == input_chan_bindings->application_data.length);
|
|
|
31ace6 |
+ assert(strcmp((char *)input_chan_bindings->application_data.value,
|
|
|
31ace6 |
+ envstr) == 0);
|
|
|
31ace6 |
+ }
|
|
|
31ace6 |
+
|
|
|
31ace6 |
if (input_token == GSS_C_NO_BUFFER || input_token->length == 0) {
|
|
|
31ace6 |
envstr = getenv("HOPS");
|
|
|
31ace6 |
hops = (envstr != NULL) ? atoi(envstr) : 1;
|
|
|
31ace6 |
@@ -112,6 +121,15 @@ gss_accept_sec_context(OM_uint32 *minor_status, gss_ctx_id_t *context_handle,
|
|
|
31ace6 |
uint8_t hops, mech_last_octet;
|
|
|
31ace6 |
const char *envstr;
|
|
|
31ace6 |
|
|
|
31ace6 |
+ envstr = getenv("GSS_ACCEPT_BINDING");
|
|
|
31ace6 |
+ if (envstr != NULL) {
|
|
|
31ace6 |
+ assert(strlen(envstr) > 0);
|
|
|
31ace6 |
+ assert(input_chan_bindings != GSS_C_NO_CHANNEL_BINDINGS);
|
|
|
31ace6 |
+ assert(strlen(envstr) == input_chan_bindings->application_data.length);
|
|
|
31ace6 |
+ assert(strcmp((char *)input_chan_bindings->application_data.value,
|
|
|
31ace6 |
+ envstr) == 0);
|
|
|
31ace6 |
+ }
|
|
|
31ace6 |
+
|
|
|
31ace6 |
/*
|
|
|
31ace6 |
* The unwrapped token sits at the end and is just one byte giving the
|
|
|
31ace6 |
* remaining number of hops. The final octet of the mech encoding should
|
|
|
31ace6 |
diff --git a/src/tests/gssapi/Makefile.in b/src/tests/gssapi/Makefile.in
|
|
|
31ace6 |
index 5cc1e0f58..68c132b79 100644
|
|
|
31ace6 |
--- a/src/tests/gssapi/Makefile.in
|
|
|
31ace6 |
+++ b/src/tests/gssapi/Makefile.in
|
|
|
31ace6 |
@@ -9,33 +9,33 @@ LOCALINCLUDES = -I$(srcdir)/../../lib/gssapi/mechglue \
|
|
|
31ace6 |
-I../../lib/gssapi/generic
|
|
|
31ace6 |
|
|
|
31ace6 |
SRCS= $(srcdir)/ccinit.c $(srcdir)/ccrefresh.c $(srcdir)/common.c \
|
|
|
31ace6 |
- $(srcdir)/t_accname.c $(srcdir)/t_add_cred.c $(srcdir)/t_ccselect.c \
|
|
|
31ace6 |
- $(srcdir)/t_ciflags.c $(srcdir)/t_context.c $(srcdir)/t_credstore.c \
|
|
|
31ace6 |
- $(srcdir)/t_enctypes.c $(srcdir)/t_err.c $(srcdir)/t_export_cred.c \
|
|
|
31ace6 |
- $(srcdir)/t_export_name.c $(srcdir)/t_gssexts.c \
|
|
|
31ace6 |
- $(srcdir)/t_imp_cred.c $(srcdir)/t_imp_name.c $(srcdir)/t_invalid.c \
|
|
|
31ace6 |
- $(srcdir)/t_inq_cred.c $(srcdir)/t_inq_ctx.c \
|
|
|
31ace6 |
+ $(srcdir)/t_accname.c $(srcdir)/t_add_cred.c $(srcdir)/t_bindings.c \
|
|
|
31ace6 |
+ $(srcdir)/t_ccselect.c $(srcdir)/t_ciflags.c $(srcdir)/t_context.c \
|
|
|
31ace6 |
+ $(srcdir)/t_credstore.c $(srcdir)/t_enctypes.c $(srcdir)/t_err.c \
|
|
|
31ace6 |
+ $(srcdir)/t_export_cred.c $(srcdir)/t_export_name.c \
|
|
|
31ace6 |
+ $(srcdir)/t_gssexts.c $(srcdir)/t_imp_cred.c $(srcdir)/t_imp_name.c \
|
|
|
31ace6 |
+ $(srcdir)/t_invalid.c $(srcdir)/t_inq_cred.c $(srcdir)/t_inq_ctx.c \
|
|
|
31ace6 |
$(srcdir)/t_inq_mechs_name.c $(srcdir)/t_iov.c \
|
|
|
31ace6 |
$(srcdir)/t_lifetime.c $(srcdir)/t_namingexts.c $(srcdir)/t_oid.c \
|
|
|
31ace6 |
$(srcdir)/t_pcontok.c $(srcdir)/t_prf.c $(srcdir)/t_s4u.c \
|
|
|
31ace6 |
$(srcdir)/t_s4u2proxy_krb5.c $(srcdir)/t_saslname.c \
|
|
|
31ace6 |
$(srcdir)/t_spnego.c $(srcdir)/t_srcattrs.c
|
|
|
31ace6 |
|
|
|
31ace6 |
-OBJS= ccinit.o ccrefresh.o common.o t_accname.o t_add_cred.o t_ccselect.o \
|
|
|
31ace6 |
- t_ciflags.o t_context.o t_credstore.o t_enctypes.o t_err.o \
|
|
|
31ace6 |
- t_export_cred.o t_export_name.o t_gssexts.o t_imp_cred.o t_imp_name.o \
|
|
|
31ace6 |
- t_invalid.o t_inq_cred.o t_inq_ctx.o t_inq_mechs_name.o t_iov.o \
|
|
|
31ace6 |
- t_lifetime.o t_namingexts.o t_oid.o t_pcontok.o t_prf.o t_s4u.o \
|
|
|
31ace6 |
- t_s4u2proxy_krb5.o t_saslname.o t_spnego.o t_srcattrs.o
|
|
|
31ace6 |
+OBJS= ccinit.o ccrefresh.o common.o t_accname.o t_add_cred.o t_bindings.o \
|
|
|
31ace6 |
+ t_ccselect.o t_ciflags.o t_context.o t_credstore.o t_enctypes.o \
|
|
|
31ace6 |
+ t_err.o t_export_cred.o t_export_name.o t_gssexts.o t_imp_cred.o \
|
|
|
31ace6 |
+ t_imp_name.o t_invalid.o t_inq_cred.o t_inq_ctx.o t_inq_mechs_name.o \
|
|
|
31ace6 |
+ t_iov.o t_lifetime.o t_namingexts.o t_oid.o t_pcontok.o t_prf.o \
|
|
|
31ace6 |
+ t_s4u.o t_s4u2proxy_krb5.o t_saslname.o t_spnego.o t_srcattrs.o
|
|
|
31ace6 |
|
|
|
31ace6 |
COMMON_DEPS= common.o $(GSS_DEPLIBS) $(KRB5_BASE_DEPLIBS)
|
|
|
31ace6 |
COMMON_LIBS= common.o $(GSS_LIBS) $(KRB5_BASE_LIBS)
|
|
|
31ace6 |
|
|
|
31ace6 |
-all: ccinit ccrefresh t_accname t_add_cred t_ccselect t_ciflags t_context \
|
|
|
31ace6 |
- t_credstore t_enctypes t_err t_export_cred t_export_name t_gssexts \
|
|
|
31ace6 |
- t_imp_cred t_imp_name t_invalid t_inq_cred t_inq_ctx t_inq_mechs_name \
|
|
|
31ace6 |
- t_iov t_lifetime t_namingexts t_oid t_pcontok t_prf t_s4u \
|
|
|
31ace6 |
- t_s4u2proxy_krb5 t_saslname t_spnego t_srcattrs
|
|
|
31ace6 |
+all: ccinit ccrefresh t_accname t_add_cred t_bindings t_ccselect t_ciflags \
|
|
|
31ace6 |
+ t_context t_credstore t_enctypes t_err t_export_cred t_export_name \
|
|
|
31ace6 |
+ t_gssexts t_imp_cred t_imp_name t_invalid t_inq_cred t_inq_ctx \
|
|
|
31ace6 |
+ t_inq_mechs_name t_iov t_lifetime t_namingexts t_oid t_pcontok t_prf \
|
|
|
31ace6 |
+ t_s4u t_s4u2proxy_krb5 t_saslname t_spnego t_srcattrs
|
|
|
31ace6 |
|
|
|
31ace6 |
check-unix: t_oid
|
|
|
31ace6 |
$(RUN_TEST) ./t_invalid
|
|
|
31ace6 |
@@ -43,11 +43,12 @@ check-unix: t_oid
|
|
|
31ace6 |
$(RUN_TEST) ./t_prf
|
|
|
31ace6 |
$(RUN_TEST) ./t_imp_name
|
|
|
31ace6 |
|
|
|
31ace6 |
-check-pytests: ccinit ccrefresh t_accname t_add_cred t_ccselect t_ciflags \
|
|
|
31ace6 |
- t_context t_credstore t_enctypes t_err t_export_cred t_export_name \
|
|
|
31ace6 |
- t_imp_cred t_inq_cred t_inq_ctx t_inq_mechs_name t_iov t_lifetime \
|
|
|
31ace6 |
- t_pcontok t_s4u t_s4u2proxy_krb5 t_spnego t_srcattrs
|
|
|
31ace6 |
+check-pytests: ccinit ccrefresh t_accname t_add_cred t_bindings t_ccselect \
|
|
|
31ace6 |
+ t_ciflags t_context t_credstore t_enctypes t_err t_export_cred \
|
|
|
31ace6 |
+ t_export_name t_imp_cred t_inq_cred t_inq_ctx t_inq_mechs_name t_iov \
|
|
|
31ace6 |
+ t_lifetime t_pcontok t_s4u t_s4u2proxy_krb5 t_spnego t_srcattrs
|
|
|
31ace6 |
$(RUNPYTEST) $(srcdir)/t_gssapi.py $(PYTESTFLAGS)
|
|
|
31ace6 |
+ $(RUNPYTEST) $(srcdir)/t_bindings.py $(PYTESTFLAGS)
|
|
|
31ace6 |
$(RUNPYTEST) $(srcdir)/t_ccselect.py $(PYTESTFLAGS)
|
|
|
31ace6 |
$(RUNPYTEST) $(srcdir)/t_client_keytab.py $(PYTESTFLAGS)
|
|
|
31ace6 |
$(RUNPYTEST) $(srcdir)/t_enctypes.py $(PYTESTFLAGS)
|
|
|
31ace6 |
@@ -64,6 +65,8 @@ t_accname: t_accname.o $(COMMON_DEPS)
|
|
|
31ace6 |
$(CC_LINK) -o $@ t_accname.o $(COMMON_LIBS)
|
|
|
31ace6 |
t_add_cred: t_add_cred.o $(COMMON_DEPS)
|
|
|
31ace6 |
$(CC_LINK) -o $@ t_add_cred.o $(COMMON_LIBS)
|
|
|
31ace6 |
+t_bindings: t_bindings.o $(COMMON_DEPS)
|
|
|
31ace6 |
+ $(CC_LINK) -o $@ t_bindings.o $(COMMON_LIBS)
|
|
|
31ace6 |
t_ccselect: t_ccselect.o $(COMMON_DEPS)
|
|
|
31ace6 |
$(CC_LINK) -o $@ t_ccselect.o $(COMMON_LIBS)
|
|
|
31ace6 |
t_ciflags: t_ciflags.o $(COMMON_DEPS)
|
|
|
31ace6 |
@@ -118,8 +121,8 @@ t_srcattrs: t_srcattrs.o $(COMMON_DEPS)
|
|
|
31ace6 |
$(CC_LINK) -o $@ t_srcattrs.o $(COMMON_LIBS)
|
|
|
31ace6 |
|
|
|
31ace6 |
clean:
|
|
|
31ace6 |
- $(RM) ccinit ccrefresh t_accname t_add_cred t_ccselect t_ciflags
|
|
|
31ace6 |
- $(RM) t_context t_credstore t_enctypes t_err t_export_cred
|
|
|
31ace6 |
+ $(RM) ccinit ccrefresh t_accname t_add_cred t_bindings t_ccselect
|
|
|
31ace6 |
+ $(RM) t_ciflags t_context t_credstore t_enctypes t_err t_export_cred
|
|
|
31ace6 |
$(RM) t_export_name t_gssexts t_imp_cred t_imp_name t_invalid
|
|
|
31ace6 |
$(RM) t_inq_cred t_inq_ctx t_inq_mechs_name t_iov t_lifetime
|
|
|
31ace6 |
$(RM) t_namingexts t_oid t_pcontok t_prf t_s4u t_s4u2proxy_krb5
|
|
|
31ace6 |
diff --git a/src/tests/gssapi/common.c b/src/tests/gssapi/common.c
|
|
|
31ace6 |
index 83e9d9bb8..7ba72f7b2 100644
|
|
|
31ace6 |
--- a/src/tests/gssapi/common.c
|
|
|
31ace6 |
+++ b/src/tests/gssapi/common.c
|
|
|
31ace6 |
@@ -115,6 +115,20 @@ establish_contexts(gss_OID imech, gss_cred_id_t icred, gss_cred_id_t acred,
|
|
|
31ace6 |
gss_name_t tname, OM_uint32 flags, gss_ctx_id_t *ictx,
|
|
|
31ace6 |
gss_ctx_id_t *actx, gss_name_t *src_name, gss_OID *amech,
|
|
|
31ace6 |
gss_cred_id_t *deleg_cred)
|
|
|
31ace6 |
+{
|
|
|
31ace6 |
+ return establish_contexts_ex(imech, icred, acred, tname, flags, ictx, actx,
|
|
|
31ace6 |
+ GSS_C_NO_CHANNEL_BINDINGS,
|
|
|
31ace6 |
+ GSS_C_NO_CHANNEL_BINDINGS, NULL, src_name,
|
|
|
31ace6 |
+ amech, deleg_cred);
|
|
|
31ace6 |
+}
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+void
|
|
|
31ace6 |
+establish_contexts_ex(gss_OID imech, gss_cred_id_t icred, gss_cred_id_t acred,
|
|
|
31ace6 |
+ gss_name_t tname, OM_uint32 flags, gss_ctx_id_t *ictx,
|
|
|
31ace6 |
+ gss_ctx_id_t *actx, gss_channel_bindings_t icb,
|
|
|
31ace6 |
+ gss_channel_bindings_t acb, OM_uint32 *aret_flags,
|
|
|
31ace6 |
+ gss_name_t *src_name, gss_OID *amech,
|
|
|
31ace6 |
+ gss_cred_id_t *deleg_cred)
|
|
|
31ace6 |
{
|
|
|
31ace6 |
OM_uint32 minor, imaj, amaj;
|
|
|
31ace6 |
gss_buffer_desc itok, atok;
|
|
|
31ace6 |
@@ -126,17 +140,16 @@ establish_contexts(gss_OID imech, gss_cred_id_t icred, gss_cred_id_t acred,
|
|
|
31ace6 |
for (;;) {
|
|
|
31ace6 |
(void)gss_release_buffer(&minor, &itok);
|
|
|
31ace6 |
imaj = gss_init_sec_context(&minor, icred, ictx, tname, imech, flags,
|
|
|
31ace6 |
- GSS_C_INDEFINITE,
|
|
|
31ace6 |
- GSS_C_NO_CHANNEL_BINDINGS, &atok, NULL,
|
|
|
31ace6 |
- &itok, NULL, NULL);
|
|
|
31ace6 |
+ GSS_C_INDEFINITE, icb, &atok, NULL, &itok,
|
|
|
31ace6 |
+ NULL, NULL);
|
|
|
31ace6 |
check_gsserr("gss_init_sec_context", imaj, minor);
|
|
|
31ace6 |
if (amaj == GSS_S_COMPLETE)
|
|
|
31ace6 |
break;
|
|
|
31ace6 |
|
|
|
31ace6 |
(void)gss_release_buffer(&minor, &atok);
|
|
|
31ace6 |
- amaj = gss_accept_sec_context(&minor, actx, acred, &itok,
|
|
|
31ace6 |
- GSS_C_NO_CHANNEL_BINDINGS, src_name,
|
|
|
31ace6 |
- amech, &atok, NULL, NULL, deleg_cred);
|
|
|
31ace6 |
+ amaj = gss_accept_sec_context(&minor, actx, acred, &itok, acb,
|
|
|
31ace6 |
+ src_name, amech, &atok, aret_flags, NULL,
|
|
|
31ace6 |
+ deleg_cred);
|
|
|
31ace6 |
check_gsserr("gss_accept_sec_context", amaj, minor);
|
|
|
31ace6 |
(void)gss_release_buffer(&minor, &itok);
|
|
|
31ace6 |
if (imaj == GSS_S_COMPLETE)
|
|
|
31ace6 |
diff --git a/src/tests/gssapi/common.h b/src/tests/gssapi/common.h
|
|
|
31ace6 |
index ae11b51d4..a5c8f87e6 100644
|
|
|
31ace6 |
--- a/src/tests/gssapi/common.h
|
|
|
31ace6 |
+++ b/src/tests/gssapi/common.h
|
|
|
31ace6 |
@@ -62,6 +62,15 @@ void establish_contexts(gss_OID imech, gss_cred_id_t icred,
|
|
|
31ace6 |
gss_name_t *src_name, gss_OID *amech,
|
|
|
31ace6 |
gss_cred_id_t *deleg_cred);
|
|
|
31ace6 |
|
|
|
31ace6 |
+/* Establish contexts with channel bindings. */
|
|
|
31ace6 |
+void establish_contexts_ex(gss_OID imech, gss_cred_id_t icred,
|
|
|
31ace6 |
+ gss_cred_id_t acred, gss_name_t tname,
|
|
|
31ace6 |
+ OM_uint32 flags, gss_ctx_id_t *ictx,
|
|
|
31ace6 |
+ gss_ctx_id_t *actx, gss_channel_bindings_t icb,
|
|
|
31ace6 |
+ gss_channel_bindings_t acb, OM_uint32 *aret_flags,
|
|
|
31ace6 |
+ gss_name_t *src_name, gss_OID *amech,
|
|
|
31ace6 |
+ gss_cred_id_t *deleg_cred);
|
|
|
31ace6 |
+
|
|
|
31ace6 |
/* Export *cred to a token, then release *cred and replace it by re-importing
|
|
|
31ace6 |
* the token. */
|
|
|
31ace6 |
void export_import_cred(gss_cred_id_t *cred);
|
|
|
31ace6 |
diff --git a/src/tests/gssapi/deps b/src/tests/gssapi/deps
|
|
|
31ace6 |
index acd0e96f8..73e4d9a74 100644
|
|
|
31ace6 |
--- a/src/tests/gssapi/deps
|
|
|
31ace6 |
+++ b/src/tests/gssapi/deps
|
|
|
31ace6 |
@@ -33,6 +33,10 @@ $(OUTPRE)t_add_cred.$(OBJEXT): $(BUILDTOP)/include/gssapi/gssapi.h \
|
|
|
31ace6 |
$(BUILDTOP)/include/gssapi/gssapi_ext.h $(BUILDTOP)/include/gssapi/gssapi_krb5.h \
|
|
|
31ace6 |
$(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/include/krb5.h \
|
|
|
31ace6 |
common.h t_add_cred.c
|
|
|
31ace6 |
+$(OUTPRE)t_bindings.$(OBJEXT): $(BUILDTOP)/include/gssapi/gssapi.h \
|
|
|
31ace6 |
+ $(BUILDTOP)/include/gssapi/gssapi_ext.h $(BUILDTOP)/include/gssapi/gssapi_krb5.h \
|
|
|
31ace6 |
+ $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/include/krb5.h \
|
|
|
31ace6 |
+ common.h t_bindings.c
|
|
|
31ace6 |
$(OUTPRE)t_ccselect.$(OBJEXT): $(BUILDTOP)/include/gssapi/gssapi.h \
|
|
|
31ace6 |
$(BUILDTOP)/include/gssapi/gssapi_ext.h $(BUILDTOP)/include/gssapi/gssapi_krb5.h \
|
|
|
31ace6 |
$(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/include/krb5.h \
|
|
|
31ace6 |
diff --git a/src/tests/gssapi/t_bindings.c b/src/tests/gssapi/t_bindings.c
|
|
|
31ace6 |
new file mode 100644
|
|
|
31ace6 |
index 000000000..e8906715b
|
|
|
31ace6 |
--- /dev/null
|
|
|
31ace6 |
+++ b/src/tests/gssapi/t_bindings.c
|
|
|
31ace6 |
@@ -0,0 +1,111 @@
|
|
|
31ace6 |
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
31ace6 |
+/*
|
|
|
31ace6 |
+ * Copyright (C) 2020 by Red Hat, Inc.
|
|
|
31ace6 |
+ * All rights reserved.
|
|
|
31ace6 |
+ *
|
|
|
31ace6 |
+ * Redistribution and use in source and binary forms, with or without
|
|
|
31ace6 |
+ * modification, are permitted provided that the following conditions
|
|
|
31ace6 |
+ * are met:
|
|
|
31ace6 |
+ *
|
|
|
31ace6 |
+ * * Redistributions of source code must retain the above copyright
|
|
|
31ace6 |
+ * notice, this list of conditions and the following disclaimer.
|
|
|
31ace6 |
+ *
|
|
|
31ace6 |
+ * * Redistributions in binary form must reproduce the above copyright
|
|
|
31ace6 |
+ * notice, this list of conditions and the following disclaimer in
|
|
|
31ace6 |
+ * the documentation and/or other materials provided with the
|
|
|
31ace6 |
+ * distribution.
|
|
|
31ace6 |
+ *
|
|
|
31ace6 |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
31ace6 |
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
31ace6 |
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
|
31ace6 |
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
|
31ace6 |
+ * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
|
|
31ace6 |
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
31ace6 |
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
31ace6 |
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
31ace6 |
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
|
31ace6 |
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
31ace6 |
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
|
|
31ace6 |
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
31ace6 |
+ */
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+#include <stdio.h>
|
|
|
31ace6 |
+#include <string.h>
|
|
|
31ace6 |
+#include <assert.h>
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+#include "common.h"
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+/*
|
|
|
31ace6 |
+ * Establish contexts (without and with GSS_C_DCE_STYLE) with the default
|
|
|
31ace6 |
+ * initiator name, a specified principal name as target name, initiator
|
|
|
31ace6 |
+ * bindings, and acceptor bindings. If any call is unsuccessful, display an
|
|
|
31ace6 |
+ * error message. Output "yes" or "no" to indicate whether the contexts were
|
|
|
31ace6 |
+ * reported as channel-bound on the acceptor. Exit with status 0 if all
|
|
|
31ace6 |
+ * operations are successful, or 1 if not.
|
|
|
31ace6 |
+ *
|
|
|
31ace6 |
+ * Usage: ./t_bindings [-s] targetname icb acb
|
|
|
31ace6 |
+ *
|
|
|
31ace6 |
+ * An icb or abc value of "-" will not specify channel bindings.
|
|
|
31ace6 |
+ */
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+int
|
|
|
31ace6 |
+main(int argc, char *argv[])
|
|
|
31ace6 |
+{
|
|
|
31ace6 |
+ OM_uint32 minor, flags1, flags2;
|
|
|
31ace6 |
+ gss_name_t target_name;
|
|
|
31ace6 |
+ gss_ctx_id_t ictx, actx;
|
|
|
31ace6 |
+ struct gss_channel_bindings_struct icb_data = {0}, acb_data = {0};
|
|
|
31ace6 |
+ gss_channel_bindings_t icb = GSS_C_NO_CHANNEL_BINDINGS;
|
|
|
31ace6 |
+ gss_channel_bindings_t acb = GSS_C_NO_CHANNEL_BINDINGS;
|
|
|
31ace6 |
+ gss_OID_desc *mech;
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+ argv++;
|
|
|
31ace6 |
+ argc--;
|
|
|
31ace6 |
+ if (*argv != NULL && strcmp(*argv, "-s") == 0) {
|
|
|
31ace6 |
+ mech = &mech_spnego;
|
|
|
31ace6 |
+ argv++;
|
|
|
31ace6 |
+ argc--;
|
|
|
31ace6 |
+ } else {
|
|
|
31ace6 |
+ mech = &mech_krb5;
|
|
|
31ace6 |
+ }
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+ if (argc != 3) {
|
|
|
31ace6 |
+ fprintf(stderr, "Usage: t_bindings [-s] targetname icb acb\n");
|
|
|
31ace6 |
+ return 1;
|
|
|
31ace6 |
+ }
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+ target_name = import_name(argv[0]);
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+ if (strcmp(argv[1], "-") != 0) {
|
|
|
31ace6 |
+ icb_data.application_data.length = strlen(argv[1]);
|
|
|
31ace6 |
+ icb_data.application_data.value = argv[1];
|
|
|
31ace6 |
+ icb = &icb_data;
|
|
|
31ace6 |
+ }
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+ if (strcmp(argv[2], "-") != 0) {
|
|
|
31ace6 |
+ acb_data.application_data.length = strlen(argv[2]);
|
|
|
31ace6 |
+ acb_data.application_data.value = argv[2];
|
|
|
31ace6 |
+ acb = &acb_data;
|
|
|
31ace6 |
+ }
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+ establish_contexts_ex(mech, GSS_C_NO_CREDENTIAL, GSS_C_NO_CREDENTIAL,
|
|
|
31ace6 |
+ target_name, 0, &ictx, &actx, icb, acb, &flags1,
|
|
|
31ace6 |
+ NULL, NULL, NULL);
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+ /* Try again with GSS_C_DCE_STYLE */
|
|
|
31ace6 |
+ (void)gss_delete_sec_context(&minor, &ictx, NULL);
|
|
|
31ace6 |
+ (void)gss_delete_sec_context(&minor, &actx, NULL);
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+ establish_contexts_ex(mech, GSS_C_NO_CREDENTIAL, GSS_C_NO_CREDENTIAL,
|
|
|
31ace6 |
+ target_name, GSS_C_DCE_STYLE, &ictx, &actx, icb, acb,
|
|
|
31ace6 |
+ &flags2, NULL, NULL, NULL);
|
|
|
31ace6 |
+ assert((flags1 & GSS_C_CHANNEL_BOUND_FLAG) ==
|
|
|
31ace6 |
+ (flags2 & GSS_C_CHANNEL_BOUND_FLAG));
|
|
|
31ace6 |
+ printf("%s\n", (flags1 & GSS_C_CHANNEL_BOUND_FLAG) ? "yes" : "no");
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+ (void)gss_delete_sec_context(&minor, &ictx, NULL);
|
|
|
31ace6 |
+ (void)gss_delete_sec_context(&minor, &actx, NULL);
|
|
|
31ace6 |
+ (void)gss_release_name(&minor, &target_name);
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+ return 0;
|
|
|
31ace6 |
+}
|
|
|
31ace6 |
diff --git a/src/tests/gssapi/t_bindings.py b/src/tests/gssapi/t_bindings.py
|
|
|
31ace6 |
new file mode 100644
|
|
|
31ace6 |
index 000000000..f377977b6
|
|
|
31ace6 |
--- /dev/null
|
|
|
31ace6 |
+++ b/src/tests/gssapi/t_bindings.py
|
|
|
31ace6 |
@@ -0,0 +1,43 @@
|
|
|
31ace6 |
+from k5test import *
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+realm = K5Realm()
|
|
|
31ace6 |
+server = 'p:' + realm.host_princ
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+mark('krb5 channel bindings')
|
|
|
31ace6 |
+realm.run(['./t_bindings', server, '-', '-'], expected_msg='no')
|
|
|
31ace6 |
+realm.run(['./t_bindings', server, 'a', '-'], expected_msg='no')
|
|
|
31ace6 |
+realm.run(['./t_bindings', server, 'a', 'a'], expected_msg='yes')
|
|
|
31ace6 |
+realm.run(['./t_bindings', server, '-', 'a'], expected_msg='no')
|
|
|
31ace6 |
+realm.run(['./t_bindings', server, 'a', 'x'],
|
|
|
31ace6 |
+ expected_code=1, expected_msg='Incorrect channel bindings')
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+mark('SPNEGO channel bindings')
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', server, '-', '-'], expected_msg='no')
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', server, 'a', '-'], expected_msg='no')
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', server, 'a', 'a'], expected_msg='yes')
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', server, '-', 'a'], expected_msg='no')
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', server, 'a', 'x'],
|
|
|
31ace6 |
+ expected_code=1, expected_msg='Incorrect channel bindings')
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+client_aware_conf = {'libdefaults': {'client_aware_channel_bindings': 'true'}}
|
|
|
31ace6 |
+e = realm.special_env('cb_aware', False, krb5_conf=client_aware_conf)
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+mark('krb5 client_aware_channel_bindings')
|
|
|
31ace6 |
+realm.run(['./t_bindings', server, '-', '-'], env=e, expected_msg='no')
|
|
|
31ace6 |
+realm.run(['./t_bindings', server, 'a', '-'], env=e, expected_msg='no')
|
|
|
31ace6 |
+realm.run(['./t_bindings', server, 'a', 'a'], env=e, expected_msg='yes')
|
|
|
31ace6 |
+realm.run(['./t_bindings', server, '-', 'a'], env=e,
|
|
|
31ace6 |
+ expected_code=1, expected_msg='Incorrect channel bindings')
|
|
|
31ace6 |
+realm.run(['./t_bindings', server, 'a', 'x'], env=e,
|
|
|
31ace6 |
+ expected_code=1, expected_msg='Incorrect channel bindings')
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+mark('SPNEGO client_aware_channel_bindings')
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', server, '-', '-'], env=e, expected_msg='no')
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', server, 'a', '-'], env=e, expected_msg='no')
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', server, 'a', 'a'], env=e, expected_msg='yes')
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', server, '-', 'a'], env=e,
|
|
|
31ace6 |
+ expected_code=1, expected_msg='Incorrect channel bindings')
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', server, 'a', 'x'], env=e,
|
|
|
31ace6 |
+ expected_code=1, expected_msg='Incorrect channel bindings')
|
|
|
31ace6 |
+
|
|
|
31ace6 |
+success('channel bindings tests')
|
|
|
31ace6 |
diff --git a/src/tests/gssapi/t_negoex.py b/src/tests/gssapi/t_negoex.py
|
|
|
31ace6 |
index 88470d2fa..a218899c4 100644
|
|
|
31ace6 |
--- a/src/tests/gssapi/t_negoex.py
|
|
|
31ace6 |
+++ b/src/tests/gssapi/t_negoex.py
|
|
|
31ace6 |
@@ -139,4 +139,11 @@ msgs = ('sending [3]AP_REQUEST', 'sending [7]CHALLENGE', 'sending [8]VERIFY',
|
|
|
31ace6 |
'sending [11]CHALLENGE', 'sending [12]VERIFY', 'sending [13]VERIFY')
|
|
|
31ace6 |
test({'HOPS': '4', 'KEY': 'accept-always'}, expected_trace=())
|
|
|
31ace6 |
|
|
|
31ace6 |
+mark('channel bindings')
|
|
|
31ace6 |
+e = realm.env.copy()
|
|
|
31ace6 |
+e.update({'HOPS': '1', 'GSS_INIT_BINDING': 'a', 'GSS_ACCEPT_BINDING': 'b'})
|
|
|
31ace6 |
+# The test mech will verify that the bindings are communicated to the
|
|
|
31ace6 |
+# mech, but does not set the channel-bound flag.
|
|
|
31ace6 |
+realm.run(['./t_bindings', '-s', 'h:host', 'a', 'b'], env=e, expected_msg='no')
|
|
|
31ace6 |
+
|
|
|
31ace6 |
success('NegoEx tests')
|