Commit ad7291c1 authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

ossl_seed: fix the last resort PRNG seeding

Instead of just abusing the pseudo-randomizer from Curl_FormBoundary(),
this now uses Curl_ossl_random() to get entropy.
parent d09d08dc
Loading
Loading
Loading
Loading
+6 −19
Original line number Diff line number Diff line
@@ -236,27 +236,14 @@ static int ossl_seed(struct SessionHandle *data)

  /* If we get here, it means we need to seed the PRNG using a "silly"
     approach! */
  {
    int len;
    char *area;

    /* Changed call to RAND_seed to use the underlying RAND_add implementation
     * directly.  Do this in a loop, with the amount of additional entropy
     * being dependent upon the algorithm used by Curl_FormBoundary(): N bytes
     * of a 7-bit ascii set. -- Richard Gorton, March 11 2003.
     */

  do {
      area = Curl_FormBoundary();
      if(!area)
        return 3; /* out of memory */

      len = curlx_uztosi(strlen(area));
      RAND_add(area, len, (len >> 1));
    int len;
    unsigned char randb[64];
    Curl_ossl_random(data, randb, sizeof(randb));

      free(area); /* now remove the random junk */
    len = sizeof(randb);
    RAND_add(randb, len, (len >> 1));
  } while(!RAND_status());
  }

  /* generates a default path for the random seed file */
  buf[0]=0; /* blank it first */