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 2007/01/05 08:12:00 UTC

svn commit: r492924 - in /webservices/axis2/trunk/c/rampart: include/ samples/client/enc_echo/ src/omxmlsec/ src/omxmlsec/openssl/ test/omxmlsec/

Author: kaushalye
Date: Thu Jan  4 23:11:59 2007
New Revision: 492924

URL: http://svn.apache.org/viewvc?view=rev&rev=492924
Log:
Fixed interop problems.

Modified:
    webservices/axis2/trunk/c/rampart/include/openssl_crypt.h
    webservices/axis2/trunk/c/rampart/samples/client/enc_echo/README.txt
    webservices/axis2/trunk/c/rampart/samples/client/enc_echo/echo.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/buffer.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/crypt.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c
    webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c

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=492924&r1=492923&r2=492924
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/openssl_crypt.h (original)
+++ webservices/axis2/trunk/c/rampart/include/openssl_crypt.h Thu Jan  4 23:11:59 2007
@@ -34,7 +34,11 @@
  * @ingroup
  * @{
  */
-
+AXIS2_EXTERN int AXIS2_CALL openssl_bc_crypt(const axis2_env_t *env,
+        openssl_cipher_ctx_t *oc_ctx,
+        oxs_buffer_t *input_buf,
+        oxs_buffer_t *output_buf,
+        int encrypt);
 /**
 *   
 *@param bc_ctx block cipher context
@@ -43,13 +47,6 @@
 *@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,
-    openssl_cipher_ctx_t *oc_ctx,
-    unsigned char *in_main_buf,
-    int in_main_len, 
-    unsigned char **out_main_buf,
-    int do_encrypt);
 
 
 

Modified: webservices/axis2/trunk/c/rampart/samples/client/enc_echo/README.txt
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/samples/client/enc_echo/README.txt?view=diff&rev=492924&r1=492923&r2=492924
==============================================================================
--- webservices/axis2/trunk/c/rampart/samples/client/enc_echo/README.txt (original)
+++ webservices/axis2/trunk/c/rampart/samples/client/enc_echo/README.txt Thu Jan  4 23:11:59 2007
@@ -16,7 +16,8 @@
 ------------------------------
     Listen port: 9090 [specified as in the client argument]
     Target port: 8080 [server port]
-This step is OPTIONAL and can be avoided by starting the server without -p8080
+
+NOTE: This step is OPTIONAL and can be avoided by starting the server without -p8080
 option.
 
 HOW TO RUN CLIENT?

Modified: webservices/axis2/trunk/c/rampart/samples/client/enc_echo/echo.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/samples/client/enc_echo/echo.c?view=diff&rev=492924&r1=492923&r2=492924
==============================================================================
--- webservices/axis2/trunk/c/rampart/samples/client/enc_echo/echo.c (original)
+++ webservices/axis2/trunk/c/rampart/samples/client/enc_echo/echo.c Thu Jan  4 23:11:59 2007
@@ -65,9 +65,14 @@
     options = axis2_options_create(env);
     AXIS2_OPTIONS_SET_TO(options, env, endpoint_ref);
     AXIS2_OPTIONS_SET_ACTION(options, env,
-            "http://ws.apache.org/axis2/c/samples/echoString");
-    /*Added*/
-    AXIS2_OPTIONS_SET_SOAP_ACTION(options, env, "urn:echo");
+                    "http://ws.apache.org/axis2/c/samples/echoString");
+    
+    /*This is required to do interop with rampart/java*/
+    AXIS2_OPTIONS_SET_SOAP_VERSION(options, env, AXIOM_SOAP11);
+    AXIS2_OPTIONS_SET_SOAP_ACTION(options, env,
+            "urn:echo");
+
+
 
     /*
      * Set security params. If you need to enable dynamic settings uncomment
@@ -108,7 +113,7 @@
     AXIS2_SVC_CLIENT_SET_OPTIONS(svc_client, env, options);
 
     /* Engage addressing module */
-    AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, AXIS2_MODULE_ADDRESSING);
+    /*AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, AXIS2_MODULE_ADDRESSING);*/
 
     /* Build the SOAP request message payload using OM API.*/
     payload = build_om_payload_for_echo_svc(env);
@@ -154,17 +159,13 @@
     axiom_element_t* echo_om_ele = NULL;
     axiom_node_t* text_om_node = NULL;
     axiom_element_t * text_om_ele = NULL;
-    axiom_node_t* text_om_node2 = NULL;
-    axiom_element_t * text_om_ele2 = NULL;
     axiom_namespace_t *ns1 = NULL;
     axis2_char_t *om_str = NULL;
 
-    ns1 = axiom_namespace_create(env, "http://ws.apache.org/axis2/c/samples", "ns1");
-    echo_om_ele = axiom_element_create(env, NULL, "echoString", ns1, &echo_om_node);
-    text_om_ele = axiom_element_create(env, echo_om_node, "text", NULL, &text_om_node);
-    AXIOM_ELEMENT_SET_TEXT(text_om_ele, env, "echo5", text_om_node);
-    text_om_ele2 = axiom_element_create(env, echo_om_node, "text2", NULL, &text_om_node2);
-    AXIOM_ELEMENT_SET_TEXT(text_om_ele2, env, "echo52", text_om_node2);
+    ns1 = axiom_namespace_create(env, "http://sample05.samples.rampart.apache.org/xsd", "ns1");
+    echo_om_ele = axiom_element_create(env, NULL, "echo", ns1, &echo_om_node);
+    text_om_ele = axiom_element_create(env, echo_om_node, "param0", NULL, &text_om_node);
+    AXIOM_ELEMENT_SET_TEXT(text_om_ele, env, "echo55555", text_om_node);
 
     om_str = AXIOM_NODE_TO_STRING(echo_om_node, env);
     if (om_str)

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/buffer.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/buffer.c?view=diff&rev=492924&r1=492923&r2=492924
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/buffer.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/buffer.c Thu Jan  4 23:11:59 2007
@@ -239,10 +239,10 @@
     /*If the size to be removed is less than the buffer size*/
     if (size < buffer_impl->size)
     {
-        if (buffer_impl->data)
+        if (!buffer_impl->data)
         {
             oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
-                    "oxs_buffer_remove_head failed");
+                    "oxs_buffer_remove_head failed. data is NULL");
             return  AXIS2_FAILURE;
         }
         buffer_impl->size -= size;
@@ -256,7 +256,7 @@
     /*If the buffer size is less than the max_size.*/
     if (buffer_impl->size < buffer_impl->max_size)
     {
-        if (buffer_impl->data)
+        if (!buffer_impl->data)
         {
             oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
                     "oxs_buffer_remove_head failed");

Modified: 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=diff&rev=492924&r1=492923&r2=492924
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/encryption.c Thu Jan  4 23:11:59 2007
@@ -93,14 +93,14 @@
     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;
+        oxs_buffer_t *output = NULL;
 
-        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);
+        output = oxs_buffer_create(env);
+
+        /*Encrypt*/
+        enclen = openssl_bc_crypt(env, oc_ctx, input, output, OPENSSL_ENCRYPT);
         if(enclen < 0){
             oxs_error(ERROR_LOCATION, OXS_ERROR_ENCRYPT_FAILED,
                     "openssl_block_cipher_crypt FAILED");
@@ -109,7 +109,7 @@
 
         encodedlen = axis2_base64_encode_len(enclen);
         encoded_str = AXIS2_MALLOC(env->allocator, encodedlen);
-        ret = axis2_base64_encode_binary(encoded_str, out_main_buf, enclen);
+        ret = axis2_base64_encode_binary(encoded_str, OXS_BUFFER_GET_DATA(output, env), enclen);
         if (ret < 0)
         {
             oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
@@ -121,17 +121,19 @@
         ret = OXS_BUFFER_POPULATE(result, env, (unsigned char*)AXIS2_STRDUP(encoded_str, env), encodedlen);
         
         /*Free*/
-        AXIS2_FREE(env->allocator, out_main_buf);
-        out_main_buf = NULL;
+        OXS_BUFFER_FREE(output, env);
+        output = NULL;
         AXIS2_FREE(env->allocator, encoded_str);
         encoded_str = NULL;
 
     /*DECRYPTION*/
     }else if(OXS_CTX_GET_OPERATION(enc_ctx, env) == OXS_CTX_OPERATION_DECRYPT){
         unsigned char *decoded_data = NULL;/*Can be binary*/
-        unsigned char *out_main_buf = NULL;
         int decoded_len = -1;
         int enclen = -1;
+        oxs_buffer_t *decoded_buf = NULL;
+
+        decoded_buf = oxs_buffer_create(env);
 
         /*First we need to base64 decode*/
         decoded_data = AXIS2_MALLOC(env->allocator, axis2_base64_decode_len((char*)OXS_BUFFER_GET_DATA(input, env)));
@@ -142,19 +144,19 @@
                     "axis2_base64_decode_binary failed");
             return AXIS2_FAILURE;
         }
+        /*Populate decoded (input to the crypto function) buffer*/
+        ret = OXS_BUFFER_POPULATE(decoded_buf, env, decoded_data, decoded_len);
         /*Then we decrypt*/
-        enclen = openssl_block_cipher_crypt(env, oc_ctx,
-                decoded_data, decoded_len,  &out_main_buf, OPENSSL_DECRYPT);
+        enclen = openssl_bc_crypt(env, oc_ctx, decoded_buf, result, OPENSSL_DECRYPT);
        
         if(enclen < 0){
             oxs_error(ERROR_LOCATION, OXS_ERROR_DECRYPT_FAILED,
                     "openssl_block_cipher_crypt FAILED");
             return AXIS2_FAILURE;
         }
-        ret = OXS_BUFFER_POPULATE(result, env, AXIS2_STRMEMDUP(out_main_buf, enclen, env), enclen);
         /*Free*/
-        AXIS2_FREE(env->allocator, out_main_buf);
-        out_main_buf = NULL;
+        OXS_BUFFER_FREE(decoded_buf, env);
+        decoded_buf = NULL;
         AXIS2_FREE(env->allocator, decoded_data);
         decoded_data = NULL;
 

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/crypt.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/crypt.c?view=diff&rev=492924&r1=492923&r2=492924
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/crypt.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/crypt.c Thu Jan  4 23:11:59 2007
@@ -26,133 +26,170 @@
 
 #define BUFSIZE 64
 
-/**
-* @param do_encrypt should be set to 1 for encryption, 0 for decryption and -1 to
-* leave the value unchanged
-*/
-AXIS2_EXTERN int AXIS2_CALL  openssl_block_cipher_crypt(const axis2_env_t *env,
+AXIS2_EXTERN int AXIS2_CALL openssl_bc_crypt(const axis2_env_t *env,
         openssl_cipher_ctx_t *oc_ctx,
-        unsigned char *in_main_buf,
-        int in_main_len,
-        unsigned char **out_main_buf,
-        int do_encrypt)
+        oxs_buffer_t *input_buf,
+        oxs_buffer_t *output_buf,
+        int encrypt)
 {
     EVP_CIPHER_CTX ctx ;
-    oxs_key_t *key = NULL;
-    unsigned char *tempbuf = NULL;
-    unsigned char *tempbuf2 = NULL;
-    unsigned char *key_data = NULL;
-    unsigned char *inbuf = NULL;
-    unsigned char *outbuf = NULL;
-    int inlen, outlen, i,  out_buf_index, ret, bufsize;
-
-    
-    bufsize =  EVP_CIPHER_block_size(OPENSSL_CIPHER_CTX_GET_CIPHER(oc_ctx, env));
+    oxs_key_t *okey = NULL;
     
-    inbuf = AXIS2_MALLOC(env->allocator, bufsize + 1 );
-    outbuf = AXIS2_MALLOC(env->allocator, bufsize + EVP_MAX_BLOCK_LENGTH);
-
-    i = 0;
-    out_buf_index = 0;
-
-    /*Get the key*/
-    key = OPENSSL_CIPHER_CTX_GET_KEY(oc_ctx, env);
-    key_data = AXIS2_MALLOC(env->allocator, OXS_KEY_GET_SIZE(key, env));
-    key_data = memcpy(key_data,  OXS_KEY_GET_DATA(key, env), OXS_KEY_GET_SIZE(key, env));
-    /*Init ctx*/
-    EVP_CIPHER_CTX_init(&ctx);
-    ret = EVP_CipherInit_ex(&ctx, (EVP_CIPHER *)OPENSSL_CIPHER_CTX_GET_CIPHER(oc_ctx, env), NULL, NULL, NULL, do_encrypt);
-
-    /*EVP_CIPHER_CTX_set_padding(&ctx, 0);*/
-
-    ret  = EVP_CipherInit_ex(&ctx, NULL, NULL, key_data,
-            /*(unsigned char*)OPENSSL_CIPHER_CTX_GET_IV(oc_ctx, env),*/
-            NULL, /*>>NULL instead of IV. Here we do not use IV*/
-            do_encrypt);
-    for (;;)
-    {
-        memset(inbuf, 0 , bufsize);/*Reset memory for the inbuf*/
-        memcpy(inbuf, in_main_buf + (i * bufsize) , bufsize);/*Copy the first block to the inbuf*/
-
-        if (in_main_len <= i*bufsize) break; /*Finish!!! */
-
-        /*If we are in the last block, set inlen according to the in_main_len */
-        if (in_main_len <= (i + 1)*bufsize)
-        {
-            inlen = in_main_len - (i * bufsize);
-        }
-        else
-        {
-            inlen = bufsize;
-        }
-
-        if (do_encrypt == 1)
-        {
-            AXIS2_LOG_INFO(env->log, "[oxs][crypt.c] Encrypting block[%d] %s", inlen, inbuf);
-        }
-
-        memset(outbuf, 0 , bufsize + EVP_MAX_BLOCK_LENGTH);/*Reset memory for the outbuf*/
-        if (!EVP_CipherUpdate(&ctx, outbuf, &outlen, inbuf, inlen))
-        {
-            /* Error */
-            oxs_error(ERROR_LOCATION, OXS_ERROR_OPENSSL_FUNC_FAILED,
-                    "Encryption failed");
-
-            EVP_CIPHER_CTX_cleanup(&ctx);
-            return (-2);
+    unsigned char iv[EVP_MAX_IV_LENGTH];
+    unsigned char key[EVP_MAX_KEY_LENGTH];
+    int ret =0, iv_length =0, block_length =0;
+    int last = 0;
+    axis2_status_t status = AXIS2_FAILURE;
+
+    /**Init******************************************************************************/
+    iv_length = EVP_CIPHER_iv_length(OPENSSL_CIPHER_CTX_GET_CIPHER(oc_ctx, env));
+    if(encrypt){
+        ret = RAND_bytes(iv, iv_length);
+        /*IV to the output*/
+        status = OXS_BUFFER_APPEND(output_buf, env, iv, iv_length);
+    }else{ /*Decrypt*/
+        /*If data is less than the IV its an error*/
+        if(OXS_BUFFER_GET_SIZE(input_buf, env) < iv_length){
+            return -1;
         }
-        /*Write the encrypted block to the tempbuf2*/
-        tempbuf2 = AXIS2_MALLOC(env->allocator, out_buf_index + outlen);
+        /*Copy IV from the inbuf to our buffer*/
+        memcpy(iv, OXS_BUFFER_GET_DATA(input_buf, env), iv_length);
+        /*And remove from input*/
+        status = OXS_BUFFER_REMOVE_HEAD (input_buf, env, iv_length);
+    }
+    /*Get key*/
+    okey = OPENSSL_CIPHER_CTX_GET_KEY(oc_ctx, env);
+    memcpy(key,  OXS_KEY_GET_DATA(okey, env), OXS_KEY_GET_SIZE(okey, env));
+
+    /*Set iv */
+    ret = EVP_CipherInit(&ctx, (EVP_CIPHER *)OPENSSL_CIPHER_CTX_GET_CIPHER(oc_ctx, env), key, iv, encrypt);
+#ifndef OXS_OPENSSL_096
+    EVP_CIPHER_CTX_set_padding(&ctx, 0);
+#endif
+
+    block_length = EVP_CIPHER_block_size((EVP_CIPHER *)OPENSSL_CIPHER_CTX_GET_CIPHER(oc_ctx, env));
+
+    /**Update****************************************************************************/
+    for(;;){/*Loop untill all the data are encrypted*/
+        unsigned char *out_buf = NULL;
+        int  in_size =0, out_size =0, fixed=0, out_length = 0;
+        oxs_buffer_t *temp_in = NULL;
+
+        if (0 == OXS_BUFFER_GET_SIZE(input_buf, env)) {
+            last = 1;            
+            break; /*Quit loop if NO DATA!!! */
+        }
+       
+        /*If the amnt of data available is greater than the buffer size, we limit it to buffer size */
+        if(OXS_BUFFER_GET_SIZE(input_buf, env) > BUFSIZE){
+            in_size = BUFSIZE;
+        }else{
+            in_size = OXS_BUFFER_GET_SIZE(input_buf, env);
+        }
+        /*Create a temp buffer and populate only data size of BUFSIZE*/
+        temp_in = oxs_buffer_create(env);
+        status = OXS_BUFFER_POPULATE(temp_in, env, OXS_BUFFER_GET_DATA(input_buf, env), in_size);        
+
+        out_size = OXS_BUFFER_GET_SIZE(output_buf, env);
         
-        if (i > 0)
-        {/*Skip for the i=0 step*/
-            memmove(tempbuf2, tempbuf, out_buf_index);
-            /*Free*/
-            AXIS2_FREE(env->allocator, tempbuf);
-            tempbuf = NULL;
-        }
-        memmove(tempbuf2 + out_buf_index, outbuf, outlen);
-        tempbuf = tempbuf2; /*Assign new tempbuf2 to the old one*/
-        out_buf_index = out_buf_index + outlen;/*Update the writing position of the tempbuf*/
+        /*Set the output buffer size*/
+        status = OXS_BUFFER_SET_MAX_SIZE(output_buf, env, out_size + in_size + block_length);
 
+        out_buf = OXS_BUFFER_GET_DATA(output_buf, env) + out_size;        /*position to write*/
+        
+#ifndef OXS_OPENSSL_096
+        /*If decrypt, we copy the final data to the out_buf of size block_length*/
+        if(!ctx.encrypt) {
+            if(ctx.final_used) {
+                memcpy(out_buf, ctx.final, block_length);
+                out_buf += block_length;
+                fixed = 1;
+            }else {
+                fixed = 0;
+            }
+        }
+#endif
+        /* encrypt or decrypt */
+        ret = EVP_CipherUpdate(&ctx, out_buf, &out_length, OXS_BUFFER_GET_DATA(temp_in, env), in_size);
+
+#ifndef OXS_OPENSSL_096    
+        if(!ctx.encrypt) {
+            if (block_length > 1 && !ctx.buf_len) {
+                out_length -= block_length;
+                ctx.final_used = 1;
+                memcpy(ctx.final, &out_buf[out_length], block_length);
+            } else {
+                ctx.final_used = 0;
+            }
+            if (fixed) {
+                out_length += block_length;
+            }
+        }
+#endif
+        /* set correct output buffer size */
+        status = OXS_BUFFER_SET_SIZE(output_buf, env, out_size + out_length);    
+        if(AXIS2_FAILURE == status){
+            return -1;
+        }
+        /* remove the processed block from input */
+        status = OXS_BUFFER_REMOVE_HEAD(input_buf, env, in_size);
+        if(AXIS2_FAILURE == status){
+            return -1;
+        }
         
-        i++;
+        /*Free temp buf*/
+        OXS_BUFFER_FREE(temp_in, env);
+        temp_in = NULL;
+ 
     }/*End of for loop*/
 
-    ret = EVP_CipherFinal_ex(&ctx, outbuf, &outlen);
-    if (!ret)
-    {
-        /* Error */
-        ret = EVP_CIPHER_CTX_cleanup(&ctx);
-        oxs_error(ERROR_LOCATION, OXS_ERROR_OPENSSL_FUNC_FAILED,
-                    "Encryption Final_ex failed");
-        return (-3);
+    /**Final****************************************************************************/
+    /* by now there should be no input */
+    if(last == 1){
+        unsigned char pad[EVP_MAX_BLOCK_LENGTH];
+        unsigned char *out_buf = NULL;
+        int out_size = 0,  out_length = 0, out_length2 = 0;
+        
+        out_size = OXS_BUFFER_GET_SIZE(output_buf, env);
+        status = OXS_BUFFER_SET_MAX_SIZE(output_buf,  env, out_size + 2 * block_length);
+        out_buf = OXS_BUFFER_GET_DATA(output_buf, env)  + out_size;/*position to write*/
+#ifndef OXS_OPENSSL_096
+        if(encrypt){
+            int pad_length;
+            pad_length = block_length - ctx.buf_len;
+            /* generate random padding */
+            if(pad_length > 1) {
+                ret = RAND_bytes(pad, pad_length - 1);
+            }
+            pad[pad_length - 1] = pad_length;
+            /* write padding */
+            ret = EVP_CipherUpdate(&ctx, out_buf, &out_length, pad, pad_length);
+            out_buf += out_length;
+        }
+#endif        
+        /* finalize transform */
+        ret = EVP_CipherFinal(&ctx, out_buf, &out_length2);
+#ifndef OXS_OPENSSL_096
+        if(!encrypt){
+            if(block_length > 1) {
+                out_length2 = block_length - ctx.final[block_length - 1];
+                if(out_length2 > 0) {
+                    memcpy(out_buf, ctx.final, out_length2);
+                } else if(out_length2 < 0) {
+                    return(-1);
+                }
+            }
+        }
+#endif
+        /* set correct output buffer size */
+        status = OXS_BUFFER_SET_SIZE(output_buf, env, out_size + out_length + out_length2);
+        
+        EVP_CIPHER_CTX_cleanup(&ctx);
+        /*return the length of the outputbuf*/
+        return out_size + out_length + out_length2;
+    }else{
+        return -1;
     }
-    /*Alright now we need to write the last drop*/
-    tempbuf2 = AXIS2_MALLOC(env->allocator, out_buf_index + outlen);
-    memmove(tempbuf2, tempbuf, out_buf_index);
-    /*Free*/
-    AXIS2_FREE(env->allocator, tempbuf);
-    tempbuf = NULL;
     
-    memmove(tempbuf2 + out_buf_index, outbuf, outlen);
-    tempbuf = tempbuf2; /*Assign new tempbuf2 to the old one*/
-    out_buf_index = out_buf_index + outlen;/*Update the writing position of the tempbuf*/
-    EVP_CIPHER_CTX_cleanup(&ctx);
-    /*Assign the temp buf to the out_main_buf*/
-    *out_main_buf =  AXIS2_MALLOC(env->allocator, out_buf_index+outlen);
-    memmove(*out_main_buf, tempbuf, out_buf_index+outlen-1);
-    
-    /*Free*/
-    AXIS2_FREE(env->allocator, tempbuf2);
-    tempbuf2 = NULL;
-    AXIS2_FREE(env->allocator, inbuf);
-    inbuf = NULL;
-    AXIS2_FREE(env->allocator, outbuf);
-    outbuf = NULL;
-    AXIS2_FREE(env->allocator, key_data);
-    key_data = NULL;
-    return out_buf_index;
-
 }
 

Modified: 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=diff&rev=492924&r1=492923&r2=492924
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_encryption.c Thu Jan  4 23:11:59 2007
@@ -329,7 +329,7 @@
                   "Data encryption failed");
         return AXIS2_FAILURE;
     }
-    decrypted_data = (axis2_char_t *)OXS_BUFFER_GET_DATA(result_buf, env);
+    decrypted_data = AXIS2_STRMEMDUP(OXS_BUFFER_GET_DATA(result_buf, env), OXS_BUFFER_GET_SIZE(result_buf, env), env);
     /*De-serialize the decrypted content to build the node*/
     deserialized_node = (axiom_node_t*)oxs_axiom_deserialize_node(env, decrypted_data);
     if(!deserialized_node){

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=492924&r1=492923&r2=492924
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c (original)
+++ webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c Thu Jan  4 23:11:59 2007
@@ -131,7 +131,7 @@
 
     if (tmpl)
     {
-        printf("load_sample_xml SUCCESS");
+        printf("load_sample_xml SUCCESS\n");
     }
     else
     {



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