29 #if HAVE_CRYPTGENRANDOM
56 err = read(fd, dst,
sizeof(*dst));
68 struct AVSHA *sha = (
void*)tmp;
70 static uint64_t i = 0;
71 static uint32_t
buffer[512] = { 0 };
72 unsigned char digest[20];
78 memset(buffer, 0,
sizeof(buffer));
93 buffer[++i & 511] += (t - last_t) % 3294638521
U;
94 if (last_i && i - last_i > 4 || i - last_i > 64 ||
TEST && i - last_i > 8)
101 buffer[0] = buffer[1] = 0;
118 #if HAVE_CRYPTGENRANDOM
120 if (CryptAcquireContext(&provider,
NULL,
NULL, PROV_RSA_FULL,
121 CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) {
122 BOOL ret = CryptGenRandom(provider,
sizeof(seed), (PBYTE) &seed);
123 CryptReleaseContext(provider, 0);
133 if (
read_random(&seed,
"/dev/urandom") ==
sizeof(seed))
135 if (
read_random(&seed,
"/dev/random") ==
sizeof(seed))
void av_sha_final(AVSHA *ctx, uint8_t *digest)
Finish hashing and output digest value.
void av_sha_update(AVSHA *ctx, const uint8_t *data, unsigned int len)
Update hash value.
static int read_random(uint32_t *dst, const char *file)
av_cold int av_sha_init(AVSHA *ctx, int bits)
Initialize SHA-1 or SHA-2 hashing.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
int avpriv_open(const char *filename, int flags,...)
A wrapper for open() setting O_CLOEXEC.
static uint32_t get_generic_seed(void)
high precision timer, useful to profile code
simple assert() macros that are a bit more flexible than ISO C assert().
common internal API header
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.