diff options
author | Günther Deschner <gdeschner@redhat.com> | 2012-08-24 14:50:55 +0200 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2012-08-31 15:40:14 -0400 |
commit | ceb608e4f18764c97ef02573187c0c0590cbaace (patch) | |
tree | 4a709d00237356e55fe765fd4ab1ae3301797b23 /proxy/src | |
parent | 6455b93e424b0999836a590548650c56e25e017f (diff) | |
download | gss-proxy-ceb608e4f18764c97ef02573187c0c0590cbaace.tar.gz gss-proxy-ceb608e4f18764c97ef02573187c0c0590cbaace.tar.xz gss-proxy-ceb608e4f18764c97ef02573187c0c0590cbaace.zip |
Implement gp_wrap().
Acked-by: Simo Sorce <simo@redhat.com>
Diffstat (limited to 'proxy/src')
-rw-r--r-- | proxy/src/gp_rpc_process.c | 4 | ||||
-rw-r--r-- | proxy/src/gp_rpc_wrap.c | 135 |
2 files changed, 135 insertions, 4 deletions
diff --git a/proxy/src/gp_rpc_process.c b/proxy/src/gp_rpc_process.c index f89c673..c294a44 100644 --- a/proxy/src/gp_rpc_process.c +++ b/proxy/src/gp_rpc_process.c @@ -390,10 +390,6 @@ int gp_store_cred(gp_exec_std_args) return 0; } -int gp_wrap(gp_exec_std_args) -{ - return 0; -} int gp_unwrap(gp_exec_std_args) { return 0; diff --git a/proxy/src/gp_rpc_wrap.c b/proxy/src/gp_rpc_wrap.c new file mode 100644 index 0000000..e8ef530 --- /dev/null +++ b/proxy/src/gp_rpc_wrap.c @@ -0,0 +1,135 @@ +/* + 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 "gp_rpc_process.h" +#include <gssapi/gssapi.h> + +int gp_wrap(struct gssproxy_ctx *gpctx, + struct gp_service *gpsvc, + union gp_rpc_arg *arg, + union gp_rpc_res *res) +{ + gss_buffer_desc input_message_buffer = GSS_C_EMPTY_BUFFER; + gss_buffer_desc output_message_buffer = GSS_C_EMPTY_BUFFER; + gss_ctx_id_t context_handle = GSS_C_NO_CONTEXT; + struct gssx_arg_wrap *wa; + struct gssx_res_wrap *wr; + uint32_t ret_maj; + uint32_t ret_min; + int ret; + int exp_ctx_type; + int conf_state = 0; + + wa = &arg->wrap; + wr = &res->wrap; + + exp_ctx_type = gp_get_exported_context_type(&wa->call_ctx); + if (exp_ctx_type == -1) { + ret_maj = GSS_S_FAILURE; + ret_min = EINVAL; + goto done; + } + + ret_maj = gp_import_gssx_to_ctx_id(&ret_min, 0, + &wa->context_handle, + &context_handle); + if (ret_maj) { + goto done; + } + + /* apparently it is ok to send an empty message, in that case we dont need + * to bother to do any conversion - gd */ + if ((wa->message_buffer.message_buffer_len > 0) && + (wa->message_buffer.message_buffer_val != NULL)) { + gp_conv_gssx_to_buffer(&wa->message_buffer.message_buffer_val[0], + &input_message_buffer); + } + + ret_maj = gss_wrap(&ret_min, + context_handle, + wa->conf_req, + wa->qop_state, + &input_message_buffer, + &conf_state, + &output_message_buffer); + if (ret_maj) { + goto done; + } + + wr->context_handle = calloc(1, sizeof(gssx_ctx)); + if (!wr->context_handle) { + ret_maj = GSS_S_FAILURE; + ret_min = ENOMEM; + goto done; + } + + ret_maj = gp_export_ctx_id_to_gssx(&ret_min, exp_ctx_type, + &context_handle, wr->context_handle); + if (ret_maj) { + goto done; + } + + wr->qop_state = malloc(sizeof(gssx_qop)); + if (!wr->qop_state) { + ret_maj = GSS_S_FAILURE; + ret_min = ENOMEM; + goto done; + } + *wr->qop_state = wa->qop_state; + + wr->conf_state = malloc(sizeof(bool_t)); + if (!wr->conf_state) { + ret_maj = GSS_S_FAILURE; + ret_min = ENOMEM; + goto done; + } + *wr->conf_state = conf_state; + + wr->token_buffer.token_buffer_val = calloc(1, sizeof(gssx_buffer)); + if (!wr->token_buffer.token_buffer_val) { + ret_maj = GSS_S_FAILURE; + ret_min = ENOMEM; + goto done; + } + wr->token_buffer.token_buffer_len = 1; + + ret = gp_conv_buffer_to_gssx(&output_message_buffer, + &wr->token_buffer.token_buffer_val[0]); + if (ret ) { + ret_maj = GSS_S_FAILURE; + ret_min = ret; + goto done; + } + + ret_maj = GSS_S_COMPLETE; + ret_min = 0; + +done: + ret = gp_conv_status_to_gssx(&wa->call_ctx, ret_maj, ret_min, + GSS_C_NO_OID, &wr->status); + gss_release_buffer(&ret_min, &output_message_buffer); + return ret; +} |