summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2012-01-30 14:53:16 -0500
committerSimo Sorce <simo@redhat.com>2012-02-01 17:56:34 -0500
commit5ece0443a85a0c6339c5fed6b7d1e2f6a214356f (patch)
tree778d7becdcc3bbb2b64cbc937335a44f0d80603f
parentbbd84e44a8b6a8d9e54fd8d1c53757fac189df93 (diff)
downloadgss-proxy-5ece0443a85a0c6339c5fed6b7d1e2f6a214356f.tar.gz
gss-proxy-5ece0443a85a0c6339c5fed6b7d1e2f6a214356f.tar.xz
gss-proxy-5ece0443a85a0c6339c5fed6b7d1e2f6a214356f.zip
Add helper to convert OID sets
-rw-r--r--proxy/src/gp_conv.c73
-rw-r--r--proxy/src/gp_conv.h3
2 files changed, 76 insertions, 0 deletions
diff --git a/proxy/src/gp_conv.c b/proxy/src/gp_conv.c
index 06e0042..c5a96dc 100644
--- a/proxy/src/gp_conv.c
+++ b/proxy/src/gp_conv.c
@@ -543,3 +543,76 @@ done:
return ret;
}
+int gp_conv_gssx_to_oid_set(gssx_OID_set *in, gss_OID_set *out)
+{
+ gss_OID_set o;
+ int i;
+
+ if (in->gssx_OID_set_len == 0) {
+ *out = GSS_C_NO_OID_SET;
+ return 0;
+ }
+
+ o = malloc(sizeof(gss_OID_set_desc));
+ if (!o) {
+ return ENOMEM;
+ }
+
+ o->count = in->gssx_OID_set_len;
+ o->elements = calloc(o->count, sizeof(gss_OID_desc));
+ if (!o->elements) {
+ free(o);
+ return ENOMEM;
+ }
+
+ for (i = 0; i < o->count; i++) {
+ o->elements[i].elements =
+ gp_memdup(in->gssx_OID_set_val[i].octet_string_val,
+ in->gssx_OID_set_val[i].octet_string_len);
+ if (!o->elements[i].elements) {
+ while (i > 0) {
+ i--;
+ free(o->elements[i].elements);
+ }
+ free(o->elements);
+ free(o);
+ return ENOMEM;
+ }
+ o->elements[i].length = in->gssx_OID_set_val[i].octet_string_len;
+ }
+
+ *out = o;
+ return 0;
+}
+
+int gp_conv_oid_set_to_gssx(gss_OID_set in, gssx_OID_set *out)
+{
+ int ret;
+ int i;
+
+ if (in->count == 0) {
+ return 0;
+ }
+
+ out->gssx_OID_set_len = in->count;
+ out->gssx_OID_set_val = calloc(in->count, sizeof(gssx_OID));
+ if (!out->gssx_OID_set_val) {
+ return ENOMEM;
+ }
+
+ for (i = 0; i < in->count; i++) {
+ ret = gp_conv_octet_string(in->elements[i].length,
+ in->elements[i].elements,
+ &out->gssx_OID_set_val[i]);
+ if (ret) {
+ while (i > 0) {
+ i--;
+ free(out->gssx_OID_set_val[i].octet_string_val);
+ }
+ free(out->gssx_OID_set_val);
+ return ENOMEM;
+ }
+ }
+
+ return 0;
+}
diff --git a/proxy/src/gp_conv.h b/proxy/src/gp_conv.h
index 20c18d5..110970a 100644
--- a/proxy/src/gp_conv.h
+++ b/proxy/src/gp_conv.h
@@ -65,4 +65,7 @@ int gp_conv_status_to_gssx(struct gssx_call_ctx *call_ctx,
int gp_copy_utf8string(utf8string *in, utf8string *out);
int gp_copy_gssx_status_alloc(gssx_status *in, gssx_status **out);
+int gp_conv_gssx_to_oid_set(gssx_OID_set *in, gss_OID_set *out);
+int gp_conv_oid_set_to_gssx(gss_OID_set in, gssx_OID_set *out);
+
#endif /* _GSS_CONV_H_ */