summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorValery Febvre <vfebvre at easter-eggs.com>2004-04-28 21:49:07 +0000
committerValery Febvre <vfebvre at easter-eggs.com>2004-04-28 21:49:07 +0000
commit6dfee05214d86dc3081d2b0d6f3f1caa4e421dec (patch)
treefd6849315538afe345c37ef736c79759a9b6ac3b
parent0807e6fc8ee944728f91b51ad0399d74fb8013b0 (diff)
downloadlasso-6dfee05214d86dc3081d2b0d6f3f1caa4e421dec.tar.gz
lasso-6dfee05214d86dc3081d2b0d6f3f1caa4e421dec.tar.xz
lasso-6dfee05214d86dc3081d2b0d6f3f1caa4e421dec.zip
a new funct added: lasso_query_get_value()
-rw-r--r--lasso/xml/tools.c39
-rw-r--r--lasso/xml/tools.h35
2 files changed, 55 insertions, 19 deletions
diff --git a/lasso/xml/tools.c b/lasso/xml/tools.c
index 49ff3bee..b7522647 100644
--- a/lasso/xml/tools.c
+++ b/lasso/xml/tools.c
@@ -96,7 +96,29 @@ lasso_get_current_time()
return (ret);
}
-static void gdata_query_to_dict_destroy_notify(gpointer data) {
+GPtrArray *
+lasso_query_get_value(xmlChar *query,
+ const xmlChar *param)
+{
+ gint i;
+ GData *gd;
+ GPtrArray *tmp_array, *array = NULL;
+
+ gd = lasso_query_to_dict(query);
+ tmp_array = (GPtrArray *)g_datalist_get_data(&gd, param);
+ /* create a copy of tmp_array */
+ if (tmp_array != NULL) {
+ array = g_ptr_array_new();
+ for(i=0; i<tmp_array->len; i++)
+ g_ptr_array_add(array, g_strdup(g_ptr_array_index(tmp_array, i)));
+ }
+ g_datalist_clear(&gd);
+ return (array);
+}
+
+static void
+gdata_query_to_dict_destroy_notify(gpointer data)
+{
gint i;
GPtrArray *array = data;
@@ -159,7 +181,7 @@ lasso_query_to_dict(const xmlChar *query)
}
int
-lasso_query_verify_signature(xmlChar *str,
+lasso_query_verify_signature(xmlChar *query,
const xmlChar *sender_public_key_file,
const xmlChar *recipient_private_key_file)
{
@@ -167,10 +189,18 @@ lasso_query_verify_signature(xmlChar *str,
xmlNodePtr sigNode, sigValNode;
xmlSecDSigCtxPtr dsigCtx;
gchar **str_split;
+ /*
+ 0: signature invalid
+ 1: signature ok
+ 2: signature not found
+ -1: error during verification
+ */
gint ret = -1;
- /* split query, signatureValue */
- str_split = g_strsplit((const gchar *)str, "&Signature=", 0);
+ /* split query, signature (must be last param) */
+ str_split = g_strsplit((const gchar *)query, "&Signature=", 0);
+ if (str_split[1] == NULL)
+ return (2);
/* re-create doc to verify (signed + enrypted) */
doc = lasso_str_sign(str_split[0],
xmlSecTransformRsaSha1Id,
@@ -204,6 +234,7 @@ lasso_query_verify_signature(xmlChar *str,
/* Verify signature */
if(xmlSecDSigCtxVerify(dsigCtx, sigNode) < 0) {
fprintf(stderr,"Error: signature verify\n");
+ ret = 0;
goto done;
}
diff --git a/lasso/xml/tools.h b/lasso/xml/tools.h
index 7a835e8d..2459d8e5 100644
--- a/lasso/xml/tools.h
+++ b/lasso/xml/tools.h
@@ -37,29 +37,34 @@ extern "C" {
#include <xmlsec/templates.h>
#include <xmlsec/crypto.h>
-xmlChar* lasso_build_unique_id (guint8 size);
+#include <lasso/export.h>
-xmlChar* lasso_doc_get_node_content (xmlDocPtr doc,
- const xmlChar *name);
+LASSO_EXPORT xmlChar* lasso_build_unique_id (guint8 size);
-xmlChar* lasso_g_ptr_array_index (GPtrArray *a,
- guint i);
+LASSO_EXPORT xmlChar* lasso_doc_get_node_content (xmlDocPtr doc,
+ const xmlChar *name);
-xmlChar* lasso_get_current_time (void);
+LASSO_EXPORT xmlChar* lasso_g_ptr_array_index (GPtrArray *a,
+ guint i);
-GData* lasso_query_to_dict (const xmlChar *query);
+LASSO_EXPORT xmlChar* lasso_get_current_time (void);
-int lasso_query_verify_signature (xmlChar *str,
- const xmlChar *sender_public_key_file,
- const xmlChar *recipient_private_key_file);
+LASSO_EXPORT GPtrArray* lasso_query_get_value (xmlChar *query,
+ const xmlChar *param);
-xmlChar* lasso_str_escape (xmlChar *str);
+LASSO_EXPORT GData* lasso_query_to_dict (const xmlChar *query);
-xmlDocPtr lasso_str_sign (xmlChar *str,
- xmlSecTransformId signMethodId,
- const char *private_key_file);
+LASSO_EXPORT int lasso_query_verify_signature (xmlChar *str,
+ const xmlChar *sender_public_key_file,
+ const xmlChar *recipient_private_key_file);
-xmlChar* lasso_str_unescape (xmlChar *str);
+LASSO_EXPORT xmlChar* lasso_str_escape (xmlChar *str);
+
+LASSO_EXPORT xmlDocPtr lasso_str_sign (xmlChar *str,
+ xmlSecTransformId signMethodId,
+ const char *private_key_file);
+
+LASSO_EXPORT xmlChar* lasso_str_unescape (xmlChar *str);
#ifdef __cplusplus
}