diff options
author | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2018-08-26 19:41:23 -0400 |
---|---|---|
committer | Alex Xu (Hello71) <alex_y_xu@yahoo.ca> | 2018-08-26 19:41:23 -0400 |
commit | da69892f56a081cb4cd65eb0a8065783d9473bd3 (patch) | |
tree | f4bf33fc7c65366163565a12bd0254f0c7c21975 /src/util.h | |
parent | f3664a28a927c7a9a122af4d72a89114b26f39bd (diff) | |
download | random-seed-da69892f56a081cb4cd65eb0a8065783d9473bd3.tar.xz random-seed-da69892f56a081cb4cd65eb0a8065783d9473bd3.zip |
Refactor.
Diffstat (limited to 'src/util.h')
-rw-r--r-- | src/util.h | 25 |
1 files changed, 11 insertions, 14 deletions
@@ -1,19 +1,17 @@ // SPDX-License-Identifier: BSD-3-Clause -#ifndef RANDOM_SEED_UTIL_H -#define RANDOM_SEED_UTIL_H +#pragma once -#include <errno.h> +#include <sys/types.h> #include <stdbool.h> -#include <stddef.h> #include <string.h> -#include <sys/syscall.h> -#include <unistd.h> -#include "sha2.h" - -#define GRND_NONBLOCK 0x01 -#define GRND_RANDOM 0x02 +#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) +#ifdef HAVE_FUNC_ATTRIBUTE_FALLTHROUGH +#define FALLS_THROUGH __attribute__((fallthrough)) +#else +#define FALLS_THROUGH (void)0 +#endif /* The pool size is fixed at 4096 bits since Linux 2.6. */ #define RAND_POOL_SIZE 512 @@ -23,12 +21,11 @@ /* The salt is the random data */ #define SALT_LEN RAND_POOL_SIZE +#define GRND_NONBLOCK 0x01 +#define GRND_RANDOM 0x02 + static inline bool streq(const char *s1, const char *s2) { return !strcmp(s1, s2); } ssize_t random_get(void *buf, size_t buflen, unsigned int flags); -size_t hex2mem(unsigned char *dest, size_t size, const char *src); -void mem2hex(char *dest, const void *src, size_t size); - -#endif |