You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by sh...@apache.org on 2008/01/25 07:28:59 UTC
svn commit: r615123 - in /webservices/rampart/trunk/c/src:
omxmlsec/encryption.c omxmlsec/openssl/hmac.c util/rampart_crypto_util.c
Author: shankar
Date: Thu Jan 24 22:28:58 2008
New Revision: 615123
URL: http://svn.apache.org/viewvc?rev=615123&view=rev
Log:
solving base64_decode_len problem.
Modified:
webservices/rampart/trunk/c/src/omxmlsec/encryption.c
webservices/rampart/trunk/c/src/omxmlsec/openssl/hmac.c
webservices/rampart/trunk/c/src/util/rampart_crypto_util.c
Modified: webservices/rampart/trunk/c/src/omxmlsec/encryption.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/encryption.c?rev=615123&r1=615122&r2=615123&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/encryption.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/encryption.c Thu Jan 24 22:28:58 2008
@@ -296,7 +296,7 @@
axutil_base64_decode_len(
(char*)oxs_buffer_get_data(input, env)));
- ret = axutil_base64_decode((char*)decoded_encrypted_str,
+ ret = axutil_base64_decode_binary((char*)decoded_encrypted_str,
(char*)oxs_buffer_get_data(input, env));
dec_enc_buf = oxs_buffer_create(env);
Modified: webservices/rampart/trunk/c/src/omxmlsec/openssl/hmac.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/omxmlsec/openssl/hmac.c?rev=615123&r1=615122&r2=615123&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/openssl/hmac.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/openssl/hmac.c Thu Jan 24 22:28:58 2008
@@ -207,7 +207,7 @@
oxs_key_set_nonce(derived_key, env, seed);
decoded_seed_len = axutil_base64_decode_len(seed);
decoded_seed = AXIS2_MALLOC(env->allocator, decoded_seed_len);
- axutil_base64_decode(decoded_seed, seed);
+ axutil_base64_decode_binary(decoded_seed, seed);
AXIS2_FREE(env->allocator, seed);
seed = NULL;
}
@@ -215,7 +215,7 @@
{
decoded_seed_len = axutil_base64_decode_len(seed);
decoded_seed = AXIS2_MALLOC(env->allocator, decoded_seed_len);
- axutil_base64_decode(decoded_seed, seed);
+ axutil_base64_decode_binary(decoded_seed, seed);
}
if(decoded_seed)
Modified: webservices/rampart/trunk/c/src/util/rampart_crypto_util.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/src/util/rampart_crypto_util.c?rev=615123&r1=615122&r2=615123&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/util/rampart_crypto_util.c (original)
+++ webservices/rampart/trunk/c/src/util/rampart_crypto_util.c Thu Jan 24 22:28:58 2008
@@ -39,38 +39,50 @@
axis2_char_t* digest = NULL;
axis2_char_t* decoded_nonce = NULL;
int decoded_nonce_length = 0;
+ int created_length = 0;
+ int password_length = 0;
/*Decode the nonce first*/
if(nonce){
int ret;
decoded_nonce_length = axutil_base64_decode_len(nonce);
- decoded_nonce = AXIS2_MALLOC(env->allocator, axutil_base64_decode_len(nonce));
- ret = axutil_base64_decode(decoded_nonce, nonce);
+ decoded_nonce = AXIS2_MALLOC(env->allocator, decoded_nonce_length);
+ ret = axutil_base64_decode_binary(decoded_nonce, nonce);
}
if ((!nonce) && (!created))
{/*If both nonce and created are omitted*/
- input = AXIS2_MALLOC(env->allocator, axutil_strlen(password) + 1);
- sprintf(input, "%s", password);
+ password_length = axutil_strlen(password);
+ input = AXIS2_MALLOC(env->allocator, password_length);
+ memcpy(input, password, password_length);
}
else if (!nonce)
{/*If nonce is omitted*/
- input = AXIS2_MALLOC(env->allocator, axutil_strlen(created) + axutil_strlen(password) + 1);
- sprintf(input, "%s%s", created, password);
+ created_length = axutil_strlen(created);
+ password_length = axutil_strlen(password);
+ input = AXIS2_MALLOC(env->allocator, created_length + password_length);
+ memcpy(input, created, created_length);
+ memcpy(input + created_length, password, password_length);
}
else if (!created)
{/*If created is omitted*/
- input = AXIS2_MALLOC(env->allocator, decoded_nonce_length + axutil_strlen(password) + 1);
- sprintf(input, "%s%s", decoded_nonce, password);
+ password_length = axutil_strlen(password);
+ input = AXIS2_MALLOC(env->allocator, decoded_nonce_length + password_length);
+ memcpy(input, decoded_nonce, decoded_nonce_length);
+ memcpy(input + decoded_nonce_length, password, password_length);
}
else
{/*If all nonce, created and password are present*/
+ created_length = axutil_strlen(created);
+ password_length = axutil_strlen(password);
input = AXIS2_MALLOC(env->allocator,
- decoded_nonce_length + axutil_strlen(created) + axutil_strlen(password) + 1);
- sprintf(input, "%s%s%s", decoded_nonce, created, password);
+ decoded_nonce_length + created_length + password_length);
+ memcpy(input, decoded_nonce, decoded_nonce_length);
+ memcpy(input + decoded_nonce_length, created, created_length);
+ memcpy(input + decoded_nonce_length + created_length, password, password_length);
}
- digest = openssl_sha1(env, input, axutil_strlen(input));
+ digest = openssl_sha1(env, input, decoded_nonce_length + created_length + password_length);
AXIS2_FREE(env->allocator, input);
AXIS2_FREE(env->allocator, decoded_nonce);
return digest;