diff options
author | David Goulet <dgoulet@torproject.org> | 2022-03-15 14:00:00 -0400 |
---|---|---|
committer | David Goulet <dgoulet@torproject.org> | 2022-03-15 14:00:00 -0400 |
commit | cf93d352095d252baf4cba07e51cb9a84ef8d9de (patch) | |
tree | 1c9d28477c84da27efe7bc4f3ec5de16a64e8aff /src/lib | |
parent | 9841e7173d7bad5aca0ceb529d31000e8a852089 (diff) | |
download | tor-cf93d352095d252baf4cba07e51cb9a84ef8d9de.tar.gz tor-cf93d352095d252baf4cba07e51cb9a84ef8d9de.zip |
crypto: Clarifying comment for the random hostname calculation
Closes #40520
Signed-off-by: David Goulet <dgoulet@torproject.org>
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/crypt_ops/crypto_rand.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/src/lib/crypt_ops/crypto_rand.c b/src/lib/crypt_ops/crypto_rand.c index 5bf3a65b3b..f39ee6c24f 100644 --- a/src/lib/crypt_ops/crypto_rand.c +++ b/src/lib/crypt_ops/crypto_rand.c @@ -568,6 +568,8 @@ crypto_random_hostname(int min_rand_len, int max_rand_len, const char *prefix, prefixlen = strlen(prefix); resultlen = prefixlen + strlen(suffix) + randlen + 16; + /* (x+(n-1))/n is an idiom for dividing x by n, rounding up to the nearest + * integer and thus why this construction. */ rand_bytes_len = ((randlen*5)+7)/8; if (rand_bytes_len % 5) rand_bytes_len += 5 - (rand_bytes_len%5); |