mirror of
https://github.com/cesanta/mongoose.git
synced 2026-11-21 19:51:50 +00:00
Remove unused mg_hmac_sha1()
This commit is contained in:
1 parent
3b5a9e2d4b
commit
642befa8d5
4 files changed
+4
-78
No files matched your search
+2
-36
@@ -2899,7 +2899,8 @@ static uint32_t blk0(union char64long16 *block, int i) {
|
|||||||
z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \
|
z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \
|
||||||
w = rol(w, 30);
|
w = rol(w, 30);
|
||||||
|
|
||||||
static void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) {
|
static void mg_sha1_transform(uint32_t state[5],
|
||||||
|
const unsigned char buffer[64]) {
|
||||||
uint32_t a, b, c, d, e;
|
uint32_t a, b, c, d, e;
|
||||||
union char64long16 block[1];
|
union char64long16 block[1];
|
||||||
|
|
||||||
@@ -3058,41 +3059,6 @@ void mg_sha1_final(unsigned char digest[20], mg_sha1_ctx *context) {
|
|||||||
memset(&finalcount, '\0', sizeof(finalcount));
|
memset(&finalcount, '\0', sizeof(finalcount));
|
||||||
}
|
}
|
||||||
|
|
||||||
void mg_hmac_sha1(const unsigned char *key, size_t keylen,
|
|
||||||
const unsigned char *data, size_t datalen,
|
|
||||||
unsigned char out[20]) {
|
|
||||||
mg_sha1_ctx ctx;
|
|
||||||
unsigned char buf1[64], buf2[64], tmp_key[20], i;
|
|
||||||
|
|
||||||
if (keylen > sizeof(buf1)) {
|
|
||||||
mg_sha1_init(&ctx);
|
|
||||||
mg_sha1_update(&ctx, key, keylen);
|
|
||||||
mg_sha1_final(tmp_key, &ctx);
|
|
||||||
key = tmp_key;
|
|
||||||
keylen = sizeof(tmp_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(buf1, 0, sizeof(buf1));
|
|
||||||
memset(buf2, 0, sizeof(buf2));
|
|
||||||
memcpy(buf1, key, keylen);
|
|
||||||
memcpy(buf2, key, keylen);
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(buf1); i++) {
|
|
||||||
buf1[i] ^= 0x36;
|
|
||||||
buf2[i] ^= 0x5c;
|
|
||||||
}
|
|
||||||
|
|
||||||
mg_sha1_init(&ctx);
|
|
||||||
mg_sha1_update(&ctx, buf1, sizeof(buf1));
|
|
||||||
mg_sha1_update(&ctx, data, datalen);
|
|
||||||
mg_sha1_final(out, &ctx);
|
|
||||||
|
|
||||||
mg_sha1_init(&ctx);
|
|
||||||
mg_sha1_update(&ctx, buf2, sizeof(buf2));
|
|
||||||
mg_sha1_update(&ctx, out, 20);
|
|
||||||
mg_sha1_final(out, &ctx);
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef MG_ENABLE_LINES
|
#ifdef MG_ENABLE_LINES
|
||||||
#line 1 "src/sntp.c"
|
#line 1 "src/sntp.c"
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -813,9 +813,6 @@ typedef struct {
|
|||||||
void mg_sha1_init(mg_sha1_ctx *);
|
void mg_sha1_init(mg_sha1_ctx *);
|
||||||
void mg_sha1_update(mg_sha1_ctx *, const unsigned char *data, size_t len);
|
void mg_sha1_update(mg_sha1_ctx *, const unsigned char *data, size_t len);
|
||||||
void mg_sha1_final(unsigned char digest[20], mg_sha1_ctx *);
|
void mg_sha1_final(unsigned char digest[20], mg_sha1_ctx *);
|
||||||
void mg_hmac_sha1(const unsigned char *key, size_t key_len,
|
|
||||||
const unsigned char *text, size_t text_len,
|
|
||||||
unsigned char out[20]);
|
|
||||||
|
|
||||||
|
|
||||||
struct mg_connection;
|
struct mg_connection;
|
||||||
|
|||||||
+2
-36
@@ -62,7 +62,8 @@ static uint32_t blk0(union char64long16 *block, int i) {
|
|||||||
z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \
|
z += (w ^ x ^ y) + blk(i) + 0xCA62C1D6 + rol(v, 5); \
|
||||||
w = rol(w, 30);
|
w = rol(w, 30);
|
||||||
|
|
||||||
static void mg_sha1_transform(uint32_t state[5], const unsigned char buffer[64]) {
|
static void mg_sha1_transform(uint32_t state[5],
|
||||||
|
const unsigned char buffer[64]) {
|
||||||
uint32_t a, b, c, d, e;
|
uint32_t a, b, c, d, e;
|
||||||
union char64long16 block[1];
|
union char64long16 block[1];
|
||||||
|
|
||||||
@@ -220,38 +221,3 @@ void mg_sha1_final(unsigned char digest[20], mg_sha1_ctx *context) {
|
|||||||
memset(context, '\0', sizeof(*context));
|
memset(context, '\0', sizeof(*context));
|
||||||
memset(&finalcount, '\0', sizeof(finalcount));
|
memset(&finalcount, '\0', sizeof(finalcount));
|
||||||
}
|
}
|
||||||
|
|
||||||
void mg_hmac_sha1(const unsigned char *key, size_t keylen,
|
|
||||||
const unsigned char *data, size_t datalen,
|
|
||||||
unsigned char out[20]) {
|
|
||||||
mg_sha1_ctx ctx;
|
|
||||||
unsigned char buf1[64], buf2[64], tmp_key[20], i;
|
|
||||||
|
|
||||||
if (keylen > sizeof(buf1)) {
|
|
||||||
mg_sha1_init(&ctx);
|
|
||||||
mg_sha1_update(&ctx, key, keylen);
|
|
||||||
mg_sha1_final(tmp_key, &ctx);
|
|
||||||
key = tmp_key;
|
|
||||||
keylen = sizeof(tmp_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
memset(buf1, 0, sizeof(buf1));
|
|
||||||
memset(buf2, 0, sizeof(buf2));
|
|
||||||
memcpy(buf1, key, keylen);
|
|
||||||
memcpy(buf2, key, keylen);
|
|
||||||
|
|
||||||
for (i = 0; i < sizeof(buf1); i++) {
|
|
||||||
buf1[i] ^= 0x36;
|
|
||||||
buf2[i] ^= 0x5c;
|
|
||||||
}
|
|
||||||
|
|
||||||
mg_sha1_init(&ctx);
|
|
||||||
mg_sha1_update(&ctx, buf1, sizeof(buf1));
|
|
||||||
mg_sha1_update(&ctx, data, datalen);
|
|
||||||
mg_sha1_final(out, &ctx);
|
|
||||||
|
|
||||||
mg_sha1_init(&ctx);
|
|
||||||
mg_sha1_update(&ctx, buf2, sizeof(buf2));
|
|
||||||
mg_sha1_update(&ctx, out, 20);
|
|
||||||
mg_sha1_final(out, &ctx);
|
|
||||||
}
|
|
||||||
@@ -11,6 +11,3 @@ typedef struct {
|
|||||||
void mg_sha1_init(mg_sha1_ctx *);
|
void mg_sha1_init(mg_sha1_ctx *);
|
||||||
void mg_sha1_update(mg_sha1_ctx *, const unsigned char *data, size_t len);
|
void mg_sha1_update(mg_sha1_ctx *, const unsigned char *data, size_t len);
|
||||||
void mg_sha1_final(unsigned char digest[20], mg_sha1_ctx *);
|
void mg_sha1_final(unsigned char digest[20], mg_sha1_ctx *);
|
||||||
void mg_hmac_sha1(const unsigned char *key, size_t key_len,
|
|
||||||
const unsigned char *text, size_t text_len,
|
|
||||||
unsigned char out[20]);
|
|
||||||
Reference in new issue
Block a user