Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
mailutils
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
b3c14bfb
...
b3c14bfb283c5fe105fb23dbab11b09b07c2e613
authored
2005-02-27 20:13:44 +0000
by
Sergey Poznyakoff
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Provide place handlers for handling MySQL 4.1.x scrambled passwords.
1 parent
8920f9ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
sql/mysql.c
sql/mysql.c
View file @
b3c14bf
...
...
@@ -249,6 +249,51 @@ scramble_password (unsigned long *result, const char *password)
result
[
1
]
=
nr2
&
(((
unsigned
long
)
1L
<<
31
)
-
1L
);
}
#if 0
static void
octet2hex (char *to, const unsigned char *str, unsigned len)
{
const char *str_end= str + len;
static char d[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
for ( ; str != str_end; ++str)
{
*to++ = d[(*str & 0xF0) >> 4];
*to++ = d[*str & 0x0F];
}
*to= '\0';
}
#define SHA1_HASH_SIZE 20
int
mu_check_mysql_4x_password (const char *scrambled, const char *message)
{
struct sha1_ctx sha1_context;
uint8 hash_stage2[SHA1_HASH_SIZE];
char to[2*SHA1_HASH_SIZE + 2];
if (!to)
return 1;
/* stage 1: hash password */
sha1_init_ctx (&sha1_context);
sha1_process_bytes (message, strlen (message), &sha1_context);
sha1_finish_ctx (&sha1_context, to);
/* stage 2: hash stage1 output */
sha1_init_ctx (&sha1_context);
sha1_process_bytes (to, SHA1_HASH_SIZE, &sha1_context);
sha1_finish_ctx (&sha1_context, hash_stage2);
/* convert hash_stage2 to hex string */
*to++= '*';
octet2hex (to, hash_stage2, SHA1_HASH_SIZE);
/* Compare both strings */
return memcmp (to, scrambled, strlen (scrambled));
}
#endif
/* Check whether a plaintext password MESSAGE matches MySQL scrambled password
PASSWORD */
int
...
...
Please
register
or
sign in
to post a comment