~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/pack.c

  • Committer: Brian Aker
  • Date: 2011-02-12 08:10:17 UTC
  • mto: This revision was merged to the branch mainline in revision 2161.
  • Revision ID: brian@tangent.org-20110212081017-7793i41ybt7gp5ty
More removal of session from includes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
226
226
    ptr[0]= DRIZZLE_MAX_SCRAMBLE_SIZE;
227
227
    ptr++;
228
228
 
229
 
    if (con->options & DRIZZLE_CON_MYSQL && con->options & DRIZZLE_CON_AUTH_PLUGIN)
230
 
    {
231
 
      snprintf((char *)ptr, DRIZZLE_MAX_SCRAMBLE_SIZE, "%s", con->password);
232
 
      ptr[DRIZZLE_MAX_SCRAMBLE_SIZE-1]= 0;
233
 
    }
234
 
    else if (con->options & DRIZZLE_CON_MYSQL)
 
229
    if (con->options & DRIZZLE_CON_MYSQL)
235
230
    {
236
231
      *ret_ptr= _pack_scramble_hash(con, ptr);
237
232
      if (*ret_ptr != DRIZZLE_RETURN_OK)
238
233
        return ptr;
239
234
    }
240
 
    else // We assume Drizzle
241
 
    {
 
235
    else
242
236
      snprintf((char *)ptr, DRIZZLE_MAX_SCRAMBLE_SIZE, "%s", con->password);
243
 
      ptr[DRIZZLE_MAX_SCRAMBLE_SIZE-1]= 0;
244
 
    }
245
237
 
246
238
    ptr+= DRIZZLE_MAX_SCRAMBLE_SIZE;
247
239
  }
266
258
static drizzle_return_t _pack_scramble_hash(drizzle_con_st *con,
267
259
                                            uint8_t *buffer)
268
260
{
269
 
  uint32_t x;
270
261
  SHA1_CTX ctx;
271
262
  uint8_t hash_tmp1[SHA1_DIGEST_LENGTH];
272
263
  uint8_t hash_tmp2[SHA1_DIGEST_LENGTH];
 
264
  uint32_t x;
273
265
 
274
266
  if (SHA1_DIGEST_LENGTH != DRIZZLE_MAX_SCRAMBLE_SIZE)
275
267
  {
303
295
  SHA1Final(buffer, &ctx);
304
296
 
305
297
  /* Fourth, xor the last hash against the first password hash. */
306
 
  x= 0;
307
 
  for (; x < SHA1_DIGEST_LENGTH; x++)
 
298
  for (x= 0; x < SHA1_DIGEST_LENGTH; x++)
308
299
    buffer[x]= buffer[x] ^ hash_tmp1[x];
309
300
 
310
301
  return DRIZZLE_RETURN_OK;