~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/password.c

  • Committer: Brian Aker
  • Date: 2008-07-15 08:57:01 UTC
  • Revision ID: brian@tangent.org-20080715085701-h7i77in02mqsg2sv
Commit cleanup of export types.

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
    seed2      IN   Second initialization parameter
76
76
*/
77
77
 
78
 
void randominit(struct rand_struct *rand_st, ulong seed1, ulong seed2)
 
78
void randominit(struct rand_struct *rand_st, uint32_t seed1, uint32_t seed2)
79
79
{                                               /* For mysql 3.21.# */
80
80
#ifdef HAVE_purify
81
81
  bzero((char*) rand_st,sizeof(*rand_st));      /* Avoid UMC varnings */
114
114
    password_len IN  password length (password may be not null-terminated)
115
115
*/
116
116
 
117
 
void hash_password(ulong *result, const char *password, uint password_len)
 
117
void hash_password(uint32_t *result, const char *password, uint32_t password_len)
118
118
{
119
119
  register ulong nr=1345345333L, add=7, nr2=0x12345671L;
120
 
  ulong tmp;
 
120
  uint32_t tmp;
121
121
  const char *password_end= password + password_len;
122
122
  for (; password < password_end; password++)
123
123
  {
124
124
    if (*password == ' ' || *password == '\t')
125
125
      continue;                                 /* skip space in password */
126
 
    tmp= (ulong) (uchar) *password;
 
126
    tmp= (uint32_t) (uchar) *password;
127
127
    nr^= (((nr & 63)+add)*tmp)+ (nr << 8);
128
128
    nr2+=(nr2 << 8) ^ nr;
129
129
    add+=tmp;
130
130
  }
131
 
  result[0]=nr & (((ulong) 1L << 31) -1L); /* Don't use sign bit (str2int) */;
132
 
  result[1]=nr2 & (((ulong) 1L << 31) -1L);
 
131
  result[0]=nr & (((uint32_t) 1L << 31) -1L); /* Don't use sign bit (str2int) */;
 
132
  result[1]=nr2 & (((uint32_t) 1L << 31) -1L);
133
133
}
134
134
 
135
135
 
146
146
{
147
147
  ulong hash_res[2];
148
148
  hash_password(hash_res, password, (uint) strlen(password));
149
 
  sprintf(to, "%08lx%08lx", hash_res[0], hash_res[1]);
 
149
  sprintf(to, "%08x%08x", hash_res[0], hash_res[1]);
150
150
}
151
151
 
152
152
 
203
203
*/
204
204
 
205
205
my_bool
206
 
check_scramble_323(const char *scrambled, const char *message,
207
 
                   ulong *hash_pass)
 
206
check_scramble_323(const char *scrambled, const char *message, uint32_t *hash_pass)
208
207
{
209
208
  struct rand_struct rand_st;
210
209
  ulong hash_message[2];
248
247
    Password hashes in old format must have length divisible by 8
249
248
*/
250
249
 
251
 
void get_salt_from_password_323(ulong *res, const char *password)
 
250
void get_salt_from_password_323(uint32_t *res, const char *password)
252
251
{
253
252
  res[0]= res[1]= 0;
254
253
  if (password)
273
272
    salt  IN  password in salt format, 2 ulongs 
274
273
*/
275
274
 
276
 
void make_password_from_salt_323(char *to, const ulong *salt)
 
275
void make_password_from_salt_323(char *to, const uint32_t *salt)
277
276
{
278
 
  sprintf(to,"%08lx%08lx", salt[0], salt[1]);
 
277
  sprintf(to,"%08x%08x", salt[0], salt[1]);
279
278
}
280
279
 
281
280