aboutsummaryrefslogtreecommitdiff
path: root/wrapper.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-01-21 08:44:53 -0800
committerJunio C Hamano <gitster@pobox.com>2025-01-21 08:44:53 -0800
commitcb441e1ec3f3cf475d9037a4ce74e8fccd6be7d8 (patch)
tree235fe13d72cc2897e498dbdd5d7a9ab0ad7c5415 /wrapper.h
parent57ebdd5af4031ddd0e012e68c5e423fd0671ed8c (diff)
parent0b4f8afef6b744d5aa92883c5a6c1985be67cc7c (diff)
downloadgit-cb441e1ec3f3cf475d9037a4ce74e8fccd6be7d8.tar.xz
Merge branch 'ps/reftable-get-random-fix'
The code to compute "unique" name used git_rand() which can fail or get stuck; the callsite does not require cryptographic security. Introduce the "insecure" mode and use it appropriately. * ps/reftable-get-random-fix: reftable/stack: accept insecure random bytes wrapper: allow generating insecure random bytes
Diffstat (limited to 'wrapper.h')
-rw-r--r--wrapper.h16
1 files changed, 12 insertions, 4 deletions
diff --git a/wrapper.h b/wrapper.h
index a6b3e1f09e..7df824e34a 100644
--- a/wrapper.h
+++ b/wrapper.h
@@ -127,18 +127,26 @@ int open_nofollow(const char *path, int flags);
void sleep_millisec(int millisec);
+enum {
+ /*
+ * Accept insecure bytes, which some CSPRNG implementations may return
+ * in case the entropy pool has been exhausted.
+ */
+ CSPRNG_BYTES_INSECURE = (1 << 0),
+};
+
/*
* Generate len bytes from the system cryptographically secure PRNG.
* Returns 0 on success and -1 on error, setting errno. The inability to
- * satisfy the full request is an error.
+ * satisfy the full request is an error. Accepts CSPRNG flags.
*/
-int csprng_bytes(void *buf, size_t len);
+int csprng_bytes(void *buf, size_t len, unsigned flags);
/*
* Returns a random uint32_t, uniformly distributed across all possible
- * values.
+ * values. Accepts CSPRNG flags.
*/
-uint32_t git_rand(void);
+uint32_t git_rand(unsigned flags);
/* Provide log2 of the given `size_t`. */
static inline unsigned log2u(uintmax_t sz)