~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to server/sql_crypt.cc

Merged in Jay's tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
SQL_CRYPT::SQL_CRYPT(const char *password)
32
32
{
33
 
  ulong rand_nr[2];
34
 
  hash_password(rand_nr,password, strlen(password));
 
33
  uint32_t rand_nr[2];
 
34
  hash_password(rand_nr, password, strlen(password));
35
35
  crypt_init(rand_nr);
36
36
}
37
37
 
38
 
void SQL_CRYPT::crypt_init(ulong *rand_nr)
 
38
void SQL_CRYPT::crypt_init(uint32_t *rand_nr)
39
39
{
40
 
  uint i;
 
40
  uint32_t i;
41
41
  randominit(&rand,rand_nr[0],rand_nr[1]);
42
42
 
43
43
  for (i=0 ; i<=255; i++)
57
57
}
58
58
 
59
59
 
60
 
void SQL_CRYPT::encode(char *str,uint length)
 
60
void SQL_CRYPT::encode(char *str, uint32_t length)
61
61
{
62
 
  for (uint i=0; i < length; i++)
 
62
  for (uint32_t i=0; i < length; i++)
63
63
  {
64
 
    shift^=(uint) (my_rnd(&rand)*255.0);
65
 
    uint idx= (uint) (uchar) str[0];
 
64
    shift^=(uint32_t) (my_rnd(&rand)*255.0);
 
65
    uint32_t idx= (uint) (uchar) str[0];
66
66
    *str++ = (char) ((uchar) encode_buff[idx] ^ shift);
67
67
    shift^= idx;
68
68
  }
69
69
}
70
70
 
71
71
 
72
 
void SQL_CRYPT::decode(char *str,uint length)
 
72
void SQL_CRYPT::decode(char *str, uint32_t length)
73
73
{
74
 
  for (uint i=0; i < length; i++)
 
74
  for (uint32_t i=0; i < length; i++)
75
75
  {
76
 
    shift^=(uint) (my_rnd(&rand)*255.0);
77
 
    uint idx= (uint) ((uchar) str[0] ^ shift);
 
76
    shift^=(uint32_t) (my_rnd(&rand)*255.0);
 
77
    uint32_t idx= (uint32_t) ((uchar) str[0] ^ shift);
78
78
    *str = decode_buff[idx];
79
 
    shift^= (uint) (uchar) *str++;
 
79
    shift^= (uint32_t) (uchar) *str++;
80
80
  }
81
81
}