Commit 32ab35f6 authored by Deomid Ryabkov's avatar Deomid Ryabkov Committed by Sergey Lyubka

Rename hmac_sha1 -> cs_hmac_sha1

    PUBLISHED_FROM=3d4fbd8192d04add406e304b113ce5ec0b1c1165
parent 8ab96ec7
......@@ -36,7 +36,7 @@ static void s3_handler(struct mg_connection *nc, int ev, void *ev_data) {
switch (ev) {
case NS_HTTP_REPLY:
if (nc2 != NULL) {
mg_printf_http_chunk(nc2, "Error: %.*s", (int)hm->message.len,
mg_printf_http_chunk(nc2, "Error: %.*s", (int) hm->message.len,
hm->message.p);
mg_send_http_chunk(nc2, "", 0);
}
......@@ -74,8 +74,9 @@ static void send_s3_request(struct mg_connection *nc, const char *file_name,
/* Prepare S3 authorization header */
snprintf(to_sign, sizeof(to_sign), "%s\n\n%s\n%s\n/%s/%s", method,
content_type, date, bucket, file_name);
hmac_sha1((unsigned char *)s_secret_access_key, strlen(s_secret_access_key),
(unsigned char *)to_sign, strlen(to_sign), (unsigned char *)sha1);
cs_hmac_sha1((unsigned char *) s_secret_access_key,
strlen(s_secret_access_key), (unsigned char *) to_sign,
strlen(to_sign), (unsigned char *) sha1);
mg_base64_encode((unsigned char *) sha1, sizeof(sha1), signature);
snprintf(req, sizeof(req),
"%s /%s HTTP/1.1\r\n"
......@@ -86,7 +87,7 @@ static void send_s3_request(struct mg_connection *nc, const char *file_name,
"Authorization: AWS %s:%s\r\n"
"\r\n",
method, file_name, bucket, host, date, content_type,
(unsigned long)strlen(file_data), s_access_key_id, signature);
(unsigned long) strlen(file_data), s_access_key_id, signature);
mg_printf(s3_conn, "%s%s", req, file_data);
/* S3 request sent, wait for a reply */
}
......@@ -165,8 +166,10 @@ int main(int argc, char *argv[]) {
}
if (s_access_key_id == NULL || s_secret_access_key == NULL) {
fprintf(stderr, "Usage: %s -a access_key_id -s s_secret_access_key "
"[-p port] [-D hexdump_file]\n", argv[0]);
fprintf(stderr,
"Usage: %s -a access_key_id -s s_secret_access_key "
"[-p port] [-D hexdump_file]\n",
argv[0]);
exit(1);
}
......
......@@ -415,7 +415,7 @@ void cs_sha1_final(unsigned char digest[20], cs_sha1_ctx *context) {
memset(&finalcount, '\0', sizeof(finalcount));
}
void hmac_sha1(const unsigned char *key, size_t keylen,
void cs_hmac_sha1(const unsigned char *key, size_t keylen,
const unsigned char *data, size_t datalen,
unsigned char out[20]) {
cs_sha1_ctx ctx;
......
......@@ -362,7 +362,7 @@ typedef struct {
void cs_sha1_init(cs_sha1_ctx *);
void cs_sha1_update(cs_sha1_ctx *, const unsigned char *data, uint32_t len);
void cs_sha1_final(unsigned char digest[20], cs_sha1_ctx *);
void hmac_sha1(const unsigned char *key, size_t key_len,
void cs_hmac_sha1(const unsigned char *key, size_t key_len,
const unsigned char *text, size_t text_len,
unsigned char out[20]);
#ifdef __cplusplus
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment