gg-crypto-ucryptolib.c
int crypto_stage2_init(GG_crypt *ggc) {
  static char buf[SEED_NUMBYTES];
  GG_ptr rand = ggp_init(buf, SEED_NUMBYTES);

  if (!ggc)
    return 0;

  if (ggp_full_read(ggc->dev_urandom, &rand, SEED_NUMBYTES) != SEED_NUMBYTES) {
    REPORT_ERROR("Could not read dev_urandom");
    return 0;
  }

  /*
   * Seed the cryptolib
   * This is not very high quality entropy, but should be good enough
   */
  clPRNG_init(&ggc->prng, buf, SEED_NUMBYTES);

  close(ggc->dev_urandom);

  /* Loop until we draw a proper private key. This will never loop in practice */
  do {
    clPRNG_draw(&ggc->prng, ggc->x, sizeof(ggc->x));
  } while (clDHgenerate(&ggc->myDH, ggc->x, sizeof(ggc->x), ggc->pubkey_bin) !=
           1);

  DEBUG(2, "worker %d: generated DH key\n", getpid());

  return 1;
}
/*
 * This is the second stage of the initialization
 * Return 0 on failure
 */
This is the second stage of the initialization
Return 0 on failure
This is the second stage of the initialization Return 0 on failure
int crypto_stage2_init(GG_crypt *ggc) {
  static char buf[SEED_NUMBYTES];
  GG_ptr rand = ggp_init(buf, SEED_NUMBYTES);
  if (!ggc)
    return 0;
  if (ggp_full_read(ggc->dev_urandom, &rand, SEED_NUMBYTES) != SEED_NUMBYTES) {
    REPORT_ERROR("Could not read dev_urandom");
    return 0;
  }
  clPRNG_init(&ggc->prng, buf, SEED_NUMBYTES);
  close(ggc->dev_urandom);
  do {
    clPRNG_draw(&ggc->prng, ggc->x, sizeof(ggc->x));
  } while (clDHgenerate(&ggc->myDH, ggc->x, sizeof(ggc->x), ggc->pubkey_bin) !=
           1);
  DEBUG(2, "worker %d: generated DH key\n", getpid());
  return 1;
}
int crypto_stage2_init ( GG_crypt * ggc ) { static char buf [ SEED_NUMBYTES ] ; GG_ptr rand = ggp_init ( buf , SEED_NUMBYTES ) ; if ( ! ggc ) return 0 ; if ( ggp_full_read ( ggc -> dev_urandom , & rand , SEED_NUMBYTES ) != SEED_NUMBYTES ) { REPORT_ERROR ( " " ) ; return 0 ; } clPRNG_init ( & ggc -> prng , buf , SEED_NUMBYTES ) ; close ( ggc -> dev_urandom ) ; do { clPRNG_draw ( & ggc -> prng , ggc -> x , sizeof ( ggc -> x ) ) ; } while ( clDHgenerate ( & ggc -> myDH , ggc -> x , sizeof ( ggc -> x ) , ggc -> pubkey_bin ) != 1 ) ; DEBUG ( 2 , " \n " , getpid ( ) ) ; return 1 ; }
This is the second stage of the initialization
 Return 0 on failure
This is the second stage of the initialization Return 0 on failure
/*
   * Seed the cryptolib
   * This is not very high quality entropy, but should be good enough
   */ /* Loop until we draw a proper private key. This will never loop in practice */