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/10/20 07:22:30 UTC

svn commit: r465999 - in /webservices/axis2/trunk/c/rampart: include/openssl_digest.h include/rampart_crypto_util.h samples/client/echo/echo.c src/omxmlsec/openssl/Makefile.am src/omxmlsec/openssl/digest.c src/util/rampart_crypto_util.c

Author: kaushalye
Date: Thu Oct 19 22:22:30 2006
New Revision: 465999

URL: http://svn.apache.org/viewvc?view=rev&rev=465999
Log:
Make the usage of nonce compatible with rampart/java. 

Added:
    webservices/axis2/trunk/c/rampart/include/openssl_digest.h
    webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/digest.c
Modified:
    webservices/axis2/trunk/c/rampart/include/rampart_crypto_util.h
    webservices/axis2/trunk/c/rampart/samples/client/echo/echo.c
    webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/Makefile.am
    webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c

Added: webservices/axis2/trunk/c/rampart/include/openssl_digest.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/openssl_digest.h?view=auto&rev=465999
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/openssl_digest.h (added)
+++ webservices/axis2/trunk/c/rampart/include/openssl_digest.h Thu Oct 19 22:22:30 2006
@@ -0,0 +1,55 @@
+/*
+ *   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 <openssl/sha.h>
+
+#include <axis2_utils_defines.h>
+#include <axis2_defines.h>
+#include <axis2_env.h>
+
+/**
+  * @file openssl_digest.h
+  * @brief 
+  */
+#ifndef OPENSSL_DIGEST
+#define OPENSSL_DIGEST
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+  * @defgroup 
+  * @ingroup 
+  */
+
+
+  /** 
+  * Calculate the digest of the input
+  * @return calculated digest
+  */ 
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+   openssl_sha1(const axis2_env_t *env,
+                axis2_char_t *input,
+                int length);
+                                                                            
+
+/* @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif    /* OPENSSL_DIGEST */

Modified: webservices/axis2/trunk/c/rampart/include/rampart_crypto_util.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/rampart_crypto_util.h?view=diff&rev=465999&r1=465998&r2=465999
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/rampart_crypto_util.h (original)
+++ webservices/axis2/trunk/c/rampart/include/rampart_crypto_util.h Thu Oct 19 22:22:30 2006
@@ -14,7 +14,6 @@
  *   limitations under the License.
  */
 
-#include <openssl/sha.h>
 
 #include <axis2_utils_defines.h>
 #include <axis2_defines.h>

Modified: webservices/axis2/trunk/c/rampart/samples/client/echo/echo.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/samples/client/echo/echo.c?view=diff&rev=465999&r1=465998&r2=465999
==============================================================================
--- webservices/axis2/trunk/c/rampart/samples/client/echo/echo.c (original)
+++ webservices/axis2/trunk/c/rampart/samples/client/echo/echo.c Thu Oct 19 22:22:30 2006
@@ -51,6 +51,7 @@
 
     /* Set end point reference of echo service */
     address = "http://localhost:9090/axis2/services/echo";
+    
     if (argc > 2)
     {
         address = argv[1];
@@ -73,10 +74,10 @@
     /* Setup options */
     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");*/
     AXIS2_OPTIONS_SET_ACTION(options, env,
-            "http://ws.apache.org/axis2/c/samples/echoString");
-
-
+            "urn:echo");
 
     /*
      * Set security params. If you need to enable dynamic settings uncomment
@@ -85,11 +86,11 @@
 
 #ifdef DYN_SETTINGS
     un_property = axis2_property_create(env);
-    AXIS2_PROPERTY_SET_VALUE(un_property, env, "Raigama");
+    AXIS2_PROPERTY_SET_VALUE(un_property, env, "alice");
     AXIS2_OPTIONS_SET_PROPERTY(options, env, RAMPART_ACTION_USER, un_property);
 
     pw_property = axis2_property_create(env);
-    AXIS2_PROPERTY_SET_VALUE(pw_property, env, "RaigamaPW");
+    AXIS2_PROPERTY_SET_VALUE(pw_property, env, "password");
     AXIS2_OPTIONS_SET_PROPERTY(options, env, RAMPART_ACTION_PASSWORD,  pw_property);
 
     pw_type_property = axis2_property_create(env);
@@ -103,11 +104,11 @@
 
     /*Make sure this is the correct path for the callback module*/
     pw_cb_property = axis2_property_create(env);
-    AXIS2_PROPERTY_SET_VALUE(pw_cb_property, env, "/home/kau/axis2/c/deploy/rampart/samples/callback/libpwcb.so");
+    AXIS2_PROPERTY_SET_VALUE(pw_cb_property, env, "/home/kau/axis2/c/deploy/samples/rampart/callback/libpwcb.so");
     AXIS2_OPTIONS_SET_PROPERTY(options, env, RAMPART_ACTION_PW_CALLBACK_CLASS , pw_cb_property);
 
     time_to_live_property = axis2_property_create(env);
-    AXIS2_PROPERTY_SET_VALUE(time_to_live_property, env, "420");
+    AXIS2_PROPERTY_SET_VALUE(time_to_live_property, env, "300");
     AXIS2_OPTIONS_SET_PROPERTY(options, env, RAMPART_ACTION_TIME_TO_LIVE, time_to_live_property);
 #endif
 

Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/Makefile.am?view=diff&rev=465999&r1=465998&r2=465999
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/Makefile.am Thu Oct 19 22:22:30 2006
@@ -1,5 +1,5 @@
 noinst_LTLIBRARIES = libomopenssl.la
-libomopenssl_la_SOURCES = cipher_ctx.c crypt.c rsa.c pkey.c util.c cipher_property.c 
+libomopenssl_la_SOURCES = cipher_ctx.c crypt.c rsa.c pkey.c util.c cipher_property.c digest.c
 
 libomopenssl_la_LIBADD  = -lssl\
 			../../../../util/src/libaxis2_util.la \

Added: webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/digest.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/digest.c?view=auto&rev=465999
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/digest.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/openssl/digest.c Thu Oct 19 22:22:30 2006
@@ -0,0 +1,45 @@
+/*
+ *   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 <openssl/sha.h>
+#include <openssl_digest.h>
+#include <axis2_base64.h>
+
+#define SIZE_HASH 32
+
+AXIS2_EXTERN axis2_char_t *AXIS2_CALL
+openssl_sha1(const axis2_env_t *env,
+            axis2_char_t *input,
+            int length)
+{
+    SHA_CTX c ;
+    unsigned char md[SHA_DIGEST_LENGTH];
+    axis2_char_t* encoded_str = NULL;
+
+    SHA1_Init(&c);
+    SHA1_Update(&c,(unsigned char*)input,length);
+    SHA1_Final(md,&c);
+
+    encoded_str = AXIS2_MALLOC(env->allocator, axis2_base64_encode_len(SIZE_HASH));
+    axis2_base64_encode(encoded_str, (char*)md, SHA_DIGEST_LENGTH);
+
+    return encoded_str;
+}
+
+
+
+

Modified: webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c?view=diff&rev=465999&r1=465998&r2=465999
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_crypto_util.c Thu Oct 19 22:22:30 2006
@@ -21,25 +21,30 @@
 #include <rampart_crypto_util.h>
 #include <axis2_util.h>
 #include <axis2_base64.h>
+#include <openssl_digest.h>
 
 /*Calculate the hash of concatenated string of
  * nonce, created and the password.
  *
  */
-#define SIZE 256
-#define SIZE_HASH 32
 
 AXIS2_EXTERN axis2_char_t* AXIS2_CALL rampart_crypto_sha1(const axis2_env_t *env,
         const axis2_char_t *nonce,
         const axis2_char_t *created,
         const axis2_char_t *password)
-
 {
     char* input = NULL;
-    axis2_char_t* encoded_str = NULL;
-    SHA_CTX c ;
-    unsigned char md[SHA_DIGEST_LENGTH];
-
+    axis2_char_t* digest = NULL;   
+    axis2_char_t* decoded_nonce = NULL;
+    int decoded_nonce_length = 0;
+
+    /*Decode the nonce first*/
+    if(nonce){
+        int ret;
+        decoded_nonce_length = axis2_base64_decode_len(nonce);
+        decoded_nonce = AXIS2_MALLOC(env->allocator, axis2_base64_decode_len(nonce));
+        ret = axis2_base64_decode(decoded_nonce, nonce);
+    }
 
     if ((!nonce) && (!created))
     {/*If both nonce and created are omitted*/
@@ -53,23 +58,19 @@
     }
     else  if (!created)
     {/*If created is omitted*/
-        input = AXIS2_MALLOC(env->allocator, AXIS2_STRLEN(nonce) + AXIS2_STRLEN(password) + 1);
-        sprintf(input, "%s%s",  nonce, password);
+        input = AXIS2_MALLOC(env->allocator, decoded_nonce_length + AXIS2_STRLEN(password) + 1);
+        sprintf(input, "%s%s",  decoded_nonce, password);
     }
     else
     {/*If all nonce, created and password are present*/
-        input = AXIS2_MALLOC(env->allocator, AXIS2_STRLEN(nonce) + AXIS2_STRLEN(created) + AXIS2_STRLEN(password) + 1);
-        sprintf(input, "%s%s%s", nonce, created, password);
+        input = AXIS2_MALLOC(env->allocator, decoded_nonce_length + AXIS2_STRLEN(created) + AXIS2_STRLEN(password) + 1);
+        sprintf(input, "%s%s%s", decoded_nonce, created, password);
     }
     
-    SHA1_Init(&c);
-    SHA1_Update(&c,(unsigned char*)input,AXIS2_STRLEN(input));
-    SHA1_Final(md,&c);
-
-    encoded_str = AXIS2_MALLOC(env->allocator, axis2_base64_encode_len(SIZE_HASH));
-    axis2_base64_encode(encoded_str, (char*)md, SHA_DIGEST_LENGTH);
-    
+    digest = openssl_sha1(env, input, AXIS2_STRLEN(input)); 
     AXIS2_FREE(env->allocator, input);
     
-    return encoded_str;
+    return digest;
 }
+
+



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