summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2013-03-16 16:51:01 -0400
committerSimo Sorce <simo@redhat.com>2013-03-22 14:14:36 -0400
commit2364627972cb8bd419dc4a52d66eef6adda4124f (patch)
treee4e49c6b87e4afdd06765e8cf06b7abc8f96f0f7
parent01b4fbd08ab869ba612935b1058f211965204282 (diff)
downloadgss-proxy-2364627972cb8bd419dc4a52d66eef6adda4124f.tar.gz
gss-proxy-2364627972cb8bd419dc4a52d66eef6adda4124f.tar.xz
gss-proxy-2364627972cb8bd419dc4a52d66eef6adda4124f.zip
Create helper function to wrap token
Wrap the token in a helper function so that the code can be reused elsewhere.
-rw-r--r--proxy/src/mechglue/gpp_context.c23
-rw-r--r--proxy/src/mechglue/gss_plugin.c29
-rw-r--r--proxy/src/mechglue/gss_plugin.h2
3 files changed, 34 insertions, 20 deletions
diff --git a/proxy/src/mechglue/gpp_context.c b/proxy/src/mechglue/gpp_context.c
index 5a3311b..cb3b172 100644
--- a/proxy/src/mechglue/gpp_context.c
+++ b/proxy/src/mechglue/gpp_context.c
@@ -24,7 +24,6 @@
*/
#include "gss_plugin.h"
-#include <endian.h>
#include <time.h>
OM_uint32 gssi_export_sec_context(OM_uint32 *minor_status,
@@ -91,28 +90,12 @@ OM_uint32 gssi_import_sec_context_by_mech(OM_uint32 *minor_status,
/* NOTE: it makes no sense to import a context remotely atm,
* so we only handle the local case for now. */
- spmech = gpp_special_mech(mech_type);
- if (spmech == GSS_C_NO_OID) {
- maj = GSS_S_FAILURE;
- goto done;
- }
-
- wrap_token.length = sizeof(uint32_t) + spmech->length +
- interprocess_token->length;
- wrap_token.value = malloc(wrap_token.length);
- if (!wrap_token.value) {
- wrap_token.length = 0;
- maj = GSS_S_FAILURE;
+ maj = gpp_wrap_sec_ctx_token(&min, mech_type,
+ interprocess_token, &wrap_token);
+ if (maj != GSS_S_COMPLETE) {
goto done;
}
- len = htobe32(spmech->length);
- memcpy(wrap_token.value, &len, sizeof(uint32_t));
- memcpy(wrap_token.value + sizeof(uint32_t),
- spmech->elements, spmech->length);
- memcpy(wrap_token.value + sizeof(uint32_t) + spmech->length,
- interprocess_token->value, interprocess_token->length);
-
maj = gss_import_sec_context(&min, &wrap_token, &ctx->local);
done:
diff --git a/proxy/src/mechglue/gss_plugin.c b/proxy/src/mechglue/gss_plugin.c
index ac9f678..96df022 100644
--- a/proxy/src/mechglue/gss_plugin.c
+++ b/proxy/src/mechglue/gss_plugin.c
@@ -25,6 +25,7 @@
#include "gss_plugin.h"
#include <signal.h>
+#include <endian.h>
#include <gssapi/gssapi_krb5.h>
#define KRB5_OID_LEN 9
@@ -395,6 +396,34 @@ uint32_t gpp_unmap_error(uint32_t err)
return err;
}
+uint32_t gpp_wrap_sec_ctx_token(uint32_t *minor, gss_OID mech_type,
+ gss_buffer_t token, gss_buffer_t wrap_token)
+{
+ gss_OID spmech;
+ uint32_t len;
+
+ spmech = gpp_special_mech(mech_type);
+ if (spmech == GSS_C_NO_OID) {
+ return GSS_S_FAILURE;
+ }
+
+ wrap_token->length = sizeof(uint32_t) + spmech->length + token->length;
+ wrap_token->value = malloc(wrap_token->length);
+ if (!wrap_token->value) {
+ wrap_token->length = 0;
+ return GSS_S_FAILURE;
+ }
+
+ len = htobe32(spmech->length);
+ memcpy(wrap_token->value, &len, sizeof(uint32_t));
+ memcpy(wrap_token->value + sizeof(uint32_t),
+ spmech->elements, spmech->length);
+ memcpy(wrap_token->value + sizeof(uint32_t) + spmech->length,
+ token->value, token->length);
+
+ return GSS_S_COMPLETE;
+}
+
uint32_t gpp_remote_to_local_ctx(uint32_t *minor, gssx_ctx **remote_ctx,
gss_ctx_id_t *local_ctx)
{
diff --git a/proxy/src/mechglue/gss_plugin.h b/proxy/src/mechglue/gss_plugin.h
index c53eb38..de8e7be 100644
--- a/proxy/src/mechglue/gss_plugin.h
+++ b/proxy/src/mechglue/gss_plugin.h
@@ -81,6 +81,8 @@ const gss_OID gpp_special_mech(const gss_OID mech_type);
gss_OID_set gpp_special_available_mechs(const gss_OID_set mechs);
uint32_t gpp_map_error(uint32_t err);
uint32_t gpp_unmap_error(uint32_t err);
+uint32_t gpp_wrap_sec_ctx_token(uint32_t *minor, gss_OID mech_type,
+ gss_buffer_t token, gss_buffer_t wrap_token);
uint32_t gpp_remote_to_local_ctx(uint32_t *minor, gssx_ctx **remote_ctx,
gss_ctx_id_t *local_ctx);
uint32_t gpp_copy_oid(uint32_t *minor, gss_OID in, gss_OID *out);