~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle-1.0/libdrizzle/pack.c

  • Committer: Mark Atwood
  • Date: 2011-08-12 04:08:33 UTC
  • mfrom: (2385.2.17 refactor5)
  • Revision ID: me@mark.atwood.name-20110812040833-u6j85nc6ahuc0dtz
mergeĀ lp:~olafvdspek/drizzle/refactor5

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