summaryrefslogtreecommitdiffstats
path: root/lasso/xml
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-12-14 01:55:09 +0100
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-12-14 01:55:09 +0100
commitec5ec161f7d957e86b44310d8f2b5bb604613196 (patch)
tree98f0740c1015f3ce29b14b2abf4d9e8a5fb83b1a /lasso/xml
parentb0c2fdab284500e547d602c5e84d6dc212061011 (diff)
downloadlasso-ec5ec161f7d957e86b44310d8f2b5bb604613196.tar.gz
lasso-ec5ec161f7d957e86b44310d8f2b5bb604613196.tar.xz
lasso-ec5ec161f7d957e86b44310d8f2b5bb604613196.zip
[xml] add field to contains encryption parameters inside CustomElement structure
Diffstat (limited to 'lasso/xml')
-rw-r--r--lasso/xml/private.h6
-rw-r--r--lasso/xml/xml.c64
2 files changed, 70 insertions, 0 deletions
diff --git a/lasso/xml/private.h b/lasso/xml/private.h
index a2262f38..cc357dcf 100644
--- a/lasso/xml/private.h
+++ b/lasso/xml/private.h
@@ -205,6 +205,12 @@ void lasso_node_get_signature(LassoNode *node, LassoSignatureType *type, LassoSi
char **private_key, char **private_key_password,
char **certificate);
+void lasso_node_set_encryption(LassoNode *node, xmlSecKey *encryption_public_key,
+ LassoEncryptionSymKeyType encryption_sym_key_type);
+
+void lasso_node_get_encryption(LassoNode *node, xmlSecKey **encryption_public_key,
+ LassoEncryptionSymKeyType *encryption_sym_key_type);
+
#ifdef __cplusplus
}
#endif /* __cplusplus */
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index 0251d479..c4af92e3 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -850,6 +850,8 @@ struct _CustomElement {
char *private_key;
char *private_key_password;
char *certificate;
+ xmlSecKey *encryption_public_key;
+ LassoEncryptionSymKeyType encryption_sym_key_type;
};
static struct _CustomElement *
@@ -1007,6 +1009,68 @@ lasso_node_get_signature(LassoNode *node, LassoSignatureType *type, LassoSignatu
}
/**
+ * lasso_node_set_encryption:
+ * @node: a @LassoNode object
+ * @encryption_public_key: an #xmlSecKey used to crypt the session key
+ * @encryption_sym_key_type: the kind of session key to use
+ *
+ * Setup a node for future encryption. It is read by saml2:EncryptedElement for eventually
+ * encrypting nodes.
+ *
+ * Return value: 0 if successful, LASSO_PARAM_ERROR_BAD_TYPE_OR_NULL_OBJ if node is not a
+ * #LassoNode.
+ */
+void
+lasso_node_set_encryption(LassoNode *node, xmlSecKey *encryption_public_key,
+ LassoEncryptionSymKeyType encryption_sym_key_type)
+{
+ struct _CustomElement *custom_element;
+
+ g_return_if_fail(LASSO_IS_NODE(node));
+ if (encryption_public_key) {
+ custom_element = _lasso_node_get_custom_element_or_create(node);
+ } else {
+ custom_element = _lasso_node_get_custom_element(node);
+ if (! custom_element) {
+ return;
+ }
+ lasso_release_sec_key(custom_element->encryption_public_key);
+ return;
+ }
+ lasso_assign_sec_key(custom_element->encryption_public_key,
+ encryption_public_key);
+ if (encryption_sym_key_type < LASSO_ENCRYTPION_SYM_KEY_TYPE_LAST) {
+ custom_element->encryption_sym_key_type = encryption_sym_key_type;
+ } else {
+ custom_element->encryption_sym_key_type = LASSO_ENCRYPTION_SYM_KEY_TYPE_DEFAULT;
+ }
+}
+
+/**
+ * lasso_node_get_encryption:
+ * @node: a #LassoNode object
+ * @encryption_public_key_ptr: a pointer on a pointer to an #xmlSecKey object, to hold the the
+ * public key used to encrypt the session key
+ * @encryption_sym_key_type: a pointer on a #LassoEncryptionSymKeyType
+ *
+ * Lookup eventual configuration for encrypting the given node.
+ */
+void
+lasso_node_get_encryption(LassoNode *node, xmlSecKey **encryption_public_key,
+ LassoEncryptionSymKeyType *encryption_sym_key_type)
+{
+ struct _CustomElement *custom_element;
+
+ g_return_if_fail(LASSO_IS_NODE(node));
+ custom_element = _lasso_node_get_custom_element(node);
+ if (custom_element->encryption_public_key) {
+ lasso_assign_sec_key(*encryption_public_key,
+ custom_element->encryption_public_key);
+ *encryption_sym_key_type = custom_element->encryption_sym_key_type;
+ }
+}
+
+/**
* lasso_node_set_custom_nodename:
* @node: a #LassoNode object
* @nodename: the name to use for the node