]> git.ipfire.org Git - thirdparty/rng-tools.git/blame - rngd.h
Release version 5.
[thirdparty/rng-tools.git] / rngd.h
CommitLineData
61af3de3
JG
1/*
2 * rngd.h -- rngd globals
3 *
4 * Copyright (C) 2001 Philipp Rumpf
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
d1b4c504 10 *
61af3de3
JG
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
d32709d1 18 * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335 USA
61af3de3
JG
19 */
20
21#ifndef RNGD__H
22#define RNGD__H
23
24#define _GNU_SOURCE
25
26#include "rng-tools-config.h"
27
28#include <unistd.h>
29#include <stdint.h>
62838c65 30#include <stdbool.h>
61af3de3
JG
31#include <stdio.h>
32#include <syslog.h>
33
34#include "fips.h"
35
62838c65
JG
36enum {
37 MAX_RNG_FAILURES = 25,
db508e37 38 RNG_OK_CREDIT = 1000, /* ~1:1250 false positives */
62838c65
JG
39};
40
61af3de3
JG
41/* Command line arguments and processing */
42struct arguments {
43 char *random_name;
c192b4cf 44 char *pid_file;
d1b4c504 45
61af3de3
JG
46 int random_step;
47 int fill_watermark;
61af3de3 48
ca6941f8
JG
49 bool quiet;
50 bool verbose;
51 bool daemon;
2a014536 52 bool enable_drng;
ca6941f8 53 bool enable_tpm;
61af3de3
JG
54};
55extern struct arguments *arguments;
56
d1b4c504
JG
57/* structures to store rng information */
58struct rng {
59 char *rng_name;
60 int rng_fd;
62838c65
JG
61 bool disabled;
62 int failures;
db508e37 63 int success;
d1b4c504
JG
64
65 int (*xread) (void *buf, size_t size, struct rng *ent_src);
66 fips_ctx_t *fipsctx;
67
68 struct rng *next;
69};
70
61af3de3 71/* Background/daemon mode */
ca6941f8 72extern bool am_daemon; /* True if we went daemon */
61af3de3
JG
73
74
75/*
76 * Routines and macros
77 */
78#define message(priority,fmt,args...) do { \
79 if (am_daemon) { \
80 syslog((priority), fmt, ##args); \
81 } else { \
82 fprintf(stderr, fmt, ##args); \
83 fprintf(stderr, "\n"); \
84 } \
85} while (0)
86
a26d20cf 87extern void src_list_add(struct rng *ent_src);
c192b4cf 88extern int write_pid_file(const char *pid_fn);
61af3de3
JG
89#endif /* RNGD__H */
90