36#include <openssl/rand.h>
62 setvbuf(fp,
NULL, _IONBF, 0);
63 err = fread(
dst, 1,
len, fp);
82 static uint64_t
i = 0;
83 static uint32_t
buffer[512] = { 0 };
84 unsigned char digest[20];
86 int repeats[3] = { 0 };
102 int incremented_i = 0;
103 int cur_td = t - last_t;
104 if (last_t + 2*last_td + (CLOCKS_PER_SEC > 1000) < t) {
110 buffer[++
i & 511] += cur_td % 3294638521U;
112 }
else if (t != last_t && repeats[0] > 0 && repeats[1] > 0 &&
113 repeats[2] > 0 && repeats[0] != repeats[1] &&
114 repeats[0] != repeats[2]) {
120 buffer[++
i & 511] += (repeats[0] + repeats[1] + repeats[2]) % 3294638521U;
123 buffer[
i & 511] = 1664525*
buffer[
i & 511] + 1013904223 + (cur_td % 3294638521U);
125 if (incremented_i && (t - init_t) >= CLOCKS_PER_SEC>>5) {
126 if (last_i &&
i - last_i > 4 ||
i - last_i > 64 ||
TEST &&
i - last_i > 8)
133 if (repeats[0] != repeats[1]) {
134 repeats[2] = repeats[1];
135 repeats[1] = repeats[0];
164 BCRYPT_ALG_HANDLE algo_handle;
165 NTSTATUS ret = BCryptOpenAlgorithmProvider(&algo_handle, BCRYPT_RNG_ALGORITHM,
166 MS_PRIMITIVE_PROVIDER, 0);
167 if (BCRYPT_SUCCESS(ret)) {
168 NTSTATUS ret = BCryptGenRandom(algo_handle, (PUCHAR)buf,
len, 0);
169 BCryptCloseAlgorithmProvider(algo_handle, 0);
170 if (BCRYPT_SUCCESS(ret))
175#if HAVE_ARC4RANDOM_BUF
176 arc4random_buf(buf,
len);
185 gcry_randomize(buf,
len, GCRY_VERY_STRONG_RANDOM);
188 if (RAND_bytes(buf,
len) == 1)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define i(width, name, range_min, range_max)
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
int av_random_bytes(uint8_t *buf, size_t len)
Generate cryptographically secure random data, i.e.
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
#define AVERROR_EXTERNAL
Generic error in an external library.
void av_sha_update(struct AVSHA *ctx, const uint8_t *data, size_t len)
Update hash value.
void av_sha_final(AVSHA *ctx, uint8_t *digest)
Finish hashing and output digest value.
av_cold int av_sha_init(AVSHA *ctx, int bits)
Initialize SHA-1 or SHA-2 hashing.
FILE * avpriv_fopen_utf8(const char *path, const char *mode)
Open a file using a UTF-8 filename.
common internal API header
static uint32_t get_generic_seed(void)
static int read_random(uint8_t *dst, size_t len, const char *file)
Public header for SHA-1 & SHA-256 hash function implementations.
high precision timer, useful to profile code