From ff6b8261d89a2ac071bba0ebe0e16b40dd7122a1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 23 Dec 2018 20:11:05 +0300 Subject: in fact, we don't need mir_hmac_sha1 either --- src/mir_core/src/mir_core.def | 1 - src/mir_core/src/mir_core64.def | 1 - src/mir_core/src/sha1.cpp | 31 ------------------------------- 3 files changed, 33 deletions(-) (limited to 'src') diff --git a/src/mir_core/src/mir_core.def b/src/mir_core/src/mir_core.def index f2cd22e6d2..4a744c5b5f 100644 --- a/src/mir_core/src/mir_core.def +++ b/src/mir_core/src/mir_core.def @@ -164,7 +164,6 @@ mir_writeLogVA @226 mir_writeLogVW @227 bin2hex @228 bin2hexW @229 -mir_hmac_sha1 @230 mir_base64_encodebuf @231 mirstr_allocate @232 mirstr_free @233 diff --git a/src/mir_core/src/mir_core64.def b/src/mir_core/src/mir_core64.def index 4b454ab756..3f25e54f77 100644 --- a/src/mir_core/src/mir_core64.def +++ b/src/mir_core/src/mir_core64.def @@ -164,7 +164,6 @@ mir_writeLogVA @226 mir_writeLogVW @227 bin2hex @228 bin2hexW @229 -mir_hmac_sha1 @230 mir_base64_encodebuf @231 mirstr_allocate @232 mirstr_free @233 diff --git a/src/mir_core/src/sha1.cpp b/src/mir_core/src/sha1.cpp index 10f47d7867..435f6f440b 100644 --- a/src/mir_core/src/sha1.cpp +++ b/src/mir_core/src/sha1.cpp @@ -153,34 +153,3 @@ MIR_CORE_DLL(void) mir_sha1_hash(BYTE *dataIn, size_t len, BYTE hashout[20]) mir_sha1_append(&ctx, dataIn, len); mir_sha1_finish(&ctx, hashout); } - -///////////////////////////////////////////////////////////////////////////////////////// - -MIR_CORE_DLL(void) mir_hmac_sha1(BYTE hashout[MIR_SHA1_HASH_SIZE], const BYTE *key, size_t keylen, const BYTE *text, size_t textlen) -{ - mir_sha1_ctx ctx; - BYTE usedKey[MIR_SHA_BLOCKSIZE] = { 0 }; - - if (keylen > MIR_SHA_BLOCKSIZE) { - mir_sha1_init(&ctx); - mir_sha1_append(&ctx, key, (int)keylen); - mir_sha1_finish(&ctx, usedKey); - } - else memcpy(usedKey, key, keylen); - - for (size_t i = 0; i < MIR_SHA_BLOCKSIZE; i++) - usedKey[i] ^= 0x36; - - mir_sha1_init(&ctx); - mir_sha1_append(&ctx, usedKey, MIR_SHA_BLOCKSIZE); - mir_sha1_append(&ctx, text, (int)textlen); - mir_sha1_finish(&ctx, hashout); - - for (size_t i = 0; i < MIR_SHA_BLOCKSIZE; i++) - usedKey[i] ^= 0x5C ^ 0x36; - - mir_sha1_init(&ctx); - mir_sha1_append(&ctx, usedKey, MIR_SHA_BLOCKSIZE); - mir_sha1_append(&ctx, hashout, MIR_SHA1_HASH_SIZE); - mir_sha1_finish(&ctx, hashout); -} -- cgit v1.2.3