You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by da...@apache.org on 2006/08/01 07:37:00 UTC
svn commit: r427449 - in /webservices/axis2/trunk/c/rampart/src: ./ core/
handlers/ omxmlsec/ omxmlsec/openssl/ util/
Author: damitha
Date: Mon Jul 31 22:37:00 2006
New Revision: 427449
URL: http://svn.apache.org/viewvc?rev=427449&view=rev
Log:
Applying patches for rampart
Added:
webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_engine.c
Modified:
webservices/axis2/trunk/c/rampart/src/Makefile.am
webservices/axis2/trunk/c/rampart/src/core/Makefile.am
webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c
webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c
webservices/axis2/trunk/c/rampart/src/omxmlsec/axiom.c
webservices/axis2/trunk/c/rampart/src/omxmlsec/enc_engine.c
webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/cipher_ctx.c
webservices/axis2/trunk/c/rampart/src/omxmlsec/token_encrypted_type.c
Modified: webservices/axis2/trunk/c/rampart/src/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/Makefile.am?rev=427449&r1=427448&r2=427449&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/Makefile.am Mon Jul 31 22:37:00 2006
@@ -1 +1 @@
-SUBDIRS = handlers util core data omxmlsec
+SUBDIRS = omxmlsec handlers util core data
Modified: webservices/axis2/trunk/c/rampart/src/core/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/core/Makefile.am?rev=427449&r1=427448&r2=427449&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/core/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/core/Makefile.am Mon Jul 31 22:37:00 2006
@@ -7,7 +7,9 @@
mod_rampart.c
libmod_rampart_la_LIBADD = ../handlers/librampart_handlers.la \
- ../util/librampart_util.la
+ ../util/librampart_util.la \
+ ../omxmlsec/libomxmlsec.la \
+ ../omxmlsec/openssl/libomopenssl.la
INCLUDES = -I$(top_builddir)/include \
@UTILINC@
Modified: webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c?rev=427449&r1=427448&r2=427449&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c (original)
+++ webservices/axis2/trunk/c/rampart/src/handlers/rampart_in_handler.c Mon Jul 31 22:37:00 2006
@@ -29,6 +29,7 @@
#include <rampart_handler_util.h>
#include <timestamp_token.h>
#include <rampart_util.h>
+#include <rampart_crypto_engine.h>
/*************************** Function headers *********************************/
@@ -72,7 +73,8 @@
axis2_char_t *items = NULL;
axiom_node_t *sec_node, *ts_node = NULL;
axiom_element_t *sec_ele, *ts_ele = NULL;
-
+ axis2_status_t enc_status = AXIS2_FAILURE;
+
AXIS2_ENV_CHECK( env, AXIS2_FAILURE);
AXIS2_PARAM_CHECK(env->error, msg_ctx, AXIS2_FAILURE);
@@ -154,7 +156,8 @@
}else if( 0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_ENCRYPT, AXIS2_STRTRIM(env, item, NULL)) ){
/*Do useful to verify encrypt*/
- printf("InHandler : Encrypt\n");
+ printf("InHandler : Decrypt\n");
+ enc_status = rampart_crypto_decrypt_message(env, soap_envelope);
}else if( 0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_SIGNATURE, AXIS2_STRTRIM(env, item, NULL)) ){
/*Do useful to verify sign*/
Modified: webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c?rev=427449&r1=427448&r2=427449&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c (original)
+++ webservices/axis2/trunk/c/rampart/src/handlers/rampart_out_handler.c Mon Jul 31 22:37:00 2006
@@ -25,7 +25,7 @@
#include <rampart_constants.h>
#include <username_token.h>
#include <rampart_handler_util.h>
-/*#include <rampart_crypto_engine.h>*/
+#include <rampart_crypto_engine.h>
#include <timestamp_token.h>
/*********************** Function headers *********************************/
@@ -219,13 +219,13 @@
/*Encrypt*/
}else if(0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_ENCRYPT,
AXIS2_STRTRIM(env, item, NULL))){
- /* printf("OUtHandler : Item is Encrypt\n"); */
- /* enc_status = rampart_crypto_encrypt_message(env, soap_envelope);*/
+ printf("OUtHandler : Item is Encrypt\n");
+ enc_status = rampart_crypto_encrypt_message(env, soap_envelope);
/*Signature*/
}else if(0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_SIGNATURE,
AXIS2_STRTRIM(env, item, NULL))){
- /*printf("OutHandler : Item is SignatureSignature. Sorry we dont support\n"); */
+ printf("OutHandler : Item is SignatureSignature. Sorry we dont support\n");
/*Any other type of action*/
}else
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/axiom.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/axiom.c?rev=427449&r1=427448&r2=427449&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/axiom.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/axiom.c Mon Jul 31 22:37:00 2006
@@ -52,6 +52,8 @@
namestr = AXIS2_QNAME_GET_LOCALPART(qname, env);
ret_name = AXIS2_STRCMP(namestr, name) ;
+
+ printf("oxs_axiom_check_node_name\n Node: %s\n Name: %s\n",namestr, name);
if(ret_name < 0) return 0;
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/enc_engine.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/enc_engine.c?rev=427449&r1=427448&r2=427449&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/enc_engine.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/enc_engine.c Mon Jul 31 22:37:00 2006
@@ -31,13 +31,12 @@
#include <openssl_constants.h>
-
+/*Encrypt or decrypt an input depending on what is set in the enc_ctx*/
/*TODO Default IV*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
oxs_enc_crypt(const axis2_env_t *env,
enc_ctx_ptr enc_ctx,
oxs_buffer_ptr input,
- axis2_char_t* key,
oxs_buffer_ptr result)
{
unsigned char *out_main_buf = NULL;
@@ -63,13 +62,13 @@
}
/*Set the key*/
- bc_ctx->key = AXIS2_STRDUP(key, env);
+ bc_ctx->key = AXIS2_STRDUP(enc_ctx->key->data, env);
bc_ctx->key_initialized = 1;
/*Set the IV*/
bc_ctx->iv = AXIS2_STRDUP(iv, env);
/*TODO: Get the cipher by giving the algoritm attribute */
- cipher_name = oxs_get_cipher(env, (unsigned char*)enc_ctx->encmtd_algorithm);
+ cipher_name = oxs_get_cipher(env, enc_ctx->encmtd_algorithm);
if(!cipher_name){
oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
"oxs_get_cipher failed");
@@ -77,14 +76,27 @@
return AXIS2_FAILURE;
}
- ret = openssl_evp_block_cipher_ctx_init(env, bc_ctx,
- OPENSSL_ENCRYPT, cipher_name);
-
+ /*Initialize block cipher ctx*/
+ if(enc_ctx->operation == oxs_operation_encrypt){
+ ret = openssl_evp_block_cipher_ctx_init(env, bc_ctx,
+ OPENSSL_ENCRYPT, (const unsigned char*)cipher_name);
+ }else if(enc_ctx->operation == oxs_operation_decrypt){
+ ret = openssl_evp_block_cipher_ctx_init(env, bc_ctx,
+ OPENSSL_DECRYPT, (const unsigned char*)cipher_name);
+ }else{
+ oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+ "Invalid operation type %d", enc_ctx->operation);
+ return AXIS2_FAILURE;
+ }
+
if(ret < 0){
oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
"openssl_evp_block_cipher_ctx_init failed");
return AXIS2_FAILURE;
}
+
+ /****************Encryption or decryption happens here ************/
+
/*If this is to encrypt we simply pass the data to crypto function*/
if(enc_ctx->operation == oxs_operation_encrypt){
enclen = openssl_block_cipher_crypt(env, bc_ctx,
@@ -119,8 +131,10 @@
/*If the operation is to encrypt we will encode the encrypted data*/
if(enc_ctx->operation == oxs_operation_encrypt){
encodedlen = axis2_base64_encode_len(enclen);
- encoded_str = AXIS2_MALLOC(env->allocator, encodedlen);
- ret = axis2_base64_encode(encoded_str, out_main_buf, enclen);
+ encoded_str = AXIS2_MALLOC(env->allocator, encodedlen );
+
+ /*out_main_buf[enclen] ="\0";*/ /*Null terminate ??? Prob???*/
+ ret = axis2_base64_encode(encoded_str, (const char *)out_main_buf, enclen);
if(ret < 0){
oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
"axis2_base64_encode");
@@ -185,7 +199,7 @@
}
- ret = AXIOM_ELEMENT_SET_TEXT(cv_ele, env, databuf->data , cv_node);
+ ret = AXIOM_ELEMENT_SET_TEXT(cv_ele, env, (axis2_char_t *)databuf->data , cv_node);
if(ret != AXIS2_SUCCESS){
oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
"Cannot set data to the CipherValue element");
@@ -205,7 +219,6 @@
axis2_status_t ret = AXIS2_FAILURE;
oxs_buffer_ptr input = NULL;
oxs_buffer_ptr result = NULL;
- axis2_char_t *key = NULL;
/*Populate enc_ctx*/
enc_ctx->operation = oxs_operation_decrypt;
@@ -219,19 +232,24 @@
}
/*Now look for data to be decrypted*/
- input = enc_ctx->inputdata;
+ input = oxs_create_buffer(env, OXS_BUFFER_INITIAL_SIZE);
+ input->data = (unsigned char *)enc_ctx->inputdata;
+ input->size = AXIS2_STRLEN(enc_ctx->inputdata);
+
+ /*Initialize the result buffer*/
result = oxs_create_buffer(env, OXS_BUFFER_INITIAL_SIZE);
-
- key = enc_ctx->key->data;
- ret = oxs_enc_crypt(env, enc_ctx, input, key, result );
+ ret = oxs_enc_crypt(env, enc_ctx, input, result );
if(ret != AXIS2_SUCCESS){
oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
"oxs_enc_encrypt failed");
return ret;
}
- *decrypted_data = result->data;
+ *decrypted_data = AXIS2_MALLOC(env->allocator,result->size);
+ *decrypted_data = (axis2_char_t*)result->data;
+
+ return ret;
}
/*We expect user to provide a template as below*/
@@ -246,7 +264,6 @@
axis2_status_t ret = AXIS2_FAILURE;
oxs_buffer_ptr input = NULL;
oxs_buffer_ptr result = NULL;
- axis2_char_t *key = NULL;
/*Populate enc_ctx*/
@@ -266,18 +283,21 @@
input = oxs_string_to_buffer(env, data);
result = oxs_create_buffer(env, OXS_BUFFER_INITIAL_SIZE);
- key = enc_ctx->key->data;
-
- ret = oxs_enc_crypt(env, enc_ctx, input, key, result );
+ ret = oxs_enc_crypt(env, enc_ctx, input, result );
if(ret != AXIS2_SUCCESS){
oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
"oxs_enc_encrypt failed");
return ret;
}
- oxs_enc_populate_cipher_value (env, template_node, result);
+ ret = oxs_enc_populate_cipher_value (env, template_node, result);
-
+ if(ret != AXIS2_SUCCESS){
+ oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+ "oxs_enc_populate_cipher_value failed");
+ return ret;
+ }
+
return AXIS2_SUCCESS;
}
@@ -289,7 +309,6 @@
axiom_node_t* cur = NULL;
axiom_element_t *ele = NULL;
axis2_char_t *data = NULL;
- int ret;
/*We've a cipher data node here.
The child element is either a CipherReference or a CipherValue element*/
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/cipher_ctx.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/cipher_ctx.c?rev=427449&r1=427448&r2=427449&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/cipher_ctx.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/cipher_ctx.c Mon Jul 31 22:37:00 2006
@@ -110,52 +110,3 @@
return 0;
}
-#if 0
-
-AXIS2_EXTERN openssl_evp_block_cipher_ctx_ptr AXIS2_CALL
-openssl_evp_block_cipher_ctx_init(const axis2_env_t *env,
- openssl_evp_block_cipher_ctx_ptr bc_ctx,
- oxs_buffer_ptr in,
- oxs_buffer_ptr out,
- int encrypt,
- const unsigned char* cipher_name)
-{
- int ivLen;
- int ret;
-
-
- bc_ctx->cipher = EVP_des_ede3_cbc(); /* Right now we support only this*/
-
- EVP_CIPHER_CTX_init(&(bc_ctx->cipher_ctx));
-
- ivLen = EVP_CIPHER_iv_length(bc_ctx->cipher);
-
- if(encrypt) {
- /* generate random iv */
- ret = RAND_bytes(bc_ctx->iv, ivLen);
- if(ret != 1) {
- return(-1);
- }
-
- /*Write IV to the output */
- ret = oxs_buffer_append(env, out, bc_ctx->iv, ivLen);
-
- }else{
- /* if we don't have enough data, exit and hope that
- * we'll have iv next time */
-
- /*TODO Decrypt*/
- return 0;
- }
-
- /* set iv */
- ret = EVP_CipherInit(&(bc_ctx->cipher_ctx), bc_ctx->cipher, bc_ctx->key, bc_ctx->iv, encrypt);
- if(ret != 1) {
- return (-1);
- }
-
- bc_ctx->ctxInitialized = 1;
-
- return 0;
-}
-#endif
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/token_encrypted_type.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/token_encrypted_type.c?rev=427449&r1=427448&r2=427449&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/token_encrypted_type.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/token_encrypted_type.c Mon Jul 31 22:37:00 2006
@@ -56,6 +56,9 @@
if(id){
id_attr = axiom_attribute_create(env, OXS_AttrId, id, NULL);
ret = AXIOM_ELEMENT_ADD_ATTRIBUTE(encrypted_type_ele, env, id_attr, encrypted_type_node);
+ }else{
+ id_attr = axiom_attribute_create(env, OXS_AttrId, "EncDataId-54321", NULL);
+ ret = AXIOM_ELEMENT_ADD_ATTRIBUTE(encrypted_type_ele, env, id_attr, encrypted_type_node);
}
return encrypted_type_node;
Added: webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_engine.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_engine.c?rev=427449&view=auto
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_engine.c (added)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_engine.c Mon Jul 31 22:37:00 2006
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2003-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Rampart_crypto_util will contain crypto functionalities of the rampart model
+ *
+ */
+#include <stdio.h>
+#include <axis2_utils.h>
+#include <oxs_ctx.h>
+#include <oxs_error.h>
+#include <oxs_enc_engine.h>
+#include <rampart_crypto_engine.h>
+#include <oxs_token_encrypted_type.h>
+#include <oxs_token_encryption_method.h>
+#include <oxs_token_cipher_data.h>
+#include <oxs_token_cipher_value.h>
+#include <oxs_token_key_info.h>
+#include <oxs_token_key_name.h>
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_crypto_decrypt_message(const axis2_env_t *env,
+ /* struct axis2_msg_ctx *msg_ctx,*/
+ axiom_soap_envelope_t *soap_envelope )
+{
+ axis2_char_t *key = NULL, *key_name = NULL;
+ axis2_status_t ret = AXIS2_FAILURE;
+ axiom_node_t *enc_data_node = NULL;
+ axiom_node_t *body_node = NULL, *header_node = NULL;
+ axiom_soap_body_t *body = NULL;
+ axiom_soap_header_t *header = NULL;
+ axis2_char_t *decrypted_data = NULL;
+ enc_ctx_ptr enc_ctx = NULL;
+
+ ret = AXIS2_SUCCESS;/*TODO Remove*/
+ /*TODO get the key using callbacks*/
+ key = "0123456701234567";
+ key_name = "KauKey";
+
+ body = AXIOM_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
+ header = AXIOM_SOAP_ENVELOPE_GET_HEADER(soap_envelope, env);
+
+ body_node = AXIOM_SOAP_BODY_GET_BASE_NODE(body, env);
+ header_node = AXIOM_SOAP_HEADER_GET_BASE_NODE(header, env);
+
+ /*TODO We assume that the very first element of bpody is encrypted data.
+ This might be different if a sub element is encrypted*/
+ enc_data_node = AXIOM_NODE_GET_FIRST_CHILD(body_node, env);
+/* ret = oxs_axiom_check_node_name(env, enc_data_node, OXS_NodeEncryptedData, NULL);
+ if(ret){
+ oxs_error(ERROR_LOCATION, OXS_ERROR_DECRYPT_FAILED,
+ "EncryptedData node searching failed." );
+ return ret;
+
+ }
+*/
+ /*Build the encryption ctx*/
+ enc_ctx = oxs_ctx_create_ctx(env);
+
+ /*Set the key*/
+ enc_ctx->key = oxs_key_create_key(env, key_name, (unsigned char*)key, AXIS2_STRLEN(key), OXS_KEY_USAGE_DECRYPT);
+
+ ret = oxs_enc_decrypt_template(env, enc_data_node, &decrypted_data, enc_ctx);
+ if(ret == AXIS2_FAILURE){
+ oxs_error(ERROR_LOCATION, OXS_ERROR_ENCRYPT_FAILED,
+ "oxs_enc_decrypt_template failed");
+ return ret;
+ }else{
+ printf("Decrypted data is \n %s", decrypted_data);
+ }
+
+ /*Create a stream reader and then build the node using decrypted text*/
+
+ return ret;
+}
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+rampart_crypto_encrypt_message(const axis2_env_t *env,
+ /* struct axis2_msg_ctx *msg_ctx,*/
+ axiom_soap_envelope_t *soap_envelope )
+{
+ axis2_char_t *key = NULL, *key_name = NULL;
+ axis2_status_t ret = AXIS2_FAILURE;
+ axiom_node_t *node_to_enc = NULL, *body_node = NULL, *header_node = NULL;
+ axiom_node_t *enc_type_node = NULL, *enc_mtd_node = NULL, *key_info_node = NULL, *key_name_node = NULL;
+ axiom_node_t *cv_node = NULL, *cd_node = NULL, *temp = NULL;
+ axiom_soap_body_t *body = NULL;
+ axiom_soap_header_t *header = NULL;
+ axis2_char_t *str_to_enc = NULL;
+ enc_ctx_ptr enc_ctx = NULL;
+
+
+ ret = AXIS2_SUCCESS;/*TODO Remove*/
+
+ /*TODO get the key using callbacks*/
+ key = "0123456701234567";
+ key_name = "KauKey";
+
+ body = AXIOM_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
+ header = AXIOM_SOAP_ENVELOPE_GET_HEADER(soap_envelope, env);
+
+ body_node = AXIOM_SOAP_BODY_GET_BASE_NODE(body, env);
+ header_node = AXIOM_SOAP_HEADER_GET_BASE_NODE(header, env);
+
+ /*TODO Get the node to be encrypted*/
+ /*If non is specified we encrypt the first element of the Body element*/
+ if(!node_to_enc){
+ node_to_enc = AXIOM_NODE_GET_FIRST_CHILD(body_node, env);
+ }
+
+ str_to_enc = AXIOM_NODE_TO_STRING(node_to_enc, env);
+
+ /*Build the template*/
+ /*TODO Support enc key later*/
+ /*NOTE : Here I pass body_node as the parent. Might be a prob :(*/
+ enc_type_node = oxs_token_build_encrypted_type_element(env,
+ AXIOM_NODE_GET_PARENT(node_to_enc, env),
+ OXS_NodeEncryptedData,
+ OXS_TypeEncElement,
+ "EncDataId-12345" );
+ enc_mtd_node = oxs_token_build_encryption_method_element(env, enc_type_node, OXS_HrefDes3Cbc);
+ key_info_node = oxs_token_build_key_info_element(env, enc_type_node);
+ key_name_node = oxs_token_build_key_name_element(env, key_info_node, key_name );
+ cd_node = oxs_token_build_cipher_data_element(env, enc_type_node);
+ cv_node = oxs_token_build_cipher_value_element(env, cd_node, NULL); /*We pass NULL here OMXMLSEC will populate this*/
+
+ /*Build the encryption ctx*/
+ enc_ctx = oxs_ctx_create_ctx(env);
+
+ /*Set the key*/
+ enc_ctx->key = oxs_key_create_key(env, key_name, (unsigned char*)key, AXIS2_STRLEN(key), OXS_KEY_USAGE_ENCRYPT);
+
+ /*Hand the template over to OMXMLSEC*/
+ ret = oxs_enc_encrypt_template(env, enc_type_node, str_to_enc, enc_ctx);
+ if(ret == AXIS2_FAILURE){
+ oxs_error(ERROR_LOCATION, OXS_ERROR_ENCRYPT_FAILED,
+ "oxs_enc_encrypt_template failed");
+ return ret;
+ }else{
+ printf("Encryption template is \n %s", AXIOM_NODE_TO_STRING(enc_type_node, env));
+ }
+
+ /*Remove the encrypted node*/
+ temp = AXIOM_NODE_DETACH(node_to_enc, env);
+ if(!temp){
+ oxs_error(ERROR_LOCATION, OXS_ERROR_ENCRYPT_FAILED,
+ "Detaching encrypyted node failed");
+ return AXIS2_FAILURE;
+ }
+
+ /*Now arrange this encrypted nodes in a suitable manner to the envelope*/
+
+ return ret;
+}
+
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org