File tree Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Expand file tree Collapse file tree 2 files changed +8
-1
lines changed Original file line number Diff line number Diff line change 1111#ifndef ZSTD_RANDOM_H
1212#define ZSTD_RANDOM_H
1313
14+ #include "mem.h"
15+
1416/*
1517 * Portability helpers for secure random, exposes the following:
1618 * - `HAS_SECURE_RANDOM` a macro that determines if secure random API is available on
2426
2527#define HAS_SECURE_RANDOM
2628#include <sys/random.h>
27- static size_t getSecureRandom (void * buf , size_t buflen ) {
29+ MEM_STATIC size_t getSecureRandom (void * buf , size_t buflen ) {
2830 return getrandom (buf , buflen , GRND_NONBLOCK ) != (ssize_t ) buflen ;
2931}
3032
33+
3134#endif
3235
3336
Original file line number Diff line number Diff line change @@ -1910,6 +1910,10 @@ ZSTD_reset_matchState(ZSTD_matchState_t* ms,
19101910 int needTagTableInit = 1 ;
19111911#ifdef HAS_SECURE_RANDOM
19121912 if (forWho == ZSTD_resetTarget_CCtx ) {
1913+ /* TODO: We might not need to generate secure random everytime. For example,
1914+ * we could generate 256 bit of secure random and roll it using a cryptographic
1915+ * hash function. This optimization could lend some performance wins for very
1916+ * small inputs. */
19131917 size_t randomGenerated = getSecureRandom (& ms -> hashSalt , sizeof (ms -> hashSalt ));
19141918 if (!randomGenerated ) {
19151919 /* We've successfully generated secure random, so we don't need to explicitly memset
You can’t perform that action at this time.
0 commit comments