diff options
Diffstat (limited to 'sql/password.c')
-rw-r--r-- | sql/password.c | 45 |
1 files changed, 9 insertions, 36 deletions
diff --git a/sql/password.c b/sql/password.c index afa514a6c53..947620ddf7a 100644 --- a/sql/password.c +++ b/sql/password.c @@ -1,5 +1,6 @@ /* - Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved. + Copyright (c) 2000, 2011, Oracle and/or its affiliates. + Copyright (c) 2012, Monty Program Ab This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -71,41 +72,12 @@ /* New (MySQL 3.21+) random generation structure initialization SYNOPSIS - randominit() + my_rnd_init() rand_st OUT Structure to initialize seed1 IN First initialization parameter seed2 IN Second initialization parameter */ -void randominit(struct rand_struct *rand_st, ulong seed1, ulong seed2) -{ /* For mysql 3.21.# */ -#ifdef HAVE_purify - bzero((char*) rand_st,sizeof(*rand_st)); /* Avoid UMC varnings */ -#endif - rand_st->max_value= 0x3FFFFFFFL; - rand_st->max_value_dbl=(double) rand_st->max_value; - rand_st->seed1=seed1%rand_st->max_value ; - rand_st->seed2=seed2%rand_st->max_value; -} - - -/* - Generate random number. - SYNOPSIS - my_rnd() - rand_st INOUT Structure used for number generation - RETURN VALUE - generated pseudo random number -*/ - -double my_rnd(struct rand_struct *rand_st) -{ - rand_st->seed1=(rand_st->seed1*3+rand_st->seed2) % rand_st->max_value; - rand_st->seed2=(rand_st->seed1+rand_st->seed2+33) % rand_st->max_value; - return (((double) rand_st->seed1)/rand_st->max_value_dbl); -} - - /* Generate binary hash from raw text string Used for Pre-4.1 password handling @@ -185,7 +157,7 @@ void make_scrambled_password_323(char *to, const char *password) void scramble_323(char *to, const char *message, const char *password) { - struct rand_struct rand_st; + struct my_rnd_struct rand_st; ulong hash_pass[2], hash_message[2]; if (password && password[0]) @@ -194,7 +166,7 @@ void scramble_323(char *to, const char *message, const char *password) const char *message_end= message + SCRAMBLE_LENGTH_323; hash_password(hash_pass,password, (uint) strlen(password)); hash_password(hash_message, message, SCRAMBLE_LENGTH_323); - randominit(&rand_st,hash_pass[0] ^ hash_message[0], + my_rnd_init(&rand_st,hash_pass[0] ^ hash_message[0], hash_pass[1] ^ hash_message[1]); for (; message < message_end; message++) *to++= (char) (floor(my_rnd(&rand_st)*31)+64); @@ -222,7 +194,7 @@ my_bool check_scramble_323(const unsigned char *scrambled, const char *message, ulong *hash_pass) { - struct rand_struct rand_st; + struct my_rnd_struct rand_st; ulong hash_message[2]; /* Big enough for checks. */ uchar buff[16], scrambled_buff[SCRAMBLE_LENGTH_323 + 1]; @@ -235,7 +207,7 @@ check_scramble_323(const unsigned char *scrambled, const char *message, scrambled= scrambled_buff; hash_password(hash_message, message, SCRAMBLE_LENGTH_323); - randominit(&rand_st,hash_pass[0] ^ hash_message[0], + my_rnd_init(&rand_st,hash_pass[0] ^ hash_message[0], hash_pass[1] ^ hash_message[1]); to=buff; DBUG_ASSERT(sizeof(buff) > SCRAMBLE_LENGTH_323); @@ -316,7 +288,8 @@ void make_password_from_salt_323(char *to, const ulong *salt) rand_st INOUT structure used for number generation */ -void create_random_string(char *to, uint length, struct rand_struct *rand_st) +void create_random_string(char *to, uint length, + struct my_rnd_struct *rand_st) { char *end= to + length; /* Use pointer arithmetics as it is faster way to do so. */ |