diff options
-rw-r--r-- | bin10/lib/mir_core.lib | bin | 50550 -> 50800 bytes | |||
-rw-r--r-- | bin10/lib/mir_core64.lib | bin | 45996 -> 46222 bytes | |||
-rw-r--r-- | bin11/lib/mir_core.lib | bin | 50550 -> 50800 bytes | |||
-rw-r--r-- | bin11/lib/mir_core64.lib | bin | 45996 -> 46222 bytes | |||
-rw-r--r-- | include/delphi/m_core.inc | 2 | ||||
-rw-r--r-- | include/m_core.h | 22 | ||||
-rw-r--r-- | plugins/CrashDumper/src/upload.cpp | 4 | ||||
-rw-r--r-- | plugins/Spamotron/src/bayes.cpp | 8 | ||||
-rw-r--r-- | protocols/AimOscar/src/client.cpp | 12 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/oauth.cpp | 2 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/fam_17signon.cpp | 2 | ||||
-rw-r--r-- | protocols/IcqOscarJ/src/icq_avatar.cpp | 12 | ||||
-rw-r--r-- | protocols/Skype/src/skype_avatars.cpp | 2 | ||||
-rw-r--r-- | protocols/Skype/src/skype_profile.cpp | 2 | ||||
-rw-r--r-- | protocols/Yahoo/src/libyahoo2/crypt.c | 24 | ||||
-rw-r--r-- | protocols/Yahoo/src/libyahoo2/libyahoo2.c | 12 | ||||
-rw-r--r-- | src/mir_core/http.cpp | 23 | ||||
-rw-r--r-- | src/mir_core/md5.cpp | 38 | ||||
-rw-r--r-- | src/mir_core/mir_core.def | 1 | ||||
-rw-r--r-- | tools/checksum/checksum.cpp | 6 | ||||
-rw-r--r-- | tools/checksum/commonheaders.h | 10 | ||||
-rw-r--r-- | tools/checksum/md5.cpp | 24 |
22 files changed, 113 insertions, 93 deletions
diff --git a/bin10/lib/mir_core.lib b/bin10/lib/mir_core.lib Binary files differindex 904590a4b9..3d9af45bc5 100644 --- a/bin10/lib/mir_core.lib +++ b/bin10/lib/mir_core.lib diff --git a/bin10/lib/mir_core64.lib b/bin10/lib/mir_core64.lib Binary files differindex 47ad270cfa..ffcb26d47e 100644 --- a/bin10/lib/mir_core64.lib +++ b/bin10/lib/mir_core64.lib diff --git a/bin11/lib/mir_core.lib b/bin11/lib/mir_core.lib Binary files differindex e2a2177eec..0b38903142 100644 --- a/bin11/lib/mir_core.lib +++ b/bin11/lib/mir_core.lib diff --git a/bin11/lib/mir_core64.lib b/bin11/lib/mir_core64.lib Binary files differindex 2648c70498..ffcb26d47e 100644 --- a/bin11/lib/mir_core64.lib +++ b/bin11/lib/mir_core64.lib diff --git a/include/delphi/m_core.inc b/include/delphi/m_core.inc index 7462e63d9a..abc3713971 100644 --- a/include/delphi/m_core.inc +++ b/include/delphi/m_core.inc @@ -603,6 +603,8 @@ function mir_base64_decode(str:pAnsiChar; var resultSize:int):PByte; stdcall; external CoreDLL name 'mir_base64_decode';
function mir_base64_encode(data:PByte; dataSize:int):pAnsiChar; stdcall;
external CoreDLL name 'mir_base64_encode';
+function mir_base64_encodebuf(data:PByte; dataSize:int; output:pAnsiChar; outputLen:int):pAnsiChar; stdcall;
+ external CoreDLL name 'mir_base64_encodebuf';
function rtrim(str:pAnsiChar):pAnsiChar; stdcall;
external CoreDLL name 'rtrim';
diff --git a/include/m_core.h b/include/m_core.h index 3fdb81a747..e7f7e4f919 100644 --- a/include/m_core.h +++ b/include/m_core.h @@ -535,19 +535,19 @@ MIR_CORE_DLL(int) mir_writeLogVW(HANDLE logger, const WCHAR *format, va_list arg // md5 functions
/* Define the state of the MD5 Algorithm. */
-typedef unsigned char mir_md5_byte_t; /* 8-bit byte */
-typedef unsigned int mir_md5_word_t; /* 32-bit word */
+typedef unsigned char BYTE; /* 8-bit byte */
+typedef unsigned int UINT32; /* 32-bit word */
typedef struct mir_md5_state_s {
- mir_md5_word_t count[2]; /* message length in bits, lsw first */
- mir_md5_word_t abcd[4]; /* digest buffer */
- mir_md5_byte_t buf[64]; /* accumulate block */
+ UINT32 count[2]; /* message length in bits, lsw first */
+ UINT32 abcd[4]; /* digest buffer */
+ BYTE buf[64]; /* accumulate block */
} mir_md5_state_t;
MIR_CORE_DLL(void) mir_md5_init(mir_md5_state_t *pms);
-MIR_CORE_DLL(void) mir_md5_append(mir_md5_state_t *pms, const mir_md5_byte_t *data, int nbytes);
-MIR_CORE_DLL(void) mir_md5_finish(mir_md5_state_t *pms, mir_md5_byte_t digest[16]);
-MIR_CORE_DLL(void) mir_md5_hash(const mir_md5_byte_t *data, int len, mir_md5_byte_t digest[16]);
+MIR_CORE_DLL(void) mir_md5_append(mir_md5_state_t *pms, const BYTE *data, int nbytes);
+MIR_CORE_DLL(void) mir_md5_finish(mir_md5_state_t *pms, BYTE digest[16]);
+MIR_CORE_DLL(void) mir_md5_hash(const BYTE *data, int len, BYTE digest[16]);
///////////////////////////////////////////////////////////////////////////////
// memory functions
@@ -675,6 +675,12 @@ MIR_CORE_DLL(void) mir_hmac_sha1(BYTE hashout[MIR_SHA1_HASH_SIZE], const BYTE *k MIR_CORE_DLL(void*) mir_base64_decode(const char *input, unsigned *outputLen);
MIR_CORE_DLL(char*) mir_base64_encode(const BYTE *input, unsigned inputLen);
+MIR_CORE_DLL(char*) mir_base64_encodebuf(const BYTE *input, unsigned inputLen, char *output, unsigned outLen);
+
+__forceinline unsigned mir_base64_encode_bufsize(unsigned inputLen)
+{
+ return 4 * ((inputLen + 2) / 3) + 1;
+}
MIR_CORE_DLL(char*) rtrim(char *str);
MIR_CORE_DLL(WCHAR*) rtrimw(WCHAR *str);
diff --git a/plugins/CrashDumper/src/upload.cpp b/plugins/CrashDumper/src/upload.cpp index 2e614923f9..437a5f55a0 100644 --- a/plugins/CrashDumper/src/upload.cpp +++ b/plugins/CrashDumper/src/upload.cpp @@ -52,7 +52,7 @@ void GetLoginStr(char* user, size_t szuser, char* pass) {
CallService(MS_DB_CRYPT_DECODESTRING, strlen(dbv.pszVal)+1, (LPARAM)dbv.pszVal);
- mir_md5_byte_t hash[16];
+ BYTE hash[16];
mir_md5_state_t context;
mir_md5_init(&context);
@@ -251,7 +251,7 @@ bool ProcessVIHash(bool store) buffer.reserve(0x1800);
PrintVersionInfo(buffer, 0);
- mir_md5_byte_t hash[16];
+ BYTE hash[16];
mir_md5_state_t context;
mir_md5_init(&context);
diff --git a/plugins/Spamotron/src/bayes.cpp b/plugins/Spamotron/src/bayes.cpp index 387c76bf83..8a00005150 100644 --- a/plugins/Spamotron/src/bayes.cpp +++ b/plugins/Spamotron/src/bayes.cpp @@ -97,9 +97,9 @@ int OpenBayes() return 0;
}
-char *tokenhash(const char *token, mir_md5_byte_t *digest)
+char *tokenhash(const char *token, BYTE *digest)
{
- mir_md5_hash((mir_md5_byte_t *)token, (int)strlen(token), digest);
+ mir_md5_hash((BYTE *)token, (int)strlen(token), digest);
return (char*)digest;
}
@@ -161,7 +161,7 @@ int get_token_score(int type, char *token) {
char sql[200];
int score = 0;
- mir_md5_byte_t digest[16];
+ BYTE digest[16];
sqlite3_stmt *stmt;
if (bayesdb == NULL)
@@ -310,7 +310,7 @@ void dequeue_messages() void learn(int type, TCHAR *msg)
{
char *tok, *message;
- mir_md5_byte_t digest[16];
+ BYTE digest[16];
char sql_select[200], sql_update[200], sql_insert[200], sql_counter[200];
sqlite3_stmt *stmt;
#ifdef _DEBUG
diff --git a/protocols/AimOscar/src/client.cpp b/protocols/AimOscar/src/client.cpp index ceb89c11dd..c7d4bf04b7 100644 --- a/protocols/AimOscar/src/client.cpp +++ b/protocols/AimOscar/src/client.cpp @@ -38,17 +38,17 @@ int CAimProto::aim_auth_request(HANDLE hServerConn,unsigned short &seqno,const c const char* country, const char* username, const char* password)
{
unsigned short offset=0;
- mir_md5_byte_t pass_hash[16];
- mir_md5_byte_t auth_hash[16];
+ BYTE pass_hash[16];
+ BYTE auth_hash[16];
mir_md5_state_t state;
mir_md5_init(&state);
- mir_md5_append(&state,(const mir_md5_byte_t *)password, (int)strlen(password));
+ mir_md5_append(&state,(const BYTE *)password, (int)strlen(password));
mir_md5_finish(&state,pass_hash);
mir_md5_init(&state);
- mir_md5_append(&state,(mir_md5_byte_t*)key, (int)strlen(key));
- mir_md5_append(&state,(mir_md5_byte_t*)pass_hash,MD5_HASH_LENGTH);
- mir_md5_append(&state,(mir_md5_byte_t*)AIM_MD5_STRING, sizeof(AIM_MD5_STRING)-1);
+ mir_md5_append(&state,(BYTE*)key, (int)strlen(key));
+ mir_md5_append(&state,(BYTE*)pass_hash,MD5_HASH_LENGTH);
+ mir_md5_append(&state,(BYTE*)AIM_MD5_STRING, sizeof(AIM_MD5_STRING)-1);
mir_md5_finish(&state,auth_hash);
char client_id[64], mirver[64];
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp index 7f428319e7..361b3ff81c 100644 --- a/protocols/Gadu-Gadu/src/oauth.cpp +++ b/protocols/Gadu-Gadu/src/oauth.cpp @@ -229,7 +229,7 @@ char *oauth_generate_nonce() strcpy(str, timestamp);
strcat(str, randnum);
- mir_md5_byte_t digest[16];
+ BYTE digest[16];
mir_md5_hash((BYTE*)(char*)str, (int)strlen(str), digest);
return bin2hex(digest, sizeof(digest), (char *)mir_alloc(32 + 1));
}
diff --git a/protocols/IcqOscarJ/src/fam_17signon.cpp b/protocols/IcqOscarJ/src/fam_17signon.cpp index dae5c38a0e..c4c546ca60 100644 --- a/protocols/IcqOscarJ/src/fam_17signon.cpp +++ b/protocols/IcqOscarJ/src/fam_17signon.cpp @@ -132,7 +132,7 @@ void CIcqProto::handleAuthKeyResponse(BYTE *buf, WORD wPacketLen, serverthread_i WORD wKeyLen;
char szKey[64] = {0};
mir_md5_state_t state;
- mir_md5_byte_t digest[16];
+ BYTE digest[16];
#ifdef _DEBUG
NetLog_Server("Received %s", "ICQ_SIGNON_AUTH_KEY");
diff --git a/protocols/IcqOscarJ/src/icq_avatar.cpp b/protocols/IcqOscarJ/src/icq_avatar.cpp index 363a9f2884..07dd17fc0f 100644 --- a/protocols/IcqOscarJ/src/icq_avatar.cpp +++ b/protocols/IcqOscarJ/src/icq_avatar.cpp @@ -196,11 +196,11 @@ BYTE* calcMD5HashOfFile(const TCHAR *tszFile) {
long cbFileSize = GetFileSize(hFile, NULL);
- res = (BYTE*)SAFE_MALLOC(16 * sizeof(mir_md5_byte_t));
+ res = (BYTE*)SAFE_MALLOC(16 * sizeof(BYTE));
if (cbFileSize != 0 && res)
{
mir_md5_state_t state;
- mir_md5_byte_t digest[16];
+ BYTE digest[16];
int dwOffset = 0;
mir_md5_init(&state);
@@ -211,12 +211,12 @@ BYTE* calcMD5HashOfFile(const TCHAR *tszFile) if (!(ppMap = (BYTE*)MapViewOfFile(hMap, FILE_MAP_READ, 0, dwOffset, dwBlockSize)))
break;
- mir_md5_append(&state, (const mir_md5_byte_t *)ppMap, dwBlockSize);
+ mir_md5_append(&state, (const BYTE *)ppMap, dwBlockSize);
UnmapViewOfFile(ppMap);
dwOffset += dwBlockSize;
}
mir_md5_finish(&state, digest);
- memcpy(res, digest, 16 * sizeof(mir_md5_byte_t));
+ memcpy(res, digest, 16 * sizeof(BYTE));
}
}
@@ -1593,10 +1593,10 @@ void avatars_server_connection::handleAvatarFam(BYTE *pBuffer, WORD wBufferLengt if (pCookieData->hashlen == 0x14 && pCookieData->hash[3] == 0x10 && ppro->getByte("StrictAvatarCheck", DEFAULT_AVATARS_CHECK))
{ // check only standard hashes
mir_md5_state_t state;
- mir_md5_byte_t digest[16];
+ BYTE digest[16];
mir_md5_init(&state);
- mir_md5_append(&state, (const mir_md5_byte_t *)pBuffer, datalen);
+ mir_md5_append(&state, (const BYTE *)pBuffer, datalen);
mir_md5_finish(&state, digest);
// check if received data corresponds to specified hash
if (memcmp(pCookieData->hash+4, digest, 0x10)) aValid = 0;
diff --git a/protocols/Skype/src/skype_avatars.cpp b/protocols/Skype/src/skype_avatars.cpp index fbf8af6138..a1e9a72e26 100644 --- a/protocols/Skype/src/skype_avatars.cpp +++ b/protocols/Skype/src/skype_avatars.cpp @@ -4,7 +4,7 @@ bool CSkypeProto::IsAvatarChanged(const SEBinary &avatar, HANDLE hContact) {
bool result = false;
- ::mir_md5_byte_t digest[16];
+ BYTE digest[16];
::mir_md5_hash((PBYTE)avatar.data(), (int)avatar.size(), digest);
DBVARIANT dbv;
diff --git a/protocols/Skype/src/skype_profile.cpp b/protocols/Skype/src/skype_profile.cpp index faf8e27e08..f76b238d80 100644 --- a/protocols/Skype/src/skype_profile.cpp +++ b/protocols/Skype/src/skype_profile.cpp @@ -34,7 +34,7 @@ void CSkypeProto::UpdateProfileAvatar(SEObject *obj, HANDLE hContact) }
else
{
- ::mir_md5_byte_t digest[16];
+ BYTE digest[16];
::mir_md5_hash((BYTE*)data.data(), (int)data.size(), digest);
::db_set_blob(hContact, this->m_szModuleName, "AvatarHash", digest, 16);
diff --git a/protocols/Yahoo/src/libyahoo2/crypt.c b/protocols/Yahoo/src/libyahoo2/crypt.c index d8c50a08f6..b54456fd85 100644 --- a/protocols/Yahoo/src/libyahoo2/crypt.c +++ b/protocols/Yahoo/src/libyahoo2/crypt.c @@ -50,7 +50,7 @@ char *yahoo_crypt(char *key, char *salt) int buflen = 0;
int needed = 3 + strlen (salt) + 1 + 26 + 1;
- mir_md5_byte_t alt_result[16];
+ BYTE alt_result[16];
mir_md5_state_t ctx;
mir_md5_state_t alt_ctx;
int salt_len;
@@ -77,29 +77,29 @@ char *yahoo_crypt(char *key, char *salt) mir_md5_init(&ctx);
/* Add the key string. */
- mir_md5_append(&ctx, (mir_md5_byte_t *)key, (int)key_len);
+ mir_md5_append(&ctx, (BYTE *)key, (int)key_len);
/* Because the SALT argument need not always have the salt prefix we
add it separately. */
- mir_md5_append(&ctx, (mir_md5_byte_t *)md5_salt_prefix, sizeof (md5_salt_prefix) - 1);
+ mir_md5_append(&ctx, (BYTE *)md5_salt_prefix, sizeof (md5_salt_prefix) - 1);
/* The last part is the salt string. This must be at most 8
characters and it ends at the first `$' character (for
compatibility which existing solutions). */
- mir_md5_append(&ctx, (mir_md5_byte_t *)salt, (int)salt_len);
+ mir_md5_append(&ctx, (BYTE *)salt, (int)salt_len);
/* Compute alternate MD5 sum with input KEY, SALT, and KEY. The
final result will be added to the first context. */
mir_md5_init(&alt_ctx);
/* Add key. */
- mir_md5_append(&alt_ctx, (mir_md5_byte_t *)key, key_len);
+ mir_md5_append(&alt_ctx, (BYTE *)key, key_len);
/* Add salt. */
- mir_md5_append(&alt_ctx, (mir_md5_byte_t *)salt, salt_len);
+ mir_md5_append(&alt_ctx, (BYTE *)salt, salt_len);
/* Add key again. */
- mir_md5_append(&alt_ctx, (mir_md5_byte_t *)key, key_len);
+ mir_md5_append(&alt_ctx, (BYTE *)key, key_len);
/* Now get result of this (16 bytes) and add it to the other
context. */
@@ -118,7 +118,7 @@ char *yahoo_crypt(char *key, char *salt) bit the first character of the key. This does not seem to be
what was intended but we have to follow this to be compatible. */
for (cnt = key_len; cnt > 0; cnt >>= 1)
- mir_md5_append(&ctx, (cnt & 1) != 0 ? alt_result : (mir_md5_byte_t *)key, 1);
+ mir_md5_append(&ctx, (cnt & 1) != 0 ? alt_result : (BYTE *)key, 1);
/* Create intermediate result. */
mir_md5_finish(&ctx, alt_result);
@@ -132,23 +132,23 @@ char *yahoo_crypt(char *key, char *salt) /* Add key or last result. */
if ((cnt & 1) != 0)
- mir_md5_append(&ctx, (mir_md5_byte_t *)key, key_len);
+ mir_md5_append(&ctx, (BYTE *)key, key_len);
else
mir_md5_append(&ctx, alt_result, 16);
/* Add salt for numbers not divisible by 3. */
if (cnt % 3 != 0)
- mir_md5_append(&ctx, (mir_md5_byte_t *)salt, salt_len);
+ mir_md5_append(&ctx, (BYTE *)salt, salt_len);
/* Add key for numbers not divisible by 7. */
if (cnt % 7 != 0)
- mir_md5_append(&ctx, (mir_md5_byte_t *)key, key_len);
+ mir_md5_append(&ctx, (BYTE *)key, key_len);
/* Add key or last result. */
if ((cnt & 1) != 0)
mir_md5_append(&ctx, alt_result, 16);
else
- mir_md5_append(&ctx, (mir_md5_byte_t *)key, key_len);
+ mir_md5_append(&ctx, (BYTE *)key, key_len);
/* Create intermediate result. */
mir_md5_finish(&ctx, alt_result);
diff --git a/protocols/Yahoo/src/libyahoo2/libyahoo2.c b/protocols/Yahoo/src/libyahoo2/libyahoo2.c index 3da50e7b67..71b0fb4886 100644 --- a/protocols/Yahoo/src/libyahoo2/libyahoo2.c +++ b/protocols/Yahoo/src/libyahoo2/libyahoo2.c @@ -2397,7 +2397,7 @@ static void yahoo_process_auth_0x0f(struct yahoo_input_data *yid, const char *se char *response = NULL;
char url[1024];
char *c, *t;
- mir_md5_byte_t result[16];
+ BYTE result[16];
mir_md5_state_t ctx;
unsigned char *magic_hash = (unsigned char*) malloc(50); /* this one is like 26 bytes? */
int i;
@@ -2657,8 +2657,8 @@ LBL_FAILED: */
mir_md5_init(&ctx);
- mir_md5_append(&ctx, (mir_md5_byte_t *)crumb, strlen(crumb));
- mir_md5_append(&ctx, (mir_md5_byte_t *)seed, strlen(seed));
+ mir_md5_append(&ctx, (BYTE *)crumb, strlen(crumb));
+ mir_md5_append(&ctx, (BYTE *)seed, strlen(seed));
mir_md5_finish(&ctx, result);
to_y64(magic_hash, result, 16);
@@ -6477,17 +6477,17 @@ char *yahoo_ft7dc_send(int id, const char *buddy, YList *files) struct yahoo_packet *pkt = NULL;
char ft_token[32]; // we only need 23 chars actually
YList *l=files;
- mir_md5_byte_t result[16];
+ BYTE result[16];
mir_md5_state_t ctx;
if (!yid)
return NULL;
mir_md5_init(&ctx);
- mir_md5_append(&ctx, (mir_md5_byte_t *)buddy, strlen(buddy));
+ mir_md5_append(&ctx, (BYTE *)buddy, strlen(buddy));
snprintf(ft_token, 32, "%lu", time(NULL));
- mir_md5_append(&ctx, (mir_md5_byte_t *)ft_token, strlen(ft_token));
+ mir_md5_append(&ctx, (BYTE *)ft_token, strlen(ft_token));
mir_md5_finish(&ctx, result);
to_y64((unsigned char *)ft_token, result, 16);
diff --git a/src/mir_core/http.cpp b/src/mir_core/http.cpp index e0e2c8176b..a4a44c86dc 100644 --- a/src/mir_core/http.cpp +++ b/src/mir_core/http.cpp @@ -66,14 +66,26 @@ MIR_CORE_DLL(char*) mir_base64_encode(const BYTE *input, unsigned inputLen) if (input == NULL)
return NULL;
- BYTE chr[3];
+ unsigned outputLen = mir_base64_encode_bufsize(inputLen);
+ char *output = (char*)mir_alloc(outputLen);
+ if (output == NULL)
+ return NULL;
- char *output = (char*)mir_alloc(4 * ((inputLen + 2) / 3) + 1);
- char *p = output;
+ return mir_base64_encodebuf(input, inputLen, output, outputLen);
+}
- for (unsigned i=0; i < inputLen; )
- {
+MIR_CORE_DLL(char*) mir_base64_encodebuf(const BYTE *input, unsigned inputLen, char *output, unsigned outputLen)
+{
+ if (input == NULL)
+ return NULL;
+
+ if (outputLen < mir_base64_encode_bufsize(inputLen))
+ return NULL;
+
+ char *p = output;
+ for (unsigned i=0; i < inputLen; ) {
int rest = 0;
+ BYTE chr[3];
chr[0] = input[i++];
chr[1] = (i < inputLen) ? input[i++] : rest++, 0;
chr[2] = (i < inputLen) ? input[i++] : rest++, 0;
@@ -89,7 +101,6 @@ MIR_CORE_DLL(char*) mir_base64_encode(const BYTE *input, unsigned inputLen) }
*p = 0;
-
return output;
}
diff --git a/src/mir_core/md5.cpp b/src/mir_core/md5.cpp index a7d7a641e3..216abfedba 100644 --- a/src/mir_core/md5.cpp +++ b/src/mir_core/md5.cpp @@ -55,7 +55,7 @@ #include "commonheaders.h"
-#define T_MASK ((mir_md5_word_t)~0)
+#define T_MASK ((UINT32)~0)
#define T1 /* 0xd76aa478 */ (T_MASK ^ 0x28955b87)
#define T2 /* 0xe8c7b756 */ (T_MASK ^ 0x173848a9)
#define T3 0x242070db
@@ -122,15 +122,15 @@ #define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
//gfd*
-static void md5_process(mir_md5_state_t *pms, const mir_md5_byte_t *data /*[64]*/)
+static void md5_process(mir_md5_state_t *pms, const BYTE *data /*[64]*/)
{
- mir_md5_word_t
+ UINT32
a = pms->abcd[0], b = pms->abcd[1],
c = pms->abcd[2], d = pms->abcd[3];
- mir_md5_word_t t;
+ UINT32 t;
/* Define storage for little-endian or both types of CPUs. */
- mir_md5_word_t xbuf[16];
- const mir_md5_word_t *X;
+ UINT32 xbuf[16];
+ const UINT32 *X;
{
/*
@@ -140,15 +140,15 @@ static void md5_process(mir_md5_state_t *pms, const mir_md5_byte_t *data /*[64]* */
static const int w = 1;
- if (*((const mir_md5_byte_t *)&w)) /* dynamic little-endian */
+ if (*((const BYTE *)&w)) /* dynamic little-endian */
{
/*
* On little-endian machines, we can process properly aligned
* data without copying it.
*/
- if ( !((data - (const mir_md5_byte_t *)0) & 3)) {
+ if ( !((data - (const BYTE *)0) & 3)) {
/* data are properly aligned */
- X = (const mir_md5_word_t *)data;
+ X = (const UINT32 *)data;
} else {
/* not aligned */
memcpy(xbuf, data, 64);
@@ -161,7 +161,7 @@ static void md5_process(mir_md5_state_t *pms, const mir_md5_byte_t *data /*[64]* * On big-endian machines, we must arrange the bytes in the
* right order.
*/
- const mir_md5_byte_t *xp = data;
+ const BYTE *xp = data;
int i;
X = xbuf; /* (dynamic only) */
@@ -290,12 +290,12 @@ MIR_CORE_DLL(void) mir_md5_init(mir_md5_state_t *pms) pms->abcd[3] = 0x10325476;
}
-MIR_CORE_DLL(void) mir_md5_append(mir_md5_state_t *pms, const mir_md5_byte_t *data, int nbytes)
+MIR_CORE_DLL(void) mir_md5_append(mir_md5_state_t *pms, const BYTE *data, int nbytes)
{
- const mir_md5_byte_t *p = data;
+ const BYTE *p = data;
int left = nbytes;
int offset = (pms->count[0] >> 3) & 63;
- mir_md5_word_t nbits = (mir_md5_word_t)(nbytes << 3);
+ UINT32 nbits = (UINT32)(nbytes << 3);
if (nbytes <= 0)
return;
@@ -327,29 +327,29 @@ MIR_CORE_DLL(void) mir_md5_append(mir_md5_state_t *pms, const mir_md5_byte_t *da memcpy(pms->buf, p, left);
}
-MIR_CORE_DLL(void) mir_md5_finish(mir_md5_state_t *pms, mir_md5_byte_t digest[16])
+MIR_CORE_DLL(void) mir_md5_finish(mir_md5_state_t *pms, BYTE digest[16])
{
- static const mir_md5_byte_t pad[64] = {
+ static const BYTE pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- mir_md5_byte_t data[8];
+ BYTE data[8];
int i;
/* Save the length before padding. */
for (i = 0; i < 8; ++i)
- data[i] = (mir_md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ data[i] = (BYTE)(pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
mir_md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
mir_md5_append(pms, data, 8);
for (i = 0; i < 16; ++i)
- digest[i] = (mir_md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+ digest[i] = (BYTE)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}
-MIR_CORE_DLL(void) mir_md5_hash(const mir_md5_byte_t *data, int len, mir_md5_byte_t digest[16])
+MIR_CORE_DLL(void) mir_md5_hash(const BYTE *data, int len, BYTE digest[16])
{
mir_md5_state_t state;
mir_md5_init(&state);
diff --git a/src/mir_core/mir_core.def b/src/mir_core/mir_core.def index 3ec58865c6..f9e990ab40 100644 --- a/src/mir_core/mir_core.def +++ b/src/mir_core/mir_core.def @@ -230,3 +230,4 @@ mir_writeLogVW @227 bin2hex @228
bin2hexW @229
mir_hmac_sha1 @230
+mir_base64_encodebuf @231
diff --git a/tools/checksum/checksum.cpp b/tools/checksum/checksum.cpp index 9778a2c66c..6318cc66a6 100644 --- a/tools/checksum/checksum.cpp +++ b/tools/checksum/checksum.cpp @@ -43,7 +43,7 @@ static void PatchResourcesDirectory(PIMAGE_RESOURCE_DIRECTORY pIRD, PBYTE pBase) PatchResourceEntry(pIRDE, pBase);
}
-int PEChecksum( TCHAR *filename, mir_md5_byte_t digest[16] )
+int PEChecksum( TCHAR *filename, BYTE digest[16] )
{
HANDLE hFile = INVALID_HANDLE_VALUE;
HANDLE hMap;
@@ -364,7 +364,7 @@ int PEChecksum( TCHAR *filename, mir_md5_byte_t digest[16] ) if ( debug )
{
int i;
- mir_md5_byte_t digest2[16];
+ BYTE digest2[16];
mir_md5_state_t pms2;
mir_md5_init( &pms2 );
@@ -423,7 +423,7 @@ TCHAR* trtrim( TCHAR *str ) int process(TCHAR *filename)
{
int res;
- mir_md5_byte_t digest[16] = {0};
+ BYTE digest[16] = {0};
res = PEChecksum( filename, digest);
diff --git a/tools/checksum/commonheaders.h b/tools/checksum/commonheaders.h index dcd24ecf1b..4797a00c4a 100644 --- a/tools/checksum/commonheaders.h +++ b/tools/checksum/commonheaders.h @@ -17,16 +17,16 @@ /* Define the state of the MD5 Algorithm. */
-typedef unsigned char mir_md5_byte_t; /* 8-bit byte */
+typedef unsigned char BYTE; /* 8-bit byte */
typedef unsigned int mir_md5_word_t; /* 32-bit word */
typedef struct mir_md5_state_s {
mir_md5_word_t count[2]; /* message length in bits, lsw first */
mir_md5_word_t abcd[4]; /* digest buffer */
- mir_md5_byte_t buf[64]; /* accumulate block */
+ BYTE buf[64]; /* accumulate block */
} mir_md5_state_t;
MIR_CORE_DLL(void) mir_md5_init(mir_md5_state_t *pms);
-MIR_CORE_DLL(void) mir_md5_append(mir_md5_state_t *pms, const mir_md5_byte_t *data, int nbytes);
-MIR_CORE_DLL(void) mir_md5_finish(mir_md5_state_t *pms, mir_md5_byte_t digest[16]);
-MIR_CORE_DLL(void) mir_md5_hash(const mir_md5_byte_t *data, int len, mir_md5_byte_t digest[16]);
+MIR_CORE_DLL(void) mir_md5_append(mir_md5_state_t *pms, const BYTE *data, int nbytes);
+MIR_CORE_DLL(void) mir_md5_finish(mir_md5_state_t *pms, BYTE digest[16]);
+MIR_CORE_DLL(void) mir_md5_hash(const BYTE *data, int len, BYTE digest[16]);
diff --git a/tools/checksum/md5.cpp b/tools/checksum/md5.cpp index a7d7a641e3..b5ea0fa8b3 100644 --- a/tools/checksum/md5.cpp +++ b/tools/checksum/md5.cpp @@ -122,7 +122,7 @@ #define T64 /* 0xeb86d391 */ (T_MASK ^ 0x14792c6e)
//gfd*
-static void md5_process(mir_md5_state_t *pms, const mir_md5_byte_t *data /*[64]*/)
+static void md5_process(mir_md5_state_t *pms, const BYTE *data /*[64]*/)
{
mir_md5_word_t
a = pms->abcd[0], b = pms->abcd[1],
@@ -140,13 +140,13 @@ static void md5_process(mir_md5_state_t *pms, const mir_md5_byte_t *data /*[64]* */
static const int w = 1;
- if (*((const mir_md5_byte_t *)&w)) /* dynamic little-endian */
+ if (*((const BYTE *)&w)) /* dynamic little-endian */
{
/*
* On little-endian machines, we can process properly aligned
* data without copying it.
*/
- if ( !((data - (const mir_md5_byte_t *)0) & 3)) {
+ if ( !((data - (const BYTE *)0) & 3)) {
/* data are properly aligned */
X = (const mir_md5_word_t *)data;
} else {
@@ -161,7 +161,7 @@ static void md5_process(mir_md5_state_t *pms, const mir_md5_byte_t *data /*[64]* * On big-endian machines, we must arrange the bytes in the
* right order.
*/
- const mir_md5_byte_t *xp = data;
+ const BYTE *xp = data;
int i;
X = xbuf; /* (dynamic only) */
@@ -290,9 +290,9 @@ MIR_CORE_DLL(void) mir_md5_init(mir_md5_state_t *pms) pms->abcd[3] = 0x10325476;
}
-MIR_CORE_DLL(void) mir_md5_append(mir_md5_state_t *pms, const mir_md5_byte_t *data, int nbytes)
+MIR_CORE_DLL(void) mir_md5_append(mir_md5_state_t *pms, const BYTE *data, int nbytes)
{
- const mir_md5_byte_t *p = data;
+ const BYTE *p = data;
int left = nbytes;
int offset = (pms->count[0] >> 3) & 63;
mir_md5_word_t nbits = (mir_md5_word_t)(nbytes << 3);
@@ -327,29 +327,29 @@ MIR_CORE_DLL(void) mir_md5_append(mir_md5_state_t *pms, const mir_md5_byte_t *da memcpy(pms->buf, p, left);
}
-MIR_CORE_DLL(void) mir_md5_finish(mir_md5_state_t *pms, mir_md5_byte_t digest[16])
+MIR_CORE_DLL(void) mir_md5_finish(mir_md5_state_t *pms, BYTE digest[16])
{
- static const mir_md5_byte_t pad[64] = {
+ static const BYTE pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
- mir_md5_byte_t data[8];
+ BYTE data[8];
int i;
/* Save the length before padding. */
for (i = 0; i < 8; ++i)
- data[i] = (mir_md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ data[i] = (BYTE)(pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
mir_md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
mir_md5_append(pms, data, 8);
for (i = 0; i < 16; ++i)
- digest[i] = (mir_md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+ digest[i] = (BYTE)(pms->abcd[i >> 2] >> ((i & 3) << 3));
}
-MIR_CORE_DLL(void) mir_md5_hash(const mir_md5_byte_t *data, int len, mir_md5_byte_t digest[16])
+MIR_CORE_DLL(void) mir_md5_hash(const BYTE *data, int len, BYTE digest[16])
{
mir_md5_state_t state;
mir_md5_init(&state);
|