chiark / gitweb /
723917057ddb9071cdd1e8d9eb24ad5d929f2fdf
[elogind.git] / src / basic / random-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 /***
5   This file is part of systemd.
6
7   Copyright 2010 Lennart Poettering
8 ***/
9
10 #include <stdbool.h>
11 #include <stddef.h>
12 #include <stdint.h>
13
14 int acquire_random_bytes(void *p, size_t n, bool high_quality_required);
15 void pseudorandom_bytes(void *p, size_t n);
16 void random_bytes(void *p, size_t n);
17 void initialize_srand(void);
18
19 static inline uint64_t random_u64(void) {
20         uint64_t u;
21         random_bytes(&u, sizeof(u));
22         return u;
23 }
24
25 static inline uint32_t random_u32(void) {
26         uint32_t u;
27         random_bytes(&u, sizeof(u));
28         return u;
29 }