Commit 807698db authored by Daniel Stenberg's avatar Daniel Stenberg
Browse files

rand: make it work without TLS backing

Regression introduced in commit f682156a

Reported-by: John Kohl
Bug: https://curl.haxx.se/mail/lib-2017-01/0055.html
parent a18db792
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -680,7 +680,7 @@ size_t Curl_axtls_version(char *buffer, size_t size)
  return snprintf(buffer, size, "axTLS/%s", ssl_version());
}

int Curl_axtls_random(struct Curl_easy *data,
CURLcode Curl_axtls_random(struct Curl_easy *data,
                           unsigned char *entropy,
                           size_t length)
{
@@ -694,7 +694,7 @@ int Curl_axtls_random(struct Curl_easy *data,
    RNG_initialize();
  }
  get_random((int)length, entropy);
  return 0;
  return CURLE_OK;
}

#endif /* USE_AXTLS */
+4 −4
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 2010, DirecTV, Contact: Eric Hu <ehu@directv.com>
 * Copyright (C) 2010 - 2015, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 2010 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -42,7 +42,7 @@ void Curl_axtls_session_free(void *ptr);
size_t Curl_axtls_version(char *buffer, size_t size);
int Curl_axtls_shutdown(struct connectdata *conn, int sockindex);
int Curl_axtls_check_cxn(struct connectdata *conn);
int Curl_axtls_random(struct Curl_easy *data,
CURLcode Curl_axtls_random(struct Curl_easy *data,
                           unsigned char *entropy,
                           size_t length);

+8 −8
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -917,19 +917,19 @@ Curl_cyassl_connect(struct connectdata *conn,
  return CURLE_OK;
}

int Curl_cyassl_random(struct Curl_easy *data,
CURLcode Curl_cyassl_random(struct Curl_easy *data,
                            unsigned char *entropy,
                            size_t length)
{
  RNG rng;
  (void)data;
  if(InitRng(&rng))
    return 1;
    return CURLE_FAILED_INIT;
  if(length > UINT_MAX)
    return 1;
    return CURLE_FAILED_INIT;
  if(RNG_GenerateBlock(&rng, entropy, (unsigned)length))
    return 1;
  return 0;
    return CURLE_FAILED_INIT;
  return CURLE_OK;
}

void Curl_cyassl_sha256sum(const unsigned char *tmp, /* input */
+4 −4
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
 *                            | (__| |_| |  _ <| |___
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -51,7 +51,7 @@ int Curl_cyassl_init(void);
CURLcode Curl_cyassl_connect_nonblocking(struct connectdata *conn,
                                         int sockindex,
                                         bool *done);
int Curl_cyassl_random(struct Curl_easy *data,
CURLcode Curl_cyassl_random(struct Curl_easy *data,
                            unsigned char *entropy,
                            size_t length);
void Curl_cyassl_sha256sum(const unsigned char *tmp, /* input */
+4 −4
Original line number Diff line number Diff line
@@ -6,7 +6,7 @@
 *                             \___|\___/|_| \_\_____|
 *
 * Copyright (C) 2012 - 2014, Nick Zitzmann, <nickzman@gmail.com>.
 * Copyright (C) 2012 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
 * Copyright (C) 2012 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution. The terms
@@ -2427,7 +2427,7 @@ bool Curl_darwinssl_data_pending(const struct connectdata *conn,
    return false;
}

int Curl_darwinssl_random(unsigned char *entropy,
CURLcode Curl_darwinssl_random(unsigned char *entropy,
                               size_t length)
{
  /* arc4random_buf() isn't available on cats older than Lion, so let's
@@ -2442,7 +2442,7 @@ int Curl_darwinssl_random(unsigned char *entropy,
    random_number >>= 8;
  }
  i = random_number = 0;
  return 0;
  return CURLE_OK;
}

void Curl_darwinssl_md5sum(unsigned char *tmp, /* input */
Loading