Creating Key using HMAC - SHA1 using openSSL

B

Bhavesh.Feb

Hi,
I'm trying to use SHA1 and HMAC to create signature for my web
service request. I dont know much about HMAC or SHA1 but this is what i
need to create signature. What i'm trying to do is:

SHA_CTX shaContext;
SHA1_Init(&shaContext);
SHA1_Update(&shaContext, &data, dataLen );
SHA1_Final(cipher_key, &shaContext);

char out[EVP_MAX_MD_SIZE]; // EVP_MAX_MD_SIZE is the limit on
int len; // what HMAC will ever put in out
HMAC(
sha1(),
secretKey,
strlen(secretKey),
data.c_str(),
dataLen,
out,
&len
);

It's throwing some compilation error for call to HMAC as i'm not
passing correct parameter to it.

Does someone already implemented this???? Can someone share working
code snippet?

Thanks,
Bhavesh
 
D

David Harmon

On 22 Sep 2006 14:52:57 -0700 in comp.lang.c++,
(e-mail address removed) wrote,
It's throwing some compilation error for call to HMAC as i'm not
passing correct parameter to it.

No fair asking about an error message without telling us what it
says!
 
R

red floyd

David said:
On 22 Sep 2006 14:52:57 -0700 in comp.lang.c++,
(e-mail address removed) wrote,

No fair asking about an error message without telling us what it
says!

He has an error on line 42 of his code.
 
T

Thomas J. Gritzan

I'm trying to use SHA1 and HMAC to create signature for my web
service request. I dont know much about HMAC or SHA1 but this is what i
need to create signature. What i'm trying to do is:

SHA_CTX shaContext;
SHA1_Init(&shaContext);
SHA1_Update(&shaContext, &data, dataLen );
SHA1_Final(cipher_key, &shaContext);

char out[EVP_MAX_MD_SIZE]; // EVP_MAX_MD_SIZE is the limit on
int len; // what HMAC will ever put in out
HMAC(
sha1(),
secretKey,
strlen(secretKey),
data.c_str(),
dataLen,
out,
&len
);

http://www.die.net/doc/linux/man/man3/hmac.3.html

Seems like you pass an int* where an unsigned int* is needed, and char*
where unsigned char*...
well, giving us the error messages would help, but asking in a newsgroup
where this library is on-topic would be even better. Try a unix programming
newsgroup.

See here:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.8
and here:
http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top