By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,661 Members | 781 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,661 IT Pros & Developers. It's quick & easy.

Creating Key using HMAC - SHA1 using openSSL

P: n/a
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

Sep 22 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
I'm working on unix and am using opneSSL libraries.

Bh*********@gmail.com wrote:
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
Sep 22 '06 #2

P: n/a
On 22 Sep 2006 14:52:57 -0700 in comp.lang.c++,
Bh*********@gmail.com 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!

Sep 22 '06 #3

P: n/a
David Harmon wrote:
On 22 Sep 2006 14:52:57 -0700 in comp.lang.c++,
Bh*********@gmail.com 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!
He has an error on line 42 of his code.
Sep 22 '06 #4

P: n/a
Bh*********@gmail.com schrieb:
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-lit...t.html#faq-5.8
and here:
http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

--
Thomas
http://www.netmeister.org/news/learn2quote.html
Sep 22 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.