~ubuntu-branches/ubuntu/lucid/gnutls26/lucid-proposed

« back to all changes in this revision

Viewing changes to lib/auth_srp_passwd.c

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2008-06-24 19:13:25 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20080624191325-33rewwn0p11jzdvq
Tags: 2.4.0-2
* Standards version 3.8.0. Rename README.source_and_patches to README.source.
* Upload to unstable.
* Point watchfile to stable releases again.
* Merge experimental and unstable changelog.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
#include <gnutls_str.h>
40
40
#include <gnutls_datum.h>
41
41
#include <gnutls_num.h>
42
 
#include <gc.h>
 
42
#include <random.h>
43
43
 
44
44
static int _randomize_pwd_entry (SRP_PWD_ENTRY * entry);
45
45
 
397
397
_randomize_pwd_entry (SRP_PWD_ENTRY * entry)
398
398
{
399
399
  unsigned char rnd;
 
400
  int ret;
400
401
 
401
402
  if (entry->g.size == 0 || entry->n.size == 0)
402
403
    {
404
405
      return GNUTLS_E_INTERNAL_ERROR;
405
406
    }
406
407
 
407
 
  if (gc_nonce (&rnd, 1) != GC_OK)
 
408
  ret = _gnutls_rnd (RND_NONCE, &rnd, 1);
 
409
  if (ret < 0)
408
410
    {
409
411
      gnutls_assert ();
410
 
      return GNUTLS_E_RANDOM_FAILED;
 
412
      return ret;
411
413
    }
 
414
 
412
415
  entry->salt.size = (rnd % 10) + 9;
413
416
 
414
417
  entry->v.data = gnutls_malloc (20);
419
422
      return GNUTLS_E_MEMORY_ERROR;
420
423
    }
421
424
 
422
 
  if (gc_nonce (entry->v.data, 20) != GC_OK)
 
425
  ret = _gnutls_rnd (RND_RANDOM, entry->v.data, 20);
 
426
  if ( ret < 0)
423
427
    {
424
428
      gnutls_assert ();
425
 
      return GNUTLS_E_RANDOM_FAILED;
 
429
      return ret;
426
430
    }
427
431
 
428
432
  entry->salt.data = gnutls_malloc (entry->salt.size);
432
436
      return GNUTLS_E_MEMORY_ERROR;
433
437
    }
434
438
 
435
 
  if (gc_nonce (entry->salt.data, entry->salt.size) != GC_OK)
 
439
  ret = _gnutls_rnd (RND_NONCE, entry->salt.data, entry->salt.size);
 
440
  if (ret < 0)
436
441
    {
437
 
      gnutls_assert ();
438
 
      return GNUTLS_E_RANDOM_FAILED;
 
442
      gnutls_assert();
 
443
      return ret;
439
444
    }
440
 
 
 
445
    
441
446
  return 0;
442
447
}
443
448