Created
June 11, 2012 11:15
-
-
Save vanhoefm/2909627 to your computer and use it in GitHub Desktop.
Security vulnerability in MySQL/MariaDB sql/password.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef char my_bool; | |
/* | |
Check that scrambled message corresponds to the password; the function | |
is used by server to check that recieved reply is authentic. | |
RETURN VALUE | |
0 password is correct | |
!0 password is invalid | |
*/ | |
my_bool | |
check_scramble(const char *scramble_arg, const char *message, | |
const uint8 *hash_stage2) | |
{ | |
SHA1_CONTEXT sha1_context; | |
uint8 buf[SHA1_HASH_SIZE]; | |
uint8 hash_stage2_reassured[SHA1_HASH_SIZE]; | |
mysql_sha1_reset(&sha1_context); | |
/* create key to encrypt scramble */ | |
mysql_sha1_input(&sha1_context, (const uint8*)message, SCRAMBLE_LENGTH); | |
mysql_sha1_input(&sha1_context, hash_stage2, SHA1_HASH_SIZE); | |
mysql_sha1_result(&sha1_context, buf); | |
/* encrypt scramble */ | |
my_crypt((char*)buf, buf, (const uchar*)scramble_arg, SCRAMBLE_LENGTH); | |
/* now buf supposedly contains hash_stage1: so we can get hash_stage2 */ | |
mysql_sha1_reset(&sha1_context); | |
mysql_sha1_input(&sha1_context, buf, SHA1_HASH_SIZE); | |
mysql_sha1_result(&sha1_context, hash_stage2_reassured); | |
return memcmp(hash_stage2, hash_stage2_reassured, SHA1_HASH_SIZE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment