summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGünther Deschner <gdeschner@redhat.com>2012-07-27 22:11:39 +0200
committerSimo Sorce <simo@redhat.com>2012-08-28 08:25:08 +0200
commitb856e3501d1c25f48db69826ba09c996445d75d0 (patch)
treecbfa3cf0cae7be4ac1f1ffaff1b65eb23c0dbfa0
parentbb778a5e93df93606597c4e8feaab1b817566a3f (diff)
downloadgss-proxy-b856e3501d1c25f48db69826ba09c996445d75d0.tar.gz
gss-proxy-b856e3501d1c25f48db69826ba09c996445d75d0.tar.xz
gss-proxy-b856e3501d1c25f48db69826ba09c996445d75d0.zip
Implement gpm_verify_mic().
-rw-r--r--proxy/Makefile.am1
-rw-r--r--proxy/src/client/gpm_verify_mic.c85
-rw-r--r--proxy/src/client/gssapi_gpm.h5
3 files changed, 91 insertions, 0 deletions
diff --git a/proxy/Makefile.am b/proxy/Makefile.am
index 7cd1277..9f29cd3 100644
--- a/proxy/Makefile.am
+++ b/proxy/Makefile.am
@@ -92,6 +92,7 @@ GP_MECHGLUE_OBJ = \
src/client/gpm_init_sec_context.c \
src/client/gpm_inquire_context.c \
src/client/gpm_get_mic.c \
+ src/client/gpm_verify_mic.c \
src/client/gpm_common.c
dist_noinst_HEADERS = \
diff --git a/proxy/src/client/gpm_verify_mic.c b/proxy/src/client/gpm_verify_mic.c
new file mode 100644
index 0000000..8b438ac
--- /dev/null
+++ b/proxy/src/client/gpm_verify_mic.c
@@ -0,0 +1,85 @@
+/*
+ GSS-PROXY
+
+ Copyright (C) 2011 Red Hat, Inc.
+ Copyright (C) 2011 Simo Sorce <simo.sorce@redhat.com>
+ Copyright (C) 2012 Guenther Deschner <guenther.deschner@redhat.com>
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include "gssapi_gpm.h"
+#include "src/gp_conv.h"
+
+OM_uint32 gpm_verify_mic(OM_uint32 *minor_status,
+ gssx_ctx *context_handle,
+ gss_buffer_t message_buffer,
+ gss_buffer_t message_token,
+ gss_qop_t *qop_state)
+{
+ union gp_rpc_arg uarg;
+ union gp_rpc_res ures;
+ gssx_arg_verify_mic *arg = &uarg.verify_mic;
+ gssx_res_verify_mic *res = &ures.verify_mic;
+ uint32_t ret_min = 0;
+ uint32_t ret_maj = 0;
+ int ret = 0;
+
+ memset(&uarg, 0, sizeof(union gp_rpc_arg));
+ memset(&ures, 0, sizeof(union gp_rpc_res));
+
+ /* format request */
+ /* NOTE: the final free will also release the old context */
+ arg->context_handle = *context_handle;
+ gp_conv_buffer_to_gssx(message_buffer, &arg->message_buffer);
+ gp_conv_buffer_to_gssx(message_token, &arg->token_buffer);
+
+ /* execute proxy request */
+ ret = gpm_make_call(GSSX_VERIFY, &uarg, &ures);
+ if (ret) {
+ ret_maj = GSS_S_FAILURE;
+ ret_min = ret;
+ goto done;
+ }
+
+ /* Check and save error status */
+ if (res->status.major_status) {
+ gpm_save_status(&res->status);
+ ret_min = res->status.minor_status;
+ ret_maj = res->status.major_status;
+ goto done;
+ }
+
+ /* Immediately steal the new context on success.
+ * NOTE: We do not want it to be freed by xdr_free, so copy the contents
+ * and cear up the structure to be freed so contents are not freed. */
+ if (res->context_handle) {
+ *context_handle = *res->context_handle;
+ memset(res->context_handle, 0, sizeof(gssx_ctx));
+ }
+
+ if (qop_state) {
+ *qop_state = *res->qop_state;
+ }
+
+done:
+ gpm_free_xdrs(GSSX_VERIFY, &uarg, &ures);
+ *minor_status = ret_min;
+ return ret_maj;
+}
diff --git a/proxy/src/client/gssapi_gpm.h b/proxy/src/client/gssapi_gpm.h
index f67d5ea..2747663 100644
--- a/proxy/src/client/gssapi_gpm.h
+++ b/proxy/src/client/gssapi_gpm.h
@@ -191,5 +191,10 @@ OM_uint32 gpm_get_mic(OM_uint32 *minor_status,
gss_qop_t qop_req,
gss_buffer_t message_buffer,
gss_buffer_t message_token);
+OM_uint32 gpm_verify_mic(OM_uint32 *minor_status,
+ gssx_ctx *context_handle,
+ gss_buffer_t message_buffer,
+ gss_buffer_t message_token,
+ gss_qop_t *qop_state);
#endif /* _GSSAPI_GPM_H_ */