473,326 Members | 2,182 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Creating Key using HMAC - SHA1 using openSSL

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
4 13228
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: User1001 | last post by:
I have been trying to enable/use specific OpenSSL extensions that I use in generating certificates manually, via PHP5 + php5-openssl module/extension. Filling out the "configargs" array with...
0
by: John Bergstrom | last post by:
Hello everyone! I wrote a simple perl program to encrypt a string using Crypt::OpenSSL::RSA. Everything as described in the module documentation. The public key is a valid X.509 encrypted...
4
by: ruben.de.visscher | last post by:
Hi, I want to make a program that checks the SHA1 message digest of a password from the user with a list of usernames and the corresponding message digests of their passwords. The problem is,...
2
by: ed | last post by:
Hello, I've been crawling the net tonight looking for a reasonably portable sha1/hmac implementation. I don't need a huge library of different methods, don't suppose anyone has such a piece of...
5
by: KW | last post by:
I'm trying to convert some PHP code using OpenSSL to Python and I'm stuck on openssl_sign() which uses an RSA private key to compute a signature. Example PHP code: $privkeyid =...
1
by: mirandacascade | last post by:
I am attempting to implement a process, and I'm pretty sure that a major roadblock is that I do not understand the nomenclature. The specs indicate that the goal is to calculate a message digest...
4
by: Patrick | last post by:
Hello, I'm currently trying the OpenSSL Library, but I got some problems. I want to create a server and client application that communicate through the OpenSSL API, but this code doesn't work. I...
0
by: shuaibali | last post by:
Hello, I just wanted to inquire if all the cipher suite Cipher Algorithm types (specifically AES group) are usable in .Net framework or not. According to my understanding, AES ciphers are still not...
1
by: lide.wyb | last post by:
We are using only the OpenSSL cryptographic functionality, the EVP and HMAC functions, in a multi-threaded application. Do we need to do anything to ensure thread safety ? The documentation...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.