misc: better random strings

Generate alphanumerical random strings.

Prior this change curl used to create random hex strings. This was
mostly okay, but having alphanumerical random strings is better: The
strings have more entropy in the same space.

The MIME multipart boundary used to be mere 64-bits of randomness due
to being 16 hex chars. With these changes the boundary is 22
alphanumerical chars, or little over 130 bits of randomness.

Closes #11838
This commit is contained in:
Harry Sintonen 2023-09-12 13:51:21 +03:00 committed by Daniel Stenberg
parent f88cc654ec
commit 3aa3cc9b05
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
53 changed files with 213 additions and 151 deletions

View file

@ -34,6 +34,13 @@ CURLcode Curl_rand(struct Curl_easy *data, unsigned char *rnd, size_t num);
CURLcode Curl_rand_hex(struct Curl_easy *data, unsigned char *rnd,
size_t num);
/*
* Curl_rand_alnum() fills the 'rnd' buffer with a given 'num' size with random
* alphanumerical chars PLUS a null-terminating byte.
*/
CURLcode Curl_rand_alnum(struct Curl_easy *data, unsigned char *rnd,
size_t num);
#ifdef WIN32
/* Random generator shared between the Schannel vtls and Curl_rand*()
functions */