diff options
-rw-r--r-- | src/common/md5calc.c | 32 | ||||
-rw-r--r-- | src/common/md5calc.h | 2 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking.Defs.inc | 4 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_char.Hooks.inc | 12 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_login.Hooks.inc | 12 | ||||
-rw-r--r-- | src/plugins/HPMHooking/HPMHooking_map.Hooks.inc | 12 |
6 files changed, 36 insertions, 38 deletions
diff --git a/src/common/md5calc.c b/src/common/md5calc.c index bd6b48f10..d2fc32371 100644 --- a/src/common/md5calc.c +++ b/src/common/md5calc.c @@ -168,16 +168,15 @@ static void md5_Round_Calculate(const unsigned char *block, } /// @copydoc md5_interface::binary() -static void md5_string2binary(const char *string, unsigned char *output) +static void md5_buf2binary(const uint8 *buf, const int buf_size, uint8 *output) { //var /*8bit*/ unsigned char padding_message[64]; //Extended message 512bit 64byte - const unsigned char *pstring; // The position of string in the present scanning notes is held. + const uint8 *pbuf; // The position of string in the present scanning notes is held. /*32bit*/ - unsigned int string_byte_len, //The byte chief of string is held. - string_bit_len, //The bit length of string is held. + unsigned int buf_bit_len, //The bit length of string is held. copy_len, //The number of bytes which is used by 1-3 and which remained msg_digest[4]; //Message digest 128bit 4byte unsigned int *A = &msg_digest[0], //The message digest in accordance with RFC (reference) @@ -195,16 +194,15 @@ static void md5_string2binary(const char *string, unsigned char *output) //Step 1.Append Padding Bits (extension of a mark bit) //1-1 - string_byte_len = (unsigned int)strlen(string); //The byte chief of a character sequence is acquired. - pstring = (const unsigned char *)string; // The position of the present character sequence is set. + pbuf = buf; // The position of the present character sequence is set. //1-2 Repeat calculation until length becomes less than 64 bytes. - for (i=string_byte_len; 64<=i; i-=64,pstring+=64) - md5_Round_Calculate(pstring, A,B,C,D); + for (i=buf_size; 64<=i; i-=64,pbuf+=64) + md5_Round_Calculate(pbuf, A,B,C,D); //1-3 - copy_len = string_byte_len % 64; //The number of bytes which remained is computed. - strncpy((char *)padding_message, (const char *)pstring, copy_len); // A message is copied to an extended bit sequence. + copy_len = buf_size % 64; //The number of bytes which remained is computed. + strncpy((char *)padding_message, (const char *)pbuf, copy_len); // A message is copied to an extended bit sequence. memset(padding_message+copy_len, 0, 64 - copy_len); //It buries by 0 until it becomes extended bit length. padding_message[copy_len] |= 0x80; //The next of a message is 1. @@ -216,12 +214,12 @@ static void md5_string2binary(const char *string, unsigned char *output) } //Step 2.Append Length (the information on length is added) - string_bit_len = string_byte_len * 8; //From the byte chief to bit length (32 bytes of low rank) - memcpy(&padding_message[56], &string_bit_len, 4); //32 bytes of low rank is set. + buf_bit_len = buf_size * 8; //From the byte chief to bit length (32 bytes of low rank) + memcpy(&padding_message[56], &buf_bit_len, 4); //32 bytes of low rank is set. //When bit length cannot be expressed in 32 bytes of low rank, it is a beam raising to a higher rank. - if (UINT_MAX / 8 < string_byte_len) { - unsigned int high = (string_byte_len - UINT_MAX / 8) * 8; + if (UINT_MAX / 8 < (unsigned int)buf_size) { + unsigned int high = (buf_size - UINT_MAX / 8) * 8; memcpy(&padding_message[60], &high, 4); } else { memset(&padding_message[60], 0, 4); //In this case, it is good for a higher rank at 0. @@ -237,12 +235,12 @@ static void md5_string2binary(const char *string, unsigned char *output) /// @copydoc md5_interface::string() void md5_string(const char *string, char *output) { - unsigned char digest[16]; + uint8 digest[16]; nullpo_retv(string); nullpo_retv(output); - md5->binary(string,digest); + md5->binary((const uint8 *)string, (int)strlen(string), digest); snprintf(output, 33, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", digest[ 0], digest[ 1], digest[ 2], digest[ 3], digest[ 4], digest[ 5], digest[ 6], digest[ 7], @@ -267,7 +265,7 @@ void md5_salt(int len, char *output) void md5_defaults(void) { md5 = &md5_s; - md5->binary = md5_string2binary; + md5->binary = md5_buf2binary; md5->string = md5_string; md5->salt = md5_salt; } diff --git a/src/common/md5calc.h b/src/common/md5calc.h index b4d4995f9..f55ebe312 100644 --- a/src/common/md5calc.h +++ b/src/common/md5calc.h @@ -46,7 +46,7 @@ struct md5_interface { * @param[in] string The source string. * @param[out] output Output buffer (at least 16 bytes available). */ - void (*binary) (const char *string, unsigned char *output); + void (*binary) (const uint8 *buf, const int buf_size, uint8 *output); /** * Generates a random salt. diff --git a/src/plugins/HPMHooking/HPMHooking.Defs.inc b/src/plugins/HPMHooking/HPMHooking.Defs.inc index 15da10bde..57abf25e0 100644 --- a/src/plugins/HPMHooking/HPMHooking.Defs.inc +++ b/src/plugins/HPMHooking/HPMHooking.Defs.inc @@ -4462,8 +4462,8 @@ typedef bool (*HPMHOOK_post_mapreg_config_read) (bool retVal___, const char *fil #ifdef COMMON_MD5CALC_H /* md5 */ typedef void (*HPMHOOK_pre_md5_string) (const char **string, char **output); typedef void (*HPMHOOK_post_md5_string) (const char *string, char *output); -typedef void (*HPMHOOK_pre_md5_binary) (const char **string, unsigned char **output); -typedef void (*HPMHOOK_post_md5_binary) (const char *string, unsigned char *output); +typedef void (*HPMHOOK_pre_md5_binary) (const uint8 **buf, const int *buf_size, uint8 **output); +typedef void (*HPMHOOK_post_md5_binary) (const uint8 *buf, const int buf_size, uint8 *output); typedef void (*HPMHOOK_pre_md5_salt) (int *len, char **output); typedef void (*HPMHOOK_post_md5_salt) (int len, char *output); #endif // COMMON_MD5CALC_H diff --git a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc index f7b43ad50..e2108c8f8 100644 --- a/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_char.Hooks.inc @@ -15207,14 +15207,14 @@ void HP_md5_string(const char *string, char *output) { } return; } -void HP_md5_binary(const char *string, unsigned char *output) { +void HP_md5_binary(const uint8 *buf, const int buf_size, uint8 *output) { int hIndex = 0; if( HPMHooks.count.HP_md5_binary_pre ) { - void (*preHookFunc) (const char **string, unsigned char **output); + void (*preHookFunc) (const uint8 **buf, const int *buf_size, uint8 **output); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_md5_binary_pre[hIndex].func; - preHookFunc(&string, &output); + preHookFunc(&buf, &buf_size, &output); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -15222,13 +15222,13 @@ void HP_md5_binary(const char *string, unsigned char *output) { } } { - HPMHooks.source.md5.binary(string, output); + HPMHooks.source.md5.binary(buf, buf_size, output); } if( HPMHooks.count.HP_md5_binary_post ) { - void (*postHookFunc) (const char *string, unsigned char *output); + void (*postHookFunc) (const uint8 *buf, const int buf_size, uint8 *output); for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_md5_binary_post[hIndex].func; - postHookFunc(string, output); + postHookFunc(buf, buf_size, output); } } return; diff --git a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc index ffdfd15a8..a7e7afa4e 100644 --- a/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_login.Hooks.inc @@ -4743,14 +4743,14 @@ void HP_md5_string(const char *string, char *output) { } return; } -void HP_md5_binary(const char *string, unsigned char *output) { +void HP_md5_binary(const uint8 *buf, const int buf_size, uint8 *output) { int hIndex = 0; if( HPMHooks.count.HP_md5_binary_pre ) { - void (*preHookFunc) (const char **string, unsigned char **output); + void (*preHookFunc) (const uint8 **buf, const int *buf_size, uint8 **output); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_md5_binary_pre[hIndex].func; - preHookFunc(&string, &output); + preHookFunc(&buf, &buf_size, &output); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -4758,13 +4758,13 @@ void HP_md5_binary(const char *string, unsigned char *output) { } } { - HPMHooks.source.md5.binary(string, output); + HPMHooks.source.md5.binary(buf, buf_size, output); } if( HPMHooks.count.HP_md5_binary_post ) { - void (*postHookFunc) (const char *string, unsigned char *output); + void (*postHookFunc) (const uint8 *buf, const int buf_size, uint8 *output); for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_md5_binary_post[hIndex].func; - postHookFunc(string, output); + postHookFunc(buf, buf_size, output); } } return; diff --git a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc index e514b50fd..654c902d8 100644 --- a/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc +++ b/src/plugins/HPMHooking/HPMHooking_map.Hooks.inc @@ -43812,14 +43812,14 @@ void HP_md5_string(const char *string, char *output) { } return; } -void HP_md5_binary(const char *string, unsigned char *output) { +void HP_md5_binary(const uint8 *buf, const int buf_size, uint8 *output) { int hIndex = 0; if( HPMHooks.count.HP_md5_binary_pre ) { - void (*preHookFunc) (const char **string, unsigned char **output); + void (*preHookFunc) (const uint8 **buf, const int *buf_size, uint8 **output); *HPMforce_return = false; for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_pre; hIndex++ ) { preHookFunc = HPMHooks.list.HP_md5_binary_pre[hIndex].func; - preHookFunc(&string, &output); + preHookFunc(&buf, &buf_size, &output); } if( *HPMforce_return ) { *HPMforce_return = false; @@ -43827,13 +43827,13 @@ void HP_md5_binary(const char *string, unsigned char *output) { } } { - HPMHooks.source.md5.binary(string, output); + HPMHooks.source.md5.binary(buf, buf_size, output); } if( HPMHooks.count.HP_md5_binary_post ) { - void (*postHookFunc) (const char *string, unsigned char *output); + void (*postHookFunc) (const uint8 *buf, const int buf_size, uint8 *output); for(hIndex = 0; hIndex < HPMHooks.count.HP_md5_binary_post; hIndex++ ) { postHookFunc = HPMHooks.list.HP_md5_binary_post[hIndex].func; - postHookFunc(string, output); + postHookFunc(buf, buf_size, output); } } return; |