summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Laniel <dlaniel@entrouvert.com>2006-12-06 17:50:23 +0000
committerDamien Laniel <dlaniel@entrouvert.com>2006-12-06 17:50:23 +0000
commite33f266e6fda24d98b3e3fd841107ff4a0ea0ee8 (patch)
tree595527638b396545112d603c38738ffd920ae705
parent3ff0082fdf8d632a3a35d26761cd7d9f2e526abd (diff)
downloadlasso-e33f266e6fda24d98b3e3fd841107ff4a0ea0ee8.tar.gz
lasso-e33f266e6fda24d98b3e3fd841107ff4a0ea0ee8.tar.xz
lasso-e33f266e6fda24d98b3e3fd841107ff4a0ea0ee8.zip
Better parse xml to find and EncryptedKey
-rw-r--r--lasso/xml/xml.c43
1 files changed, 20 insertions, 23 deletions
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index 5816d036..58b2540e 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -600,33 +600,30 @@ lasso_node_decrypt(LassoSaml2EncryptedElement* encrypted_element,
}
/* Get the EncryptedKey */
- if (encrypted_element->EncryptedKey == NULL) {
- message(G_LOG_LEVEL_WARNING, "No EncryptedKey node");
- return NULL;
- }
- for (i = encrypted_element->EncryptedKey; i; i = g_list_next(i)) {
- if (i->data == NULL)
- continue;
- if (strcmp((char*)((xmlNode*)i->data)->name, "EncryptedKey") == 0) {
- encrypted_key_node = (xmlNode*)(i->data);
- break;
+ if (encrypted_element->EncryptedKey != NULL) {
+ for (i = encrypted_element->EncryptedKey; i; i = g_list_next(i)) {
+ if (i->data == NULL)
+ continue;
+ if (strcmp((char*)((xmlNode*)i->data)->name, "EncryptedKey") == 0) {
+ encrypted_key_node = (xmlNode*)(i->data);
+ break;
+ }
}
- }
- if (encrypted_key_node == NULL) {
+ } else {
/* Look an EncryptedKey inside the EncryptedData */
- xmlNode *t = encrypted_data_node;
- while (t && strcmp((char*)t->name, "EncryptedKey") != 0 ) {
- if (strcmp((char*)t->name, "EncryptedData") == 0 ||
- strcmp((char*)t->name, "KeyInfo") == 0)
- t = t->children;
- t = t->next;
+ encrypted_key_node = encrypted_data_node;
+ while (encrypted_key_node &&
+ strcmp((char*)encrypted_key_node->name, "EncryptedKey") != 0 ) {
+ if (strcmp((char*)encrypted_key_node->name, "EncryptedData") == 0 ||
+ strcmp((char*)encrypted_key_node->name, "KeyInfo") == 0)
+ encrypted_key_node = encrypted_key_node->children;
+ encrypted_key_node = encrypted_key_node->next;
}
+ }
- if (t == NULL) {
- message(G_LOG_LEVEL_WARNING, "No EncryptedKey data");
- return NULL;
- }
- encrypted_key_node = t;
+ if (encrypted_key_node == NULL) {
+ message(G_LOG_LEVEL_WARNING, "No EncryptedKey node");
+ return NULL;
}
/* Create a document to contain the node to decrypt */