Author: kaushalye
Date: Tue Oct 16 00:30:14 2007
New Revision: 585064
URL: http://svn.apache.org/viewvc?rev=585064&view=rev
Log:
HMAC-SHA1 algo implementation in the openssl wrapper layer
Modified:
webservices/rampart/trunk/c/include/openssl_hmac.h
webservices/rampart/trunk/c/src/omxmlsec/openssl/hmac.c
Modified: webservices/rampart/trunk/c/include/openssl_hmac.h
URL:
http://svn.apache.org/viewvc/webservices/rampart/trunk/c/include/openssl_hmac.h?rev=585064&r1=585063&r2=585064&view=diff
==============================================================================
--- webservices/rampart/trunk/c/include/openssl_hmac.h (original)
+++ webservices/rampart/trunk/c/include/openssl_hmac.h Tue Oct 16 00:30:14 2007
@@ -15,7 +15,7 @@
*/
#include <openssl/sha.h>
-
+#include <openssl/hmac.h>
#include <axutil_utils_defines.h>
#include <axis2_defines.h>
#include <axutil_env.h>
@@ -41,7 +41,8 @@
AXIS2_EXTERN axis2_status_t AXIS2_CALL
openssl_hmac_sha1(const axutil_env_t *env,
oxs_buffer_t *secret,
- oxs_buffer_t *seed);
+ oxs_buffer_t *seed,
+ oxs_buffer_t *output);
/* @} */
#ifdef __cplusplus
}
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=585064&r1=585063&r2=585064&view=diff
==============================================================================
--- webservices/rampart/trunk/c/src/omxmlsec/openssl/hmac.c (original)
+++ webservices/rampart/trunk/c/src/omxmlsec/openssl/hmac.c Tue Oct 16 00:30:14
2007
@@ -22,13 +22,41 @@
#include <axutil_base64.h>
#include <axis2_util.h>
+/**
+ unsigned char *HMAC(const EVP_MD *evp_md, const void *key,
+ int key_len, const unsigned char *d, int n,
+ unsigned char *md, unsigned int *md_len);
+ void HMAC_CTX_init(HMAC_CTX *ctx);
+
+ void HMAC_Init(HMAC_CTX *ctx, const void *key, int key_len,
+ const EVP_MD *md);
+ void HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int key_len,
+ const EVP_MD *md, ENGINE *impl);
+ void HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, int len);
+ void HMAC_Final(HMAC_CTX *ctx, unsigned char *md, unsigned int *len);
+
+ void HMAC_CTX_cleanup(HMAC_CTX *ctx);
+ void HMAC_cleanup(HMAC_CTX *ctx);
+
+*/
AXIS2_EXTERN axis2_status_t AXIS2_CALL
openssl_hmac_sha1(const axutil_env_t *env,
oxs_buffer_t *secret,
- oxs_buffer_t *seed)
+ oxs_buffer_t *seed,
+ oxs_buffer_t *output)
{
+ HMAC_CTX ctx;
+ unsigned char hmac[MD5_DIGEST_LENGTH];
+ unsigned int hashed_len;
+ HMAC_CTX_init(&ctx);
+ HMAC_Init_ex(&ctx, oxs_buffer_get_data(secret, env),
oxs_buffer_get_size(secret, env), EVP_sha1(), NULL);
+ HMAC_Update(&ctx, oxs_buffer_get_data(seed, env),
oxs_buffer_get_size(seed, env));
+ HMAC_Final(&ctx, hmac, &hashed_len);
+ HMAC_cleanup(&ctx);
+
+ HMAC_CTX_cleanup(&ctx);
return AXIS2_SUCCESS;
}