I am writing a program to upload file to Amazon S3 in C with libCurl and OpenSSL. To send a request to amazon I have to sign it - with HMAC-SHA1 here amazon doc that explain it. Help, please, can it be done with openSSL, and if U know advise how? Or I need to use some other libs?
Asked
Active
Viewed 1,843 times
1
-
1Is this what you are looking for? http://stackoverflow.com/questions/242665/understanding-engine-initialization-in-openssl/244310#244310 – mocj Oct 11 '11 at 17:23
-
@mocj seems like that function, thanks! Now I'm trying to understand what part of the request to Amazon S3 should be passed as the fourth parameter. Didn't U work with Amazon API? – Hate Oct 12 '11 at 13:51
-
Sorry, I just knew about HMAC in OpenSSL, hence the comment and not a complete answer. I haven't worked with the Amazon API. What is the fourth parameter? If you are referring to the ParameterA in the graphic it would seem to be linked to your Action parameter. If your action takes no parameters - just leave it out. Then append your signature. – mocj Oct 12 '11 at 16:33
-
as far as I understand 4th parameter in the case of Amazon API is some part of the request, but what part.. – Hate Oct 13 '11 at 09:37
-
The parameter(s) depend on the service and action. Without knowing that... – mocj Oct 13 '11 at 23:13
-
Old question :) Were you successful? How did you get this done? – Cmag May 15 '13 at 15:03
-
hey, great old question... can anyone bring up some of their C? – Cmag May 15 '13 at 16:10
-
1@Clustermagnet it was long time ago, as far as I remember I was told that we don't need it any more before I find out how to do it ) – Hate Jul 03 '13 at 22:18
2 Answers
0
This section of the documentation explains exactly what to encode for each request type (including uploading a file), with several examples that are good for testing your requests/hashing: http://docs.aws.amazon.com/AmazonS3/latest/dev/RESTAuthentication.html#RESTAuthenticationExamples
0
If it's iOS..
AmazonAuthUtils.h
/**
* Compute a keyed hash of some data with a specified key and algorithm.
* @param data The data to sign
* @param key The key to sign the data with
* @param algorithm Which HMAC algortithm to use. Currently support <code>kCCHmacAlgSHA1</code> and <code>kCCHmacAlgSHA256</code>.
* @return Base64 encoded string that is the signature of the data with the specified key.
*/
+(NSString *)HMACSign:(NSData *)data withKey:(NSString *)key usingAlgorithm:(CCHmacAlgorithm)algorithm;

estobbart
- 1,137
- 12
- 28