axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kausha...@apache.org
Subject svn commit: r504883 - in /webservices/axis2/trunk/c/rampart: include/oxs_xml_signature.h src/omxmlsec/Makefile.am src/omxmlsec/sign_part.c src/omxmlsec/xml_signature.c test/Makefile.am test/omxmlsec/test.c
Date Thu, 08 Feb 2007 13:17:51 GMT
Author: kaushalye
Date: Thu Feb  8 05:17:51 2007
New Revision: 504883

URL: http://svn.apache.org/viewvc?view=rev&rev=504883
Log:
Implementing XML signature in OMXMLSecurity. 


Modified:
    webservices/axis2/trunk/c/rampart/include/oxs_xml_signature.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am
    webservices/axis2/trunk/c/rampart/src/omxmlsec/sign_part.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c
    webservices/axis2/trunk/c/rampart/test/Makefile.am
    webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c

Modified: webservices/axis2/trunk/c/rampart/include/oxs_xml_signature.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_xml_signature.h?view=diff&rev=504883&r1=504882&r2=504883
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_xml_signature.h (original)
+++ webservices/axis2/trunk/c/rampart/include/oxs_xml_signature.h Thu Feb  8 05:17:51 2007
@@ -20,8 +20,8 @@
 
 
 /**
-  * @file oxs_xml_enc.h
-  * @brief Does the XML encryption for OMXMLSecurity  
+  * @file oxs_xml_signature.h
+  * @brief Does the XML Signature for OMXMLSecurity  
   */
 
 #include <axis2_defines.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=504883&r1=504882&r2=504883
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/Makefile.am Thu Feb  8 05:17:51 2007
@@ -1,5 +1,5 @@
 SUBDIRS = tokens openssl c14n
-noinst_LTLIBRARIES = libomxmlsec.la
+lib_LTLIBRARIES = libomxmlsec.la
 
 libomxmlsec_la_SOURCES = ctx.c  buffer.c key.c cipher.c error.c axis2_utils.c axiom.c \
                          iv.c xml_encryption.c encryption.c\

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/sign_part.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/sign_part.c?view=diff&rev=504883&r1=504882&r2=504883
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/sign_part.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/sign_part.c Thu Feb  8 05:17:51 2007
@@ -100,6 +100,9 @@
     const axis2_env_t *env,
     axiom_node_t *node)
 {
+    if(sign_part->node){
+        sign_part->node = NULL;
+    }
     sign_part->node = node;
     return AXIS2_SUCCESS;
 }
@@ -110,6 +113,9 @@
     const axis2_env_t *env,
     axis2_array_list_t *transforms)
 {
+    if(sign_part->transforms){
+        sign_part->transforms = NULL;
+    }
     sign_part->transforms = transforms;
     return AXIS2_SUCCESS;
 }

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c?view=diff&rev=504883&r1=504882&r2=504883
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c Thu Feb  8 05:17:51 2007
@@ -22,6 +22,7 @@
 #include <oxs_buffer.h>
 #include <oxs_cipher.h>
 #include <openssl_rsa.h>
+#include <openssl_digest.h>
 #include <oxs_sign_ctx.h>
 #include <oxs_sign_part.h>
 #include <oxs_token_ds_reference.h>
@@ -36,6 +37,7 @@
 #include <oxs_token_signed_info.h>
 /*Private functions*/
 
+
 /*parent is ds:SignedInfo*/
 static axis2_status_t
 rampart_xml_sig_build_reference(const axis2_env_t *env,
@@ -60,7 +62,8 @@
 
     /*Get transforms if any*/
     transforms = oxs_sign_part_get_transforms(sign_part, env);
-    if(0 < AXIS2_ARRAY_LIST_SIZE(transforms, env)){
+    
+    if((transforms) && (0 < AXIS2_ARRAY_LIST_SIZE(transforms, env))){
         axiom_node_t *transforms_node = NULL;
         /*Add ds:Transforms element*/
         transforms_node = oxs_token_build_transforms_element(env, reference_node);
@@ -76,15 +79,45 @@
 
     /*Make digest.*/
     digest_mtd = oxs_sign_part_get_digest_mtd(sign_part, env);
-    digest = "j6lwx3rvEPO0vKtMup4NbeVu8nk=";/*TODO : Hard coded*/ 
+    digest = openssl_sha1(env, serialized_node, axis2_strlen(serialized_node)); 
 
     /*Construct nodes*/
     digest_mtd_node = oxs_token_build_digest_method_element(env, reference_node, digest_mtd);
     digest_value_node = oxs_token_build_digest_value_element(env, reference_node, digest);
-
+    
     return AXIS2_SUCCESS; 
 }
 
+static axis2_status_t
+rampart_xml_sig_sign_signed_info(const axis2_env_t *env,
+    axiom_node_t *signature_node,
+    axiom_node_t *signed_info_node,
+    oxs_sign_ctx_t *sign_ctx)
+{
+    axis2_char_t *signature_val = "FAKE_SIG_VAL(734dwe93721fd8y2==";
+    axis2_char_t *serialized_signed_info = NULL;
+    axis2_char_t *sign_algo = NULL;
+    axis2_char_t *c14n_algo = NULL;
+    axiom_node_t *signature_val_node = NULL;
+
+    /*TODO : Cannonicalize <SignedInfo>*/
+    c14n_algo = oxs_sign_ctx_get_c14n_mtd(sign_ctx, env);
+
+    /*Then serialize <SignedInfo>*/
+    serialized_signed_info = AXIOM_NODE_TO_STRING(signed_info_node, env);
+    
+    /*Then sign... NOTE: The signature process includes making the digest. e.g. rsa-sha1
=> RSA(SHA-1(contents))*/ 
+    sign_algo = oxs_sign_ctx_get_sign_mtd_algo(sign_ctx, env);
+
+    /*Sign the data using the private key*/
+    signature_val = "MC0CFFrVLtRlk=";
+    
+    /*Construct <SignatureValue>*/
+    signature_val_node = oxs_token_build_signature_value_element(env, signature_node, signature_val);
+
+    return AXIS2_SUCCESS;
+}
+
 /*Public functions*/
 AXIS2_EXTERN axis2_status_t AXIS2_CALL 
 oxs_xml_sig_sign(const axis2_env_t *env,
@@ -94,11 +127,9 @@
     axiom_node_t *signed_info_node = NULL;
     axiom_node_t *signature_node = NULL;
     axiom_node_t *signature_mtd_node = NULL;
-    axiom_node_t *signature_val_node = NULL;
     axiom_node_t *c14n_mtd_node = NULL;
     axis2_char_t *sign_algo = NULL;
     axis2_char_t *c14n_algo = NULL;
-    axis2_char_t *signature_val = NULL;
     axis2_array_list_t *sign_parts = NULL;
     int i=0;
 
@@ -122,22 +153,16 @@
     /*For each and every signature part in sig ctx,*/
     for (i = 0; i < AXIS2_ARRAY_LIST_SIZE(sign_parts, env); i++){
         oxs_sign_part_t *sign_part =  NULL;
+
         /*TODO Get ith sign_part*/
-        
+        sign_part = (oxs_sign_part_t*)axis2_array_list_get(sign_parts, env, i);
         /*Create <ds:Reference> elements */
         rampart_xml_sig_build_reference(env, signed_info_node, sign_part);
 
     }
-    /*Cannonicalize <SignedInfo>*/
-    
+    /*At this point we have a complete <SignedInfo> node. Now we need to sign it*/
+    rampart_xml_sig_sign_signed_info(env, signature_node, signed_info_node, sign_ctx); 
 
-    /*Then serialize <SignedInfo>*/
-     
-    /*Sign the data using the private key*/
-    signature_val = "MC0CFFrVLtRlk=";
-    
-    /*Construct <SignatureValue>*/
-    signature_val_node = oxs_token_build_signature_value_element(env, signature_node, signature_val);
     
     return AXIS2_SUCCESS;
 }

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=504883&r1=504882&r2=504883
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/test/Makefile.am Thu Feb  8 05:17:51 2007
@@ -1,2 +1,2 @@
-SUBDIRS = openssl c14n
+SUBDIRS = openssl c14n omxmlsec
 

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=504883&r1=504882&r2=504883
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c (original)
+++ webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c Thu Feb  8 05:17:51 2007
@@ -20,6 +20,7 @@
 #include <axis2_util.h>
 #include <oxs_constants.h>
 #include <oxs_utility.h>
+#include <oxs_axiom.h>
 #include <axiom.h>
 #include <axiom_xml_reader.h>
 #include <axis2_env.h>
@@ -72,6 +73,7 @@
     axiom_node_t *tmpl = NULL;
     oxs_sign_part_t *sign_part = NULL;
     oxs_sign_ctx_t *sign_ctx = NULL;
+    axis2_array_list_t *sign_parts = NULL;
     FILE *outf;
 
     env = axis2_env_create_all("echo.log", AXIS2_LOG_LEVEL_TRACE);
@@ -94,14 +96,19 @@
     
     /*Sign specific*/
     sign_part = oxs_sign_part_create(env);
+    status = AXIS2_FAILURE;
     status = oxs_sign_part_set_node(sign_part, env, AXIOM_NODE_GET_FIRST_CHILD(tmpl, env));
 
+    sign_parts = axis2_array_list_create(env, 1);
+    axis2_array_list_add(sign_parts, env, sign_part);
     sign_ctx = oxs_sign_ctx_create(env);
+    oxs_sign_ctx_set_sign_parts(sign_ctx, env, sign_parts);
+    /*Sign*/
+    oxs_xml_sig_sign(env, sign_ctx, tmpl);
 
-    
     signed_result = AXIOM_NODE_TO_STRING(tmpl, env) ;
 
-    outf = fopen("result.xml", "wb");
+    outf = fopen("result-sign.xml", "wb");
     fwrite(signed_result, 1, AXIS2_STRLEN(signed_result), outf);
     fclose(outf);
     return 0;



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


Mime
View raw message