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 ka...@apache.org on 2006/11/09 06:46:20 UTC

svn commit: r472783 - in /webservices/axis2/trunk/c/rampart: ./ include/ src/omxmlsec/ src/util/ test/ test/omxmlsec/

Author: kaushalye
Date: Wed Nov  8 21:46:19 2006
New Revision: 472783

URL: http://svn.apache.org/viewvc?view=rev&rev=472783
Log:
Introducing new encryption and xml_encryption files to omxmlsec.


Added:
    webservices/axis2/trunk/c/rampart/include/oxs_encryption.h
    webservices/axis2/trunk/c/rampart/include/oxs_xml_encryption.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c
Modified:
    webservices/axis2/trunk/c/rampart/Makefile.am
    webservices/axis2/trunk/c/rampart/configure.ac
    webservices/axis2/trunk/c/rampart/include/openssl_crypt.h
    webservices/axis2/trunk/c/rampart/include/oxs_token_cipher_data.h
    webservices/axis2/trunk/c/rampart/include/oxs_token_encryption_method.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am
    webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_engine.c
    webservices/axis2/trunk/c/rampart/test/Makefile.am
    webservices/axis2/trunk/c/rampart/test/omxmlsec/Makefile.am
    webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c

Modified: webservices/axis2/trunk/c/rampart/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/Makefile.am?view=diff&rev=472783&r1=472782&r2=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/Makefile.am Wed Nov  8 21:46:19 2006
@@ -1,4 +1,4 @@
-SUBDIRS = src 
+SUBDIRS = src  test
 include_HEADERS=$(top_builddir)/include/*.h
 EXTRA_DIST = LICENSE build.sh autogen.sh samples
 

Modified: webservices/axis2/trunk/c/rampart/configure.ac
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/configure.ac?view=diff&rev=472783&r1=472782&r2=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/configure.ac (original)
+++ webservices/axis2/trunk/c/rampart/configure.ac Wed Nov  8 21:46:19 2006
@@ -55,6 +55,8 @@
     src/handlers/Makefile \
     src/core/Makefile \
     src/util/Makefile 
+    test/Makefile 
+    test/omxmlsec/Makefile 
     ])
     
 AC_OUTPUT

Modified: webservices/axis2/trunk/c/rampart/include/openssl_crypt.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/openssl_crypt.h?view=diff&rev=472783&r1=472782&r2=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/openssl_crypt.h (original)
+++ webservices/axis2/trunk/c/rampart/include/openssl_crypt.h Wed Nov  8 21:46:19 2006
@@ -35,6 +35,8 @@
  * @{
  */
 
+
+
 /**
 *   
 *@param bc_ctx block cipher context
@@ -43,7 +45,8 @@
 *@param do_encrypt 1 to encrypt 0 to decrypt
 *@return -1 if failed
 */
-AXIS2_EXTERN int AXIS2_CALL  openssl_block_cipher_crypt(const axis2_env_t *env,
+AXIS2_EXTERN int AXIS2_CALL  
+openssl_block_cipher_crypt(const axis2_env_t *env,
     openssl_cipher_ctx_t *oc_ctx,
     unsigned char *in_main_buf,
     int in_main_len, 

Added: webservices/axis2/trunk/c/rampart/include/oxs_encryption.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_encryption.h?view=auto&rev=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_encryption.h (added)
+++ webservices/axis2/trunk/c/rampart/include/oxs_encryption.h Wed Nov  8 21:46:19 2006
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2004,2005 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.
+ */
+
+#ifndef OXS_ENCRYPTION_H
+#define OXS_ENCRYPTION_H
+
+
+/**
+  * @file oxs_encryption.h
+  * @brief 
+  */
+
+#include <axis2_defines.h>
+#include <oxs_ctx.h>
+#include <axis2_env.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axis2_qname.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+axis2_status_t AXIS2_CALL
+oxs_encryption_symmetric_crypt(const axis2_env_t *env,
+    oxs_ctx_t * enc_ctx,
+    oxs_buffer_t *input,
+    oxs_buffer_t *result);
+
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif                          /* OXS_ENCRYPTION_H */

Modified: webservices/axis2/trunk/c/rampart/include/oxs_token_cipher_data.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_token_cipher_data.h?view=diff&rev=472783&r1=472782&r2=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_token_cipher_data.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_token_cipher_data.h Wed Nov  8 21:46:19 2006
@@ -36,7 +36,7 @@
 /**
 * Cipher Data element
 */
-AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+AXIS2_EXTERN axiom_node_t * AXIS2_CALL
 oxs_token_build_cipher_data_element(const axis2_env_t *env,
                         axiom_node_t *parent
                     );

Modified: webservices/axis2/trunk/c/rampart/include/oxs_token_encryption_method.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_token_encryption_method.h?view=diff&rev=472783&r1=472782&r2=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_token_encryption_method.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_token_encryption_method.h Wed Nov  8 21:46:19 2006
@@ -40,7 +40,7 @@
 AXIS2_EXTERN axiom_node_t* AXIS2_CALL
 oxs_token_build_encryption_method_element(const axis2_env_t *env,
                         axiom_node_t *parent,
-                        axis2_char_t* algorithm
+                        axis2_char_t *algorithm
                     );
 
 AXIS2_EXTERN axis2_char_t *AXIS2_CALL

Added: webservices/axis2/trunk/c/rampart/include/oxs_xml_encryption.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_xml_encryption.h?view=auto&rev=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_xml_encryption.h (added)
+++ webservices/axis2/trunk/c/rampart/include/oxs_xml_encryption.h Wed Nov  8 21:46:19 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2004,2005 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.
+ */
+
+#ifndef OXS_XML_ENCRYPTION_H
+#define OXS_XML_ENCRYPTION_H
+
+
+/**
+  * @file oxs_xml_enc.h
+  * @brief 
+  */
+
+#include <axis2_defines.h>
+#include <oxs_ctx.h>
+#include <axis2_env.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axis2_qname.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+axis2_status_t AXIS2_CALL
+oxs_xml_enc_encrypt_node(const axis2_env_t *env,
+                            oxs_ctx_t * enc_ctx,
+                            axiom_node_t *node,
+                            axiom_node_t **enc_type_node);
+
+axis2_status_t AXIS2_CALL
+oxs_xml_enc_decrypt_node(const axis2_env_t *env,
+                            oxs_ctx_t * enc_ctx,
+                            axiom_node_t *enc_type_node,
+                            axiom_node_t **decrypted_node);
+
+axis2_status_t AXIS2_CALL
+oxs_xml_enc_encrypt_data(const axis2_env_t *env,
+                            oxs_ctx_t * enc_ctx,
+                            oxs_buffer_t *content_buf,
+                            axiom_node_t **enc_type_node);
+
+axis2_status_t AXIS2_CALL
+oxs_xml_enc_decrypt_data(const axis2_env_t *env,
+                            oxs_ctx_t * enc_ctx,
+                            axiom_node_t *enc_type_node,
+                            oxs_buffer_t *result_buf);
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif                          /* OXS_XML_ENCRYPTION_H */

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am?view=diff&rev=472783&r1=472782&r2=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am Wed Nov  8 21:46:19 2006
@@ -4,7 +4,7 @@
 libomxmlsec_la_SOURCES = ctx.c  enc_engine.c buffer.c key.c cipher.c error.c axis2_utils.c axiom.c \
                         token_encrypted_data.c token_encryption_method.c token_cipher_value.c \
                         token_cipher_data.c token_key_name.c token_key_info.c token_binary_security_token.c \
-                        token_reference_list.c token_data_reference.c token_encrypted_key.c iv.c
+                        token_reference_list.c token_data_reference.c token_encrypted_key.c iv.c xml_encryption.c encryption.c
 
 libomxmlsec_la_LIBADD  = -lssl\
 			../../../util/src/libaxis2_util.la \

Added: webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c?view=auto&rev=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c Wed Nov  8 21:46:19 2006
@@ -0,0 +1,156 @@
+/*
+ *   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.
+ */
+#include <stdio.h>
+#include <axis2_util.h>
+#include <oxs_constants.h>
+#include <oxs_ctx.h>
+#include <oxs_error.h>
+#include <oxs_buffer.h>
+#include <oxs_encryption.h>
+#include <oxs_cipher.h>
+#include <oxs_iv.h>
+#include <openssl_cipher_ctx.h>
+#include <openssl_crypt.h>
+#include <openssl_constants.h>
+#include <openssl_rsa.h>
+#include <openssl_util.h>
+
+
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_encryption_symmetric_crypt(const axis2_env_t *env,
+    oxs_ctx_t * enc_ctx,
+    oxs_buffer_t *input,
+    oxs_buffer_t *result)
+{
+    openssl_cipher_ctx_t *oc_ctx = NULL;
+    openssl_cipher_property_t *cprop = NULL;
+    axis2_char_t *iv = NULL;
+    axis2_char_t *cipher_name = NULL;
+    axis2_status_t ret = AXIS2_FAILURE;
+    
+    /*Get cipher property*/
+    cprop =  oxs_get_cipher_property_for_url(env, OXS_CTX_GET_ENC_MTD_ALGORITHM(enc_ctx, env));
+    
+    /*Get the IV*/
+    iv = AXIS2_STRNDUP((axis2_char_t*)oxs_iv_generate_for_algo(
+                env,
+                OXS_CTX_GET_ENC_MTD_ALGORITHM(enc_ctx, env)),
+            OPENSSL_CIPHER_PROPERTY_GET_IV_SIZE(cprop, env),
+            env);
+
+    /*Create the openssl context*/
+    oc_ctx = openssl_cipher_ctx_create(env);
+    if (!oc_ctx)
+    {
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                "openssl_cipher_ctx_create failed");
+        return AXIS2_FAILURE;
+    }
+
+    /*Set IV*/
+    ret = OPENSSL_CIPHER_CTX_SET_IV(oc_ctx, env, iv);
+
+    /*Set key*/
+    ret = OPENSSL_CIPHER_CTX_SET_KEY(oc_ctx, env, OXS_CTX_GET_KEY(enc_ctx, env));
+
+    /*Set the cipher*/
+    cipher_name = (axis2_char_t*)OPENSSL_CIPHER_PROPERTY_GET_NAME(cprop, env);
+    if (!cipher_name)
+    {
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                "oxs_get_cipher failed");
+
+        return AXIS2_FAILURE;
+    }
+    ret = OPENSSL_CIPHER_CTX_SET_CIPHER(oc_ctx,
+            env,
+            (EVP_CIPHER*)openssl_get_evp_cipher_by_name(
+                env, (axis2_char_t*)cipher_name)
+            );
+    
+    /*Now everything is ready for the en/decryption*/ 
+    /*ENCRYPTION*/
+    if (OXS_CTX_GET_OPERATION(enc_ctx, env) == OXS_CTX_OPERATION_ENCRYPT)
+    {
+        axis2_char_t *encoded_str = NULL;
+        unsigned char *out_main_buf = NULL;
+        int enclen = -1;
+        int encodedlen = -1;
+
+        enclen = openssl_block_cipher_crypt(env, oc_ctx,
+                OXS_BUFFER_GET_DATA(input, env),
+                OXS_BUFFER_GET_SIZE(input, env),
+                &out_main_buf, OPENSSL_ENCRYPT);
+        if(enclen < 0){
+            oxs_error(ERROR_LOCATION, OXS_ERROR_ENCRYPT_FAILED,
+                    "openssl_block_cipher_crypt");
+            return AXIS2_FAILURE;
+        }
+
+        encodedlen = axis2_base64_encode_len(enclen);
+        encoded_str = AXIS2_MALLOC(env->allocator, encodedlen);
+        ret = axis2_base64_encode_binary(encoded_str, out_main_buf, enclen);
+        if (ret < 0)
+        {
+            oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                    "axis2_base64_encode_binary failed");
+            return AXIS2_FAILURE;
+        }
+
+        /*Attach the result to the result buf*/
+        ret = OXS_BUFFER_POPULATE(result, env, (unsigned char*)AXIS2_STRDUP(encoded_str, env), encodedlen);
+        
+        /*Free*/
+        AXIS2_FREE(env->allocator, encoded_str);
+        encoded_str = NULL;
+        AXIS2_FREE(env->allocator, out_main_buf);
+        out_main_buf = NULL;    
+
+    /*DECRYPTION*/
+    }else if(OXS_CTX_GET_OPERATION(enc_ctx, env) == OXS_CTX_OPERATION_DECRYPT){
+        unsigned char *decoded_data = NULL;
+        unsigned char *out_main_buf = NULL;
+        int decoded_len = -1;
+        int enclen = -1;
+
+        /*First we need to base64 decode*/
+        decoded_data = AXIS2_MALLOC(env->allocator, axis2_base64_decode_len((char*)(OXS_CTX_GET_INPUT_DATA(enc_ctx, env))));
+        decoded_len = axis2_base64_decode_binary(decoded_data, (char*)(OXS_CTX_GET_INPUT_DATA(enc_ctx, env)) );
+        if (decoded_len < 0)
+        {
+            oxs_error(ERROR_LOCATION, OXS_ERROR_DECRYPT_FAILED,
+                    "axis2_base64_decode_binary failed");
+        }
+        /*Then we decrypt*/
+        enclen = openssl_block_cipher_crypt(env, oc_ctx,
+                decoded_data, decoded_len,  &out_main_buf, OPENSSL_DECRYPT);
+
+        ret = OXS_BUFFER_POPULATE(result, env, AXIS2_STRMEMDUP(out_main_buf, enclen, env), enclen);
+        /*Free*/
+        AXIS2_FREE(env->allocator, decoded_data);
+        decoded_data = NULL;
+        AXIS2_FREE(env->allocator, out_main_buf);
+        out_main_buf = NULL;
+
+    }else{
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                "Invalid operation type %d", OXS_CTX_GET_OPERATION(enc_ctx, env));
+        return AXIS2_FAILURE;
+    }
+  
+    return AXIS2_SUCCESS;
+}
+

Added: webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c?view=auto&rev=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c Wed Nov  8 21:46:19 2006
@@ -0,0 +1,124 @@
+/*
+ *   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.
+ */
+#include <stdio.h>
+#include <axis2_qname.h>
+#include <axiom_namespace.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axis2_util.h>
+#include <oxs_token_encrypted_data.h>
+#include <oxs_token_encrypted_key.h>
+#include <oxs_token_encryption_method.h>
+#include <oxs_token_cipher_value.h>
+#include <oxs_token_cipher_data.h>
+#include <oxs_constants.h>
+#include <oxs_axiom.h>
+#include <oxs_ctx.h>
+#include <oxs_error.h>
+#include <oxs_buffer.h>
+#include <oxs_cipher.h>
+#include <oxs_iv.h>
+#include <oxs_encryption.h>
+#include <oxs_xml_encryption.h>
+
+/*private functions*/
+
+
+/*public functions*/
+axis2_status_t AXIS2_CALL
+oxs_xml_enc_encrypt_node(const axis2_env_t *env,
+                            oxs_ctx_t * enc_ctx,
+                            axiom_node_t *node,
+                            axiom_node_t **enc_type_node)
+{
+    axis2_char_t *serialized_data = NULL;
+    oxs_buffer_t *serialized_buf= NULL;
+    axis2_status_t ret = AXIS2_FAILURE;
+    
+    /*Serialize node*/
+    serialized_data = AXIOM_NODE_TO_STRING(node, env);
+    serialized_buf = oxs_buffer_create(env);
+    ret =  OXS_BUFFER_POPULATE(serialized_buf, env, (unsigned char *)serialized_data, AXIS2_STRLEN(serialized_data));
+   
+    /*We call encrypt_data*/
+    ret = oxs_xml_enc_encrypt_data(env, enc_ctx, serialized_buf, enc_type_node); 
+    
+    /*Free*/
+    OXS_BUFFER_FREE(serialized_buf, env); 
+
+    /*Return success*/
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_xml_enc_decrypt_node(const axis2_env_t *env,
+                            oxs_ctx_t * enc_ctx,
+                            axiom_node_t *enc_type_node,
+                            axiom_node_t **decrypted_node)
+{
+    
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_xml_enc_encrypt_data(const axis2_env_t *env,
+                            oxs_ctx_t * enc_ctx,
+                            oxs_buffer_t *content_buf,
+                            axiom_node_t **enc_type_node)
+{
+    oxs_buffer_t *result_buf= NULL;
+    oxs_key_t *sym_key = NULL;
+    axis2_char_t *sym_algo = NULL;
+    axiom_node_t *enc_mtd_node = NULL;
+    axiom_node_t *cd_node = NULL;
+    axiom_node_t *cv_node = NULL;
+    axis2_status_t ret = AXIS2_FAILURE;
+
+    /*Determine the algorithm to be used*/
+    sym_algo = OXS_CTX_GET_ENC_MTD_ALGORITHM(enc_ctx, env);
+    
+    /*Determine the key to be used*/
+    sym_key = OXS_CTX_GET_KEY(enc_ctx, env);
+
+    /*Set the operation to encrypt*/
+    OXS_CTX_SET_OPERATION(enc_ctx, env, OXS_CTX_OPERATION_DECRYPT);
+
+    /*Create an empty buffer for encrypted data*/
+    result_buf = oxs_buffer_create(env);
+    /*Call encryption. Result should be base64 encoded*/
+    ret = oxs_encryption_symmetric_crypt(env, enc_ctx, content_buf, result_buf);
+
+    /*Create EncryptionMethod, CipherData element and populate*/
+    enc_mtd_node = oxs_token_build_encryption_method_element(env, *enc_type_node, sym_algo);     
+    cd_node = oxs_token_build_cipher_data_element(env, *enc_type_node);
+    cv_node = oxs_token_build_cipher_value_element(env, cd_node, (axis2_char_t*)OXS_BUFFER_GET_DATA(result_buf, env));
+
+    /*Replace the node with enc_type_node*/
+    /*Free buffers*/
+    OXS_BUFFER_FREE(result_buf, env); 
+
+    return AXIS2_SUCCESS;
+}
+
+axis2_status_t AXIS2_CALL
+oxs_xml_enc_decrypt_data(const axis2_env_t *env,
+                            oxs_ctx_t * enc_ctx,
+                            axiom_node_t *enc_type_node,
+                            oxs_buffer_t *result_buf)
+{
+    return AXIS2_SUCCESS;
+}
+

Modified: 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?view=diff&rev=472783&r1=472782&r2=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_engine.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_engine.c Wed Nov  8 21:46:19 2006
@@ -43,7 +43,10 @@
 
 #define AXIS2_INTF_TO_IMPL(engine) ((rampart_crypto_engine_impl_t *)engine)
 
+
+
 /*******************Function Headers ****************************/
+/*Private functions*/
 static void
 rampart_crypto_engine_init_ops(
     rampart_crypto_engine_t *engine);
@@ -182,10 +185,14 @@
     rampart_crypto_engine_impl_t *engine_impl = NULL;
     axiom_node_t *removed_node = NULL;
     axis2_char_t* tmp_str = NULL;
+    axis2_char_t* encryption_parts = NULL;
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     engine_impl = AXIS2_INTF_TO_IMPL(engine);
 
+    /*TODO Get encryption parts*/
+    encryption_parts = RAMPART_ACTIONS_GET_ENCRYPTION_PARTS(actions, env);
+
     /*Generate the session key*/
     sessionkey = oxs_key_create_key(env);
     if (!sessionkey)
@@ -199,13 +206,9 @@
     ret = OXS_KEY_SET_NAME(sessionkey, env, "sessionkey");
     ret = OXS_KEY_SET_USAGE(sessionkey, env, OXS_KEY_USAGE_ENCRYPT);
 
-    /*printf("\nSession Key is %s", OXS_KEY_GET_DATA(sessionkey,env));    */
-
     body = AXIOM_SOAP_ENVELOPE_GET_BODY(soap_envelope, env);
     body_node = AXIOM_SOAP_BODY_GET_BASE_NODE(body, env);
 
-    /*TODO Get the node to be encrypted. As per encryptionParts in the OutflowSecurity*/
-
     /*TODO Generate uuid for the EncryptedDataNode*/
     uuid = "EncDataId-34526";
 
@@ -214,7 +217,6 @@
     {
         node_to_enc = AXIOM_NODE_GET_FIRST_CHILD(body_node, env);
     }
-
 
     str_to_enc = AXIOM_NODE_TO_STRING(node_to_enc, env);
 

Modified: webservices/axis2/trunk/c/rampart/test/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/Makefile.am?view=diff&rev=472783&r1=472782&r2=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/test/Makefile.am Wed Nov  8 21:46:19 2006
@@ -1,2 +1,2 @@
-SUBDIRS = openssl 
+SUBDIRS = omxmlsec
 

Modified: webservices/axis2/trunk/c/rampart/test/omxmlsec/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/omxmlsec/Makefile.am?view=diff&rev=472783&r1=472782&r2=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/omxmlsec/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/test/omxmlsec/Makefile.am Wed Nov  8 21:46:19 2006
@@ -4,12 +4,12 @@
 
 AM_CFLAGS = -g -O2 -pthread
 
-#test_oxs_SOURCES = test_base64.c
 test_oxs_SOURCES =  test.c
 
 INCLUDES = -I$(top_builddir)/include \
-			@UTILINC@ \
-            @AXIOMINC@
+		    -I ../../../include \
+            -I ../../../util/include \
+            -I ../../../axiom/include
 
 test_oxs_LDADD   = $(top_builddir)/src/util/librampart_util.la \
                     $(top_builddir)/src/omxmlsec/libomxmlsec.la \

Modified: webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c?view=diff&rev=472783&r1=472782&r2=472783
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c (original)
+++ webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c Wed Nov  8 21:46:19 2006
@@ -21,8 +21,11 @@
 #include <axiom_xml_reader.h>
 #include <axis2_env.h>
 #include <oxs_ctx.h>
+#include <oxs_key.h>
 #include <oxs_error.h>
-#include <oxs_enc_engine.h>
+#include <oxs_encryption.h>
+#include <oxs_xml_encryption.h>
+#include <oxs_token_encrypted_data.h>
 
 
 AXIS2_EXTERN axiom_node_t* AXIS2_CALL
@@ -64,12 +67,11 @@
     oxs_error(ERROR_LOCATION, OXS_ERROR_DEFAULT, "Api danne neee %d", 13);
     axis2_env_t *env = NULL;
     axis2_char_t *filename = "a.xml";
-    axis2_char_t *doc_file = "b.xml";
-    axis2_char_t *data = "OM the universal sound";
-    enc_ctx_t *ctx = NULL;
+    oxs_ctx_t *ctx = NULL;
+    oxs_key_t *key = NULL;
     axis2_status_t temp_status = AXIS2_FAILURE;
-    axiom_node_t *tmpl = NULL, *enc_doc = NULL;
-    axis2_char_t *encrypted_result = NULL, *decrypted_result = NULL;
+    axiom_node_t *tmpl = NULL, *enc_node = NULL, *enc_data_node = NULL;
+    axis2_char_t *encrypted_result = NULL;
     FILE *outf;
 
     env = test_init();
@@ -77,6 +79,7 @@
 
     if (argc > 1)
         filename = argv[1];
+
     tmpl = load_sample_xml(env , tmpl, filename);
 
     if (tmpl)
@@ -88,34 +91,25 @@
         printf("load_sample_xml FAILED");
         return -1;
     }
+    /*Create key*/
+    key = oxs_key_create_key(env);
+    OXS_KEY_POPULATE(key, env, (unsigned char*)"12345678", "session_key",  8, OXS_KEY_USAGE_ENCRYPT);
+   
+    /*Create ctx*/
+    ctx = oxs_ctx_create(env);
+    OXS_CTX_SET_KEY(ctx, env, key);
 
-    enc_doc =  load_sample_xml(env , enc_doc, doc_file);
-    if (enc_doc)
-    {
-        printf("load_sample_xml enc_doc SUCCESS");
-        /*     data = AXIOM_NODE_TO_STRING(enc_doc, env); *//*Enable this to encrypt an xml*/
-    }
-    else
-    {
-        printf("load_sample_xml enc_doc FAILED");
-        return -1;
-    }
-
+    /*Set algorithm*/
+    OXS_CTX_SET_ENC_MTD_ALGORITHM(ctx, env, OXS_HrefAes128Cbc);
 
+    /*Get the node to be encrypted*/
+    enc_node = AXIOM_NODE_GET_FIRST_CHILD(tmpl, env);
 
+    /*Create a reference to encrypted node*/
+    enc_data_node =  oxs_token_build_encrypted_data_element(env, tmpl, "xml-element", "id"); 
     /*Encrypt***************************************************/
-    ctx = oxs_ctx_create_ctx(env);
 
-    ctx->key = oxs_key_read_from_file(env, "deskey.bin");
-
-    /*TODO Set the key name inside KeyName node*/
-
-    if (!ctx)
-    {
-        printf("\nCannot create context");
-        return -1;
-    }
-    temp_status = oxs_enc_encrypt_template(env, tmpl, data, ctx);
+    temp_status = oxs_xml_enc_encrypt_node(env, ctx,  enc_node, &enc_data_node);
 
     if (temp_status)
     {
@@ -132,33 +126,5 @@
     outf = fopen("result.xml", "wb");
     fwrite(encrypted_result, 1, AXIS2_STRLEN(encrypted_result), outf);
 
-    /*Decrypt **************************************************/
-#if 1
-    printf("\nDecryption start\n**************************************************\n");
-    ctx = oxs_ctx_create_ctx(env);
-    ctx->key = oxs_key_read_from_file(env, "deskey.bin");
-
-    if (!ctx)
-    {
-        printf("\nCannot create context");
-        return -1;
-    }
-
-    temp_status = oxs_enc_decrypt_template(env, tmpl, &decrypted_result, ctx);
-
-    if (temp_status)
-    {
-        printf("oxs_enc_decrypt_template SUCCESS\n");
-    }
-    else
-    {
-        printf("oxs_enc_decrypt_template FAILURE\n");
-    }
-
-    printf("Decrypted result is\n%s", decrypted_result)    ;
-
-#endif
     return 0;
-
-
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org