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/07/31 07:34:30 UTC

svn commit: r427017 - in /webservices/axis2/trunk/c/rampart/src: handlers/ omxmlsec/ omxmlsec/openssl/ util/

Author: damitha
Date: Sun Jul 30 22:34:29 2006
New Revision: 427017

URL: http://svn.apache.org/viewvc?rev=427017&view=rev
Log:
Applying patches.

Modified:
    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/enc_engine.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/key.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/cipher_ctx.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/token_cipher_value.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/token_encrypted_type.c
    webservices/axis2/trunk/c/rampart/src/util/Makefile.am

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=427017&r1=427016&r2=427017&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 Sun Jul 30 22:34:29 2006
@@ -152,6 +152,14 @@
                             return AXIS2_FAILURE;
                         }
                     
+                }else if( 0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_ENCRYPT, AXIS2_STRTRIM(env, item, NULL)) ){
+                        /*Do useful to verify encrypt*/       
+                        printf("InHandler : Encrypt\n"); 
+
+                }else if( 0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_SIGNATURE, AXIS2_STRTRIM(env, item, NULL)) ){
+                        /*Do useful to verify sign*/       
+                        printf("InHandler : Signature\n"); 
+
                 }else if (0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_TIMESTAMP, AXIS2_STRTRIM(env, item, NULL))){
                          axis2_qname_t *qname = NULL;
                          axis2_status_t valid_ts = AXIS2_FAILURE;

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=427017&r1=427016&r2=427017&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 Sun Jul 30 22:34:29 2006
@@ -25,6 +25,7 @@
 #include <rampart_constants.h>
 #include <username_token.h>
 #include <rampart_handler_util.h>
+/*#include <rampart_crypto_engine.h>*/
 #include <timestamp_token.h>
 
 /*********************** Function headers *********************************/
@@ -99,9 +100,10 @@
     axis2_param_t *param_out_flow_security = NULL;
     axiom_node_t *sec_node =  NULL;    
     axiom_element_t *sec_ele = NULL;
-   axis2_array_list_t *action_list = NULL;
+    axis2_array_list_t *action_list = NULL;
     axis2_param_t *param_action = NULL;
     axis2_char_t *items = NULL;
+    axis2_status_t enc_status =  AXIS2_FAILURE;
 
     AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
     AXIS2_PARAM_CHECK (env->error, msg_ctx, AXIS2_FAILURE);
@@ -189,25 +191,43 @@
             AXIOM_ELEMENT_DECLARE_NAMESPACE (sec_ele, env,
                                            sec_node, sec_ns_obj);
             */
+            
+            /*Get action items seperated by spaces*/
             item = strtok (items," ");
 
+            /*Iterate thru items. Eg. Usernmaetoken, Timestamp, Encrypt, Signature*/
             while (item != NULL)
             {
+                /*Username token*/
                 if(0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_USERNAMETOKEN , 
                         AXIS2_STRTRIM(env, item, NULL)))
                 {
                     sec_node = rampart_build_username_token(env, 
                         ctx, param_action,  sec_node, sec_ns_obj);
-                    if(!sec_node)
+                    if(!sec_node){
                           return AXIS2_FAILURE;
-    
+                    }
+                /*Timestamp token*/
                 }else if(0 == AXIS2_STRCMP(RAMPART_ACTION_ITEMS_TIMESTAMP, 
                     AXIS2_STRTRIM(env, item, NULL)))
                 {
                     sec_node = rampart_build_timestamp_token(env, 
                         ctx, sec_node, sec_ns_obj, 300);
-                    if(!sec_node)
+                    if(!sec_node){
                           return AXIS2_FAILURE;
+                    }
+                /*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);*/
+                    
+                /*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"); */
+
+                /*Any other type of action*/ 
                 }else
                 {
                     rampart_print_info(env,

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=427017&r1=427016&r2=427017&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/enc_engine.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/enc_engine.c Sun Jul 30 22:34:29 2006
@@ -17,6 +17,7 @@
 #include <axis2_qname.h>
 #include <axiom_namespace.h>
 #include <axiom_node.h>
+#include <axiom_element.h>
 #include <stdio.h>
 #include <axis2_util.h>
 #include <oxs_constants.h>
@@ -30,22 +31,36 @@
 #include <openssl_constants.h>
 
 
+
+/*TODO Default IV*/
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
-oxs_enc_encrypt(const axis2_env_t *env, 
+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;
+    unsigned char *out_main_buf = NULL;
     openssl_evp_block_cipher_ctx_ptr bc_ctx = NULL;
-    axis2_char_t* iv =  "12345678";   
-    axis2_char_t* cipher_name =  NULL;   
+    axis2_char_t *iv =  OPENSSL_DEFAULT_IV8;   
+    axis2_char_t *cipher_name =  NULL;   
+    axis2_char_t *encoded_str=NULL;
+    axis2_char_t *in_data = NULL;
+    int ret, enclen, encodedlen;
+
+    /*Safety initializations*/
+    ret = AXIS2_FAILURE;
+    enclen = -1;
+    encodedlen = -1;   
 
-    int ret;
  
+    /*Create the context*/
     bc_ctx = openssl_evp_block_cipher_ctx_create(env);
-    if(!bc_ctx) return (-1);
+    if(!bc_ctx){
+         oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "openssl_evp_block_cipher_ctx_create failed");
+         return AXIS2_FAILURE;
+    }
     
     /*Set the key*/
     bc_ctx->key = AXIS2_STRDUP(key, env);
@@ -56,6 +71,9 @@
     /*TODO: Get the cipher by giving the algoritm attribute */
     cipher_name = oxs_get_cipher(env, (unsigned char*)enc_ctx->encmtd_algorithm);
     if(!cipher_name){
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "oxs_get_cipher failed");
+        
         return AXIS2_FAILURE;
     } 
 
@@ -63,28 +81,164 @@
                             OPENSSL_ENCRYPT, cipher_name);
    
     if(ret < 0){
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "openssl_evp_block_cipher_ctx_init failed");
         return AXIS2_FAILURE;
     }
-    ret = openssl_block_cipher_crypt(env, bc_ctx,
+    /*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,
                                          input->data,  &out_main_buf, OPENSSL_ENCRYPT);
-    if(ret < 0) return AXIS2_FAILURE;
+    
+    /*If this is to decrypt, then we need to base64decode first*/
+    }else if(enc_ctx->operation == oxs_operation_decrypt){
+        in_data = AXIS2_MALLOC(env->allocator, axis2_base64_decode_len( (char*)(enc_ctx->inputdata)));
+        axis2_base64_decode(in_data, (char*)(enc_ctx->inputdata)); 
+        enclen = openssl_block_cipher_crypt(env, bc_ctx,
+                                         (unsigned char*)in_data,  &out_main_buf, OPENSSL_DECRYPT);
+    }else{
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "Invalid operation type %d", enc_ctx->operation);
+        return AXIS2_FAILURE;
+
+    }
+
+    if(enclen < 0){
+         oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "openssl_block_cipher_crypt failed");
+         return AXIS2_FAILURE;
+    }
    
 #if 0 
     FILE *outf;
     outf = fopen("outbuf", "wb");
-    fwrite(out_main_buf, 1, ret, outf);
+    fwrite(out_main_buf, 1, enclen, outf);
 #endif
     
-    oxs_buffer_set_size(env, result, ret);
-    result->data = out_main_buf;
     
+    /*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);
+        if(ret < 0){
+            oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "axis2_base64_encode");
+            return AXIS2_FAILURE;
+        }
+    
+        /*Attach the result to the result buf*/    
+        result->size = encodedlen;
+        result->data = (unsigned char*)AXIS2_STRDUP(encoded_str, env);
+    }else if(enc_ctx->operation == oxs_operation_decrypt){
+        result->size = enclen;
+        result->data = (unsigned char*)AXIS2_STRDUP(out_main_buf, env);
+    }else{
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "Invalid operation type %d", enc_ctx->operation);
+        return AXIS2_FAILURE;
+
+    }
     return AXIS2_SUCCESS;
 }
 
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_enc_populate_cipher_value(const axis2_env_t *env,
+                             axiom_node_t* template_node,
+                             oxs_buffer_ptr databuf)
+{
+    axis2_status_t ret = AXIS2_FAILURE;
+    axiom_element_t *template_ele = NULL, *cv_ele = NULL, *cd_ele = NULL;
+    axiom_node_t *cv_node = NULL, *cd_node = NULL;
+    axis2_qname_t *qname = NULL;
+
+    template_ele = AXIOM_NODE_GET_DATA_ELEMENT(template_node, env);
+    
+    if(!template_ele){
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "Cannot retriew  element from the template given");
+        return AXIS2_FAILURE;
+    }
+
+    /*Get CipherData*/
+    qname = axis2_qname_create(env, OXS_NodeCipherData, NULL, NULL);
+    cd_ele = AXIOM_ELEMENT_GET_FIRST_CHILD_WITH_QNAME(template_ele, env, qname, template_node, &cd_node);
+    
+    if(!cd_ele){
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "Cannot retriew CipherData element from %s", AXIOM_ELEMENT_GET_LOCALNAME(template_ele, env));
+        return AXIS2_FAILURE;
+    }
+
+    AXIS2_QNAME_FREE(qname, env);
+    qname= NULL;
+
+    /*Get CipherValue*/
+    qname = axis2_qname_create(env, OXS_NodeCipherValue, NULL, NULL);
+    cv_ele = AXIOM_ELEMENT_GET_FIRST_CHILD_WITH_QNAME(cd_ele, env, qname, cd_node, &cv_node);
+   
+    if(!cv_ele){
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "Cannot retriew CipherValue element from %s", AXIOM_ELEMENT_GET_LOCALNAME(cd_ele, env));
+        return AXIS2_FAILURE;
+
+    }
+    
+
+    ret =  AXIOM_ELEMENT_SET_TEXT(cv_ele, env, databuf->data , cv_node); 
+    if(ret != AXIS2_SUCCESS){
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "Cannot set data to the CipherValue element");
+        return AXIS2_FAILURE;
+    }
+    
+    return AXIS2_SUCCESS;
+}
 /*We expect user to provide a template as below*/
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
+oxs_enc_decrypt_template(const axis2_env_t *env,
+                        axiom_node_t* template_node,
+                        axis2_char_t** decrypted_data,
+                        enc_ctx_ptr enc_ctx
+                        )
+{
+    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;
+    enc_ctx->mode = enc_ctx_mode_encrypted_data;
+
+    ret = oxs_enc_encryption_data_node_read(env, enc_ctx, template_node);
+    if(ret != AXIS2_SUCCESS){
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "openssl_block_cipher_crypt failed");
+        return ret;
+    }
+
+    /*Now look for data to be decrypted*/
+    input = enc_ctx->inputdata;
+    result = oxs_create_buffer(env, OXS_BUFFER_INITIAL_SIZE);
+     
+    key = enc_ctx->key->data;
+
+    ret = oxs_enc_crypt(env, enc_ctx, input, key, result ); 
+    if(ret != AXIS2_SUCCESS){
+           oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "oxs_enc_encrypt failed");
+        return ret;
+    }
+
+    *decrypted_data =  result->data;
+}
+
+/*We expect user to provide a template as below*/
+/**/
+AXIS2_EXTERN axis2_status_t AXIS2_CALL
 oxs_enc_encrypt_template(const axis2_env_t *env,
-                        axiom_node_t* template, 
+                        axiom_node_t* template_node, 
                         axis2_char_t* data,
                         enc_ctx_ptr enc_ctx
                         )
@@ -99,8 +253,10 @@
     enc_ctx->operation = oxs_operation_encrypt;
     enc_ctx->mode = enc_ctx_mode_encrypted_data;
      
-    ret = oxs_enc_encryption_data_node_read(env, enc_ctx, template);
+    ret = oxs_enc_encryption_data_node_read(env, enc_ctx, template_node);
     if(ret != AXIS2_SUCCESS){
+        oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "openssl_block_cipher_crypt failed");    
         return ret;
     }
     
@@ -108,16 +264,21 @@
     
     /*Create the input buffer*/
     input = oxs_string_to_buffer(env, data);
-    
-    result = oxs_create_buffer(env, ret);
-    
+    result = oxs_create_buffer(env, OXS_BUFFER_INITIAL_SIZE);
+     
     key = enc_ctx->key->data;
 
-    oxs_enc_encrypt(env, enc_ctx, input, key, result ); 
-    
-    printf("Encrypted Result = %s\n", oxs_buffer_to_string(env, result));
+    ret = oxs_enc_crypt(env, enc_ctx, input, key, 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);
+   
      
-    return ret;
+    return AXIS2_SUCCESS;
     
 }
 
@@ -127,13 +288,11 @@
 {
     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*/
 
-
-    printf("\n Found node CD %s\n", AXIOM_NODE_TO_STRING(node_cipher_data, env)); 
-    
     cur = AXIOM_NODE_GET_FIRST_CHILD(node_cipher_data, env); 
     
     if(!cur){        
@@ -145,17 +304,24 @@
         /*Got a cipher value*/
         if(enc_ctx->operation == oxs_operation_decrypt)
         {  
-            printf("\n Found node CV %s\n", AXIOM_NODE_TO_STRING(node_cipher_data, env)); 
             enc_ctx->cipher_value_node = cur;
+            ele = AXIOM_NODE_GET_DATA_ELEMENT(cur, env);
+            /*Read data from the CipherValue node and set it to the context*/
+            data = AXIOM_ELEMENT_GET_TEXT(ele, env, cur);
+            enc_ctx->inputdata = AXIS2_STRDUP(data, env);
         } 
     }else if(oxs_axiom_check_node_name(env, cur, OXS_NodeCipherReference, OXS_EncNs )){
         /*Got a cipher reference*/
         /*TODO : Support Cipher references*/
+        /*Check cipher reference and set it to enc_ctx->cipher_value_node*/
     }
 
     return AXIS2_SUCCESS;    
 }
-
+/**
+* We have EncryptedData of EncryptedKey node by now. 
+* So process it and populate the ctx.
+*/
 AXIS2_EXTERN axis2_status_t AXIS2_CALL
 oxs_enc_encryption_data_node_read(const axis2_env_t *env,
             enc_ctx_ptr enc_ctx, axiom_node_t* node)
@@ -163,104 +329,87 @@
     axiom_node_t* cur = NULL;
     axiom_element_t *ele = NULL;
     int ret;
-
-    if(!(enc_ctx->operation == oxs_operation_encrypt) || (enc_ctx->operation == oxs_operation_decrypt)) return (-1);
-
+    
+    /* Operation is either encrypt or decrypt */
+    if(!((enc_ctx->operation == oxs_operation_encrypt) || (enc_ctx->operation == oxs_operation_decrypt))) return (-1);
+    
+    /*Check which mode we are in.
+      1. Encrypted Data
+      2. Encrypted Key
+    */
+    
     switch(enc_ctx->mode) {
     case enc_ctx_mode_encrypted_data:
         if(!(oxs_axiom_check_node_name(env, node, OXS_NodeEncryptedData, OXS_EncNs )))
         {
+            oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "No %s node found",OXS_NodeEncryptedData );
             return AXIS2_FAILURE;
         }
         break;
     case enc_ctx_mode_encrypted_key:
         if(!(oxs_axiom_check_node_name(env, node, OXS_NodeEncryptedKey, OXS_EncNs)))
         {
+            oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "No %s node found", OXS_NodeEncryptedKey);
              return AXIS2_FAILURE;
         }
         break;
     }
-
     
+    enc_ctx->enc_data_node = node;
+    
+    /*Element is either Encrypted Data or Encrypted Key*/ 
     ele = AXIOM_NODE_GET_DATA_ELEMENT(node, env);
-
-    if(!ele) return AXIS2_FAILURE;
-
+    if(!ele){
+         oxs_error(ERROR_LOCATION, OXS_ERROR_INVALID_DATA,
+                     "No element found");
+         return AXIS2_FAILURE;
+    }
+    
+    /*Populate ctx with id, type, mime and encoding types if found*/
     enc_ctx->id = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(ele, env, OXS_AttrId);
     enc_ctx->type = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(ele, env, OXS_AttrType);
     enc_ctx->mime_type = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(ele, env, OXS_AttrMimeType);
     enc_ctx->encoding = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(ele, env, OXS_AttrEncoding);
-
     if(enc_ctx->mode == enc_ctx_mode_encrypted_key) {
         enc_ctx->recipient = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(ele, env, OXS_AttrRecipient);
     }
     
-    printf("\n1 Found node %s\n", AXIOM_NODE_TO_STRING(node, env));
     cur = AXIOM_NODE_GET_FIRST_CHILD(node, env);
 
-    /*TODO remove check*/
-    if(cur == NULL){    
-         printf("Geeeee\n");
-         return AXIS2_FAILURE;
-    }
     /* first node is optional EncryptionMethod, we'll read it later */
     if((cur != NULL) && (oxs_axiom_check_node_name(env, cur, OXS_NodeEncryptionMethod, OXS_EncNs))) {
-    printf("\n2 Found node %s\n", AXIOM_NODE_TO_STRING(cur, env));
         enc_ctx->enc_method_node = cur;
         cur = AXIOM_NODE_GET_NEXT_SIBLING(cur, env);
     }
 
-
     /* next node is optional KeyInfo, we'll process it later */
     if((cur != NULL) && (  oxs_axiom_check_node_name(env, cur, OXS_NodeKeyInfo, OXS_DSigNs))) {
-        printf("\n3 Found node %s\n", AXIOM_NODE_TO_STRING(cur, env));
         enc_ctx->key_info_node = cur;
         cur = AXIOM_NODE_GET_NEXT_SIBLING(cur, env);
     }
 
-
-
     /* next is required CipherData node */
     if((cur == NULL) || (!oxs_axiom_check_node_name(env, cur, OXS_NodeCipherData, OXS_EncNs))) {
-        printf("\n4 Found node %s\n", AXIOM_NODE_TO_STRING(cur, env));
         return AXIS2_FAILURE;
     }
 
-
     ret = oxs_enc_cipher_data_node_read(env, enc_ctx, cur);
     if(ret < 0) {
-        printf("\n5 Processing failed %s\n", AXIOM_NODE_TO_STRING(cur, env));
         return AXIS2_FAILURE;
     }
     
-
-    cur = AXIOM_NODE_GET_NEXT_SIBLING(cur, env);
-
-
-    /* next is optional EncryptionProperties node (we simply ignore it) */
-    if((cur != NULL) && (oxs_axiom_check_node_name(env, cur, OXS_NodeEncryptionProperties, OXS_EncNs))) {
-        printf("\n6 Found node %s\n", AXIOM_NODE_TO_STRING(cur, env));
-        cur = AXIOM_NODE_GET_NEXT_SIBLING(cur, env);
-    }
-
-    /* there are more possible nodes for the <EncryptedKey> node */
-    if(enc_ctx->mode == enc_ctx_mode_encrypted_key) {
-    /* next is optional ReferenceList node (we simply ignore it) */
-        if((cur != NULL) && (oxs_axiom_check_node_name(env, cur, OXS_NodeReferenceList, OXS_EncNs))) {
-            printf("\n6 Found node %s\n", AXIOM_NODE_TO_STRING(cur, env));
-            cur = AXIOM_NODE_GET_NEXT_SIBLING(cur, env);
-        }
-    }
-
        
     /* now read the encryption method node */
     if(enc_ctx->enc_method_node != NULL) {
         ele = AXIOM_NODE_GET_DATA_ELEMENT(enc_ctx->enc_method_node, env);
         enc_ctx->encmtd_algorithm = AXIOM_ELEMENT_GET_ATTRIBUTE_VALUE_BY_NAME(ele, env, OXS_AttrAlgorithm);
-
     }
-        
-return AXIS2_SUCCESS;
+      
+    /*If you need to populate the context more this is the place*/   
+
+    return AXIS2_SUCCESS;
 
 }
 

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/key.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/key.c?rev=427017&r1=427016&r2=427017&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/key.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/key.c Sun Jul 30 22:34:29 2006
@@ -22,6 +22,7 @@
 
 AXIS2_EXTERN oxs_key_ptr AXIS2_CALL
 oxs_key_create_key(const axis2_env_t *env,
+                    axis2_char_t *name,
                     unsigned char *data,
                     int size,
                     int usage
@@ -30,6 +31,7 @@
     oxs_key_ptr key = NULL;
     key = (oxs_buffer_ptr)AXIS2_MALLOC(env->allocator,sizeof(oxs_key)); 
     
+    key->name = name;
     key->data = data;
     key->size = size;
     key->usage = usage;
@@ -51,7 +53,7 @@
     buf = oxs_create_buffer(env, OXS_KEY_DEFAULT_SIZE);
     ret = oxs_buffer_read_file(env, buf, file_name);
     
-    key = oxs_key_create_key(env, buf->data, buf->size, OXS_KEY_USAGE_NONE);
+    key = oxs_key_create_key(env, file_name, buf->data, buf->size, OXS_KEY_USAGE_NONE);
     return key; 
     
 }

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=427017&r1=427016&r2=427017&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 Sun Jul 30 22:34:29 2006
@@ -83,15 +83,17 @@
     if(!bc_ctx->key) return (-1);
        
     /*Check if key and IV sizes are not applicable for the cipher*/
-    if(EVP_CIPHER_key_length(bc_ctx->cipher) != strlen(bc_ctx->cipher) ){
-        printf("Key size is not applicable for the cipher\n");
+#if 0
+    if(EVP_CIPHER_key_length(bc_ctx->cipher) != strlen(bc_ctx->key) ){
+        printf("Key size is not applicable for the cipher %d = %d\n", EVP_CIPHER_key_length(bc_ctx->cipher),  strlen(bc_ctx->key)  );
         return (-1);
     }  
 
     if(EVP_CIPHER_iv_length(bc_ctx->cipher) != strlen(bc_ctx->iv) ){
-        printf("IV size is not applicable for the cipher\n");
+        printf("IV size is not applicable for the cipher %d = %d\n", EVP_CIPHER_iv_length(bc_ctx->cipher) , strlen(bc_ctx->iv) );
         return (-1);
     }  
+#endif
 
     /*Init ctx*/    
     EVP_CIPHER_CTX_init(&(bc_ctx->cipher_ctx));

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/token_cipher_value.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/token_cipher_value.c?rev=427017&r1=427016&r2=427017&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/token_cipher_value.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/token_cipher_value.c Sun Jul 30 22:34:29 2006
@@ -43,9 +43,11 @@
                     OXS_ERROR_ELEMENT_FAILED,"Error creating cipher value element");
         return NULL;
     }  
+    
+    if(cipher_val){
+        ret  = AXIOM_ELEMENT_SET_TEXT(cipher_value_ele, env, cipher_val, cipher_value_node);
+    }
 
-    ret  = AXIOM_ELEMENT_SET_TEXT(cipher_value_ele, env, cipher_val, cipher_value_node);
-   
     return cipher_value_node; 
      
 }

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=427017&r1=427016&r2=427017&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 Sun Jul 30 22:34:29 2006
@@ -21,6 +21,7 @@
 #include <axiom_attribute.h>
 #include <axiom_element.h>
 
+/*TODO These names should be changed to oxs_token_build_XXX_node*/
 
 AXIS2_EXTERN axiom_node_t* AXIS2_CALL
 oxs_token_build_encrypted_type_element(const axis2_env_t *env,
@@ -46,13 +47,17 @@
                     OXS_ERROR_ELEMENT_FAILED,"Error creating encrypted type element");
         return NULL;
     }  
-
-    type_attr =  axiom_attribute_create (env, OXS_AttrType, type_attribute, NULL);
-    id_attr = axiom_attribute_create(env, OXS_AttrId, id, NULL);
-
-    ret = AXIOM_ELEMENT_ADD_ATTRIBUTE(encrypted_type_ele, env, type_attr, encrypted_type_node);  
-    ret = AXIOM_ELEMENT_ADD_ATTRIBUTE(encrypted_type_ele, env, id_attr, encrypted_type_node);  
-   
+    
+    if(type_attribute){
+        type_attr =  axiom_attribute_create (env, OXS_AttrType, type_attribute, NULL);
+        ret = AXIOM_ELEMENT_ADD_ATTRIBUTE(encrypted_type_ele, env, type_attr, encrypted_type_node);  
+    }
+    
+    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);  
+    }
+    
     return encrypted_type_node; 
      
 }

Modified: webservices/axis2/trunk/c/rampart/src/util/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/Makefile.am?rev=427017&r1=427016&r2=427017&view=diff
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/util/Makefile.am Sun Jul 30 22:34:29 2006
@@ -2,7 +2,7 @@
 
 noinst_LTLIBRARIES = librampart_util.la
 
-librampart_util_la_SOURCES = rampart_crypto_util.c rampart_util.c rampart_handler_util.c username_token.c  timestamp_token.c
+librampart_util_la_SOURCES = rampart_crypto_engine.c rampart_crypto_util.c rampart_util.c rampart_handler_util.c username_token.c  timestamp_token.c
 
 librampart_util_la_LIBADD  = -lssl\
 			-lcrypto 



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