summaryrefslogtreecommitdiffstats
path: root/lasso/xml
diff options
context:
space:
mode:
authorBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-12-14 02:00:10 +0100
committerBenjamin Dauvergne <bdauvergne@entrouvert.com>2010-12-14 02:00:10 +0100
commitb324c41237889f8d985f6bac905170db31823988 (patch)
treea38fcbf16e124ae5811866f17bc402f2ceae9ab1 /lasso/xml
parent447c610c9cdfd81f46841a290964b20842cdb02d (diff)
downloadlasso-b324c41237889f8d985f6bac905170db31823988.tar.gz
lasso-b324c41237889f8d985f6bac905170db31823988.tar.xz
lasso-b324c41237889f8d985f6bac905170db31823988.zip
[xml] add exportation of the encrypting public key in EncryptedData elements
This commit check if the given is a simple RSA key or a full certificate and choose the better serialization method between RSAKeyValue and X509Data.
Diffstat (limited to 'lasso/xml')
-rw-r--r--lasso/xml/xml.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lasso/xml/xml.c b/lasso/xml/xml.c
index c4af92e3..9b64c579 100644
--- a/lasso/xml/xml.c
+++ b/lasso/xml/xml.c
@@ -44,6 +44,7 @@
#include <xmlsec/templates.h>
#include <xmlsec/crypto.h>
#include <xmlsec/xmlenc.h>
+#include <xmlsec/openssl/crypto.h>
#include "xml.h"
#include "xml_enc.h"
@@ -596,6 +597,24 @@ lasso_node_encrypt(LassoNode *lasso_node, xmlSecKey *encryption_public_key,
message(G_LOG_LEVEL_WARNING, "Failed to add key info");
goto cleanup;
}
+ /* check id of the key */
+ if (xmlSecKeyGetData(encryption_public_key, xmlSecOpenSSLKeyDataRsaId) != 0) {
+ xmlNode *key_value = xmlSecTmplKeyInfoAddKeyValue(key_info_node2);
+ if (key_value == NULL) {
+ message(G_LOG_LEVEL_WARNING, "Failed to add key value");
+ goto cleanup;
+ }
+ } else { /* it must be a certificate */
+ xmlNodePtr x509_data;
+ x509_data = xmlSecTmplKeyInfoAddX509Data(key_info_node2);
+ if (x509_data == NULL) {
+ message(G_LOG_LEVEL_WARNING, "Failed to add X509 data");
+ goto cleanup;
+ }
+ }
+
+
+
/* create encryption context */
enc_ctx = (xmlSecEncCtxPtr)xmlSecEncCtxCreate(key_manager);