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