You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ka...@apache.org on 2006/09/11 07:44:48 UTC
svn commit: r442108 -
/webservices/axis2/trunk/c/rampart/src/util/rampart_util.c
Author: kaushalye
Date: Sun Sep 10 22:44:48 2006
New Revision: 442108
URL: http://svn.apache.org/viewvc?view=rev&rev=442108
Log:
Changed the way rampart generating nonce. Instead of using rand() now we are using the openssl based implementation.
JIRA - AXIS2C-273
Modified:
webservices/axis2/trunk/c/rampart/src/util/rampart_util.c
Modified: webservices/axis2/trunk/c/rampart/src/util/rampart_util.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/util/rampart_util.c?view=diff&rev=442108&r1=442107&r2=442108
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/util/rampart_util.c (original)
+++ webservices/axis2/trunk/c/rampart/src/util/rampart_util.c Sun Sep 10 22:44:48 2006
@@ -22,7 +22,8 @@
#include <axis2_util.h>
#include <axis2_base64.h>
#include <time.h>
-
+#include <oxs_buffer.h>
+#include <openssl_util.h>
/*Calculate the hash of concatenated string of
* nonce, created and the password.
*
@@ -31,21 +32,23 @@
#define SIZE_HASH 32
#define SIZE_NONCE 24
+
/*#define PRINTINFO 1 */
AXIS2_EXTERN axis2_char_t* AXIS2_CALL rampart_generate_nonce(const axis2_env_t *env)
{
- int num;
- char* rand_str = NULL;
- axis2_char_t* encoded_str=NULL;
- num=rand();
- rand_str= AXIS2_MALLOC(env->allocator,sizeof(char)*16);
- sprintf(rand_str, "%16d", num);
-
-
+ oxs_buffer_t *buffer = NULL;
+ axis2_status_t status = AXIS2_FAILURE;
+ char *rand_str = NULL;
+ axis2_char_t* encoded_str=NULL;
+
+ buffer = oxs_buffer_create(env);
+ status = generate_random_data(env, buffer, 16);
+ rand_str = (char*)OXS_BUFFER_GET_DATA(buffer, env);
encoded_str = AXIS2_MALLOC(env->allocator, sizeof(char)*SIZE_NONCE);
- axis2_base64_encode(encoded_str,rand_str,AXIS2_STRLEN(rand_str));
- /* AXIS2_FREE(env->allocator, rand_str); */
- return encoded_str;
+ axis2_base64_encode(encoded_str,rand_str,OXS_BUFFER_GET_SIZE(buffer, env));
+ OXS_BUFFER_FREE(buffer, env);
+
+ return encoded_str;
}
@@ -58,7 +61,7 @@
curtime = time (NULL) + ttl;
loctime = localtime (&curtime);
- strftime (buffer, SIZE, "%Y-%m-%dT%H:%M:%SZ\n", loctime);
+ strftime (buffer, SIZE, "%Y-%m-%dT%H:%M:%SZ\n", loctime);
created_str = AXIS2_STRDUP(buffer, env);
return created_str;
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org