summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/havege.c34
-rw-r--r--src/havege.h7
-rw-r--r--src/havegecmd.c2
-rw-r--r--src/havegecmd.h2
-rw-r--r--src/havegecollect.c2
-rw-r--r--src/havegecollect.h2
-rw-r--r--src/haveged.c16
-rw-r--r--src/haveged.h2
-rw-r--r--src/havegetest.c2
-rw-r--r--src/havegetest.h2
-rw-r--r--src/havegetune.c2
-rw-r--r--src/havegetune.h2
-rw-r--r--src/oneiteration.h2
13 files changed, 45 insertions, 32 deletions
diff --git a/src/havege.c b/src/havege.c
index b0070d1..a1dc0a6 100644
--- a/src/havege.c
+++ b/src/havege.c
@@ -1,7 +1,7 @@
/**
** Simple entropy harvester based upon the havege RNG
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2009-2014 Gary Wuertz gary@issiweb.com
** Copyright 2011-2012 BenEleventh Consulting manolson@beneleventh.com
**
@@ -317,7 +317,7 @@ int havege_status_dump( /* RETURN: output length */
{
struct h_status status;
int n = 0;
-
+
if (buf != 0) {
*buf = 0;
len -= 1;
@@ -346,7 +346,7 @@ int havege_status_dump( /* RETURN: output length */
case H_SD_TOPIC_TEST:
{
H_UINT m;
-
+
if (strlen(status.tot_tests)>0) {
n += snprintf(buf+n, len-n, "tot tests(%s): ", status.tot_tests);
if ((m = status.n_tests[ H_OLT_TOT_A_P] + status.n_tests[ H_OLT_TOT_A_F])>0)
@@ -368,19 +368,29 @@ int havege_status_dump( /* RETURN: output length */
case H_SD_TOPIC_SUM:
{
char units[] = {'T', 'G', 'M', 'K', 0};
- double factor = 1024.0 * 1024.0 * 1024.0 * 1024.0;
+ double factor[2];
+ factor[0] = 1024.0 * 1024.0 * 1024.0 * 1024.0;
+ factor[1] = factor[0];
double sz = ((double)hptr->n_fills * hptr->i_collectSz) * sizeof(H_UINT);
- int i;
-
- for (i=0;0 != units[i];i++) {
- if (sz >= factor)
+ double ent = ((double) hptr->n_entropy_bytes);
+ int i[2];
+
+ for (i[0]=0;0 != units[i[0]];i[0]++) {
+ if (sz >= factor[0])
+ break;
+ factor[0] /= 1024.0;
+ }
+ for (i[1]=0;0 != units[i[1]];i[1]++) {
+ if (ent >= factor[1])
break;
- factor /= 1024.0;
+ factor[1] /= 1024.0;
}
- n = snprintf(buf, len, "fills: %u, generated: %.4g %c bytes",
+ n = snprintf(buf, len, "fills: %u, generated: %.4g %c bytes, RNDADDENTROPY: %.4g %c bytes",
hptr->n_fills,
- sz / factor,
- units[i]
+ sz / factor[0],
+ units[i[0]],
+ ent / factor[1],
+ units[i[1]]
);
}
break;
diff --git a/src/havege.h b/src/havege.h
index 4c34964..4a5b026 100644
--- a/src/havege.h
+++ b/src/havege.h
@@ -1,7 +1,7 @@
/**
** Simple entropy harvester based upon the havege RNG
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2009-2014 Gary Wuertz gary@issiweb.com
** Copyright 2011-2012 BenEleventh Consulting manolson@beneleventh.com
**
@@ -56,7 +56,7 @@ typedef void (*pMsg)(const char *format, ...);
typedef int (*pRawIn)(volatile H_UINT *pData, H_UINT szData);
/**
* options for H_PARAMS below. Lower byte transferred from verbose settings
- * upper byte set by diagnositic run options
+ * upper byte set by diagnositic run options
*/
#define H_VERBOSE 0x001 /* deprecated from ver 1.7 */
#define H_DEBUG_INFO 0x001 /* Show config info, retries */
@@ -72,7 +72,7 @@ typedef int (*pRawIn)(volatile H_UINT *pData, H_UINT szData);
/**
* Initialization parameters. Use non-zero values to override default values.
* Notes:
- *
+ *
* 1) Correspondence between provided value and value of H_PTR members are:
* ioSz <==> i_readSz, collectSize <==> i_collectSz, nCores <==> n_cores,
* options <==> havege_opts
@@ -159,6 +159,7 @@ typedef struct h_anchor {
H_UINT m_sz; /* size of thread ipc area (bytes) */
H_UINT n_cores; /* number of cores */
H_UINT n_fills; /* number of buffer fills */
+ size_t n_entropy_bytes; /* total amount of entropy (byte) */
} *H_PTR;
/**
* Fail/Success counters for tot and production tests.
diff --git a/src/havegecmd.c b/src/havegecmd.c
index 9ced105..06a2367 100644
--- a/src/havegecmd.c
+++ b/src/havegecmd.c
@@ -1,7 +1,7 @@
/**
** Provide HAVEGE socket communication API
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2018 Werner Fink <werner@suse.de>
**
** This program is free software: you can redistribute it and/or modify
diff --git a/src/havegecmd.h b/src/havegecmd.h
index 19a1823..7765334 100644
--- a/src/havegecmd.h
+++ b/src/havegecmd.h
@@ -1,7 +1,7 @@
/**
** Provide HAVEGE socket communication API
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2018 Werner Fink <werner@suse.de>
**
** This program is free software: you can redistribute it and/or modify
diff --git a/src/havegecollect.c b/src/havegecollect.c
index 1c82e51..71f353a 100644
--- a/src/havegecollect.c
+++ b/src/havegecollect.c
@@ -1,7 +1,7 @@
/**
** Simple entropy harvester based upon the havege RNG
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2009-2014 Gary Wuertz gary@issiweb.com
** Copyright 2011-2012 BenEleventh Consulting manolson@beneleventh.com
**
diff --git a/src/havegecollect.h b/src/havegecollect.h
index 55ffbfb..933297f 100644
--- a/src/havegecollect.h
+++ b/src/havegecollect.h
@@ -1,7 +1,7 @@
/**
** Simple entropy harvester based upon the havege RNG
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2009-2014 Gary Wuertz gary@issiweb.com
** Copyright 2011-2012 BenEleventh Consulting manolson@beneleventh.com
**
diff --git a/src/haveged.c b/src/haveged.c
index b74c9d0..fcfe764 100644
--- a/src/haveged.c
+++ b/src/haveged.c
@@ -1,7 +1,7 @@
/**
** Simple entropy harvester based upon the havege RNG
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2009-2014 Gary Wuertz gary@issiweb.com
** Copyright 2011-2012 BenEleventh Consulting manolson@beneleventh.com
**
@@ -60,7 +60,7 @@
// {{{ VERSION_TEXT
static const char* VERSION_TEXT =
"haveged %s\n\n"
- "Copyright (C) 2018-2021 Jirka Hladky <hladky.jiri@gmail.com>\n"
+ "Copyright (C) 2018-2022 Jirka Hladky <hladky.jiri@gmail.com>\n"
"Copyright (C) 2009-2014 Gary Wuertz <gary@issiweb.com>\n"
"Copyright (C) 2011-2012 BenEleventh Consulting <manolson@beneleventh.com>\n\n"
"License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.\n"
@@ -655,9 +655,10 @@ static void run_daemon( /* RETURN: nothing */
/* entropy is 8 bits per byte */
output->entropy_count = nbytes * 8;
if (ioctl(random_fd, RNDADDENTROPY, output) == -1)
- printf("Warning: RNDADDENTROPY failed!");
+ error_exit("RNDADDENTROPY failed!");
+ h->n_entropy_bytes += nbytes;
if (params->once == 1)
- return;
+ error_exit("Entropy refilled once (%d bytes), exiting.", nbytes);
t[0] = t[1];
continue;
}
@@ -743,6 +744,7 @@ static void run_daemon( /* RETURN: nothing */
t[0] = t[1];
if (ioctl(random_fd, RNDADDENTROPY, output) == -1)
error_exit("RNDADDENTROPY failed!");
+ h->n_entropy_bytes += nbytes;
}
}
/**
@@ -801,7 +803,7 @@ void error_exit( /* RETURN: nothing */
#endif
{
fprintf(stderr, "%s: %s\n", params->daemon, buffer);
- if (0 !=(params->setup & RUN_AS_APP) && 0 != handle) {
+ if (0 !=(params->setup & (RUN_AS_APP | RUN_IN_FG) ) && 0 != handle) {
if (havege_status_dump(handle, H_SD_TOPIC_TEST, buffer, sizeof(buffer))>0)
fprintf(stderr, "%s\n", buffer);
if (havege_status_dump(handle, H_SD_TOPIC_SUM, buffer, sizeof(buffer))>0)
@@ -824,7 +826,7 @@ static int get_runsize( /* RETURN: the size */
int p2 = 0;
int p10 = APP_BUFF_SIZE * sizeof(H_UINT);
long long ct;
-
+
f = strtod(bp, &suffix);
if (f < 0 || strlen(suffix)>1)
@@ -888,7 +890,7 @@ static char *ppSize( /* RETURN: the formatted size */
char units[] = {'T', 'G', 'M', 'K', 0};
double factor = 1024.0 * 1024.0 * 1024.0 * 1024.0;
int i;
-
+
for (i=0;0 != units[i];i++) {
if (sz >= factor)
break;
diff --git a/src/haveged.h b/src/haveged.h
index e3dff92..d37688b 100644
--- a/src/haveged.h
+++ b/src/haveged.h
@@ -1,7 +1,7 @@
/**
** Simple entropy harvester based upon the havege RNG
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2009-2014 Gary Wuertz gary@issiweb.com
**
** This program is free software: you can redistribute it and/or modify
diff --git a/src/havegetest.c b/src/havegetest.c
index 74c72b0..cee5535 100644
--- a/src/havegetest.c
+++ b/src/havegetest.c
@@ -1,7 +1,7 @@
/**
** Simple entropy harvester based upon the havege RNG
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2012-2014 Gary Wuertz gary@issiweb.com
** Copyright 2012 BenEleventh Consulting manolson@beneleventh.com
**
diff --git a/src/havegetest.h b/src/havegetest.h
index 8e9ac28..22b5142 100644
--- a/src/havegetest.h
+++ b/src/havegetest.h
@@ -1,7 +1,7 @@
/**
** Simple entropy harvester based upon the havege RNG
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2012-2014 Gary Wuertz gary@issiweb.com
** Copyright 2012 BenEleventh Consulting manolson@beneleventh.com
**
diff --git a/src/havegetune.c b/src/havegetune.c
index f558e0d..59e00c5 100644
--- a/src/havegetune.c
+++ b/src/havegetune.c
@@ -1,7 +1,7 @@
/**
** Determine HAVEGE environment
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2009-2014 Gary Wuertz gary@issiweb.com
** Copyright 2011-2012 BenEleventh Consulting manolson@beneleventh.com
**
diff --git a/src/havegetune.h b/src/havegetune.h
index 5283a0b..7db8f30 100644
--- a/src/havegetune.h
+++ b/src/havegetune.h
@@ -1,7 +1,7 @@
/**
** Simple entropy harvester based upon the havege RNG
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2009-2014 Gary Wuertz gary@issiweb.com
**
** This program is free software: you can redistribute it and/or modify
diff --git a/src/oneiteration.h b/src/oneiteration.h
index e6b16d8..37a39e8 100644
--- a/src/oneiteration.h
+++ b/src/oneiteration.h
@@ -1,7 +1,7 @@
/**
** Simple entropy harvester based upon the havege RNG
**
- ** Copyright 2018-2021 Jirka Hladky hladky DOT jiri AT gmail DOT com
+ ** Copyright 2018-2022 Jirka Hladky hladky DOT jiri AT gmail DOT com
** Copyright 2009-2013 Gary Wuertz gary@issiweb.com
**
** This program is free software: you can redistribute it and/or modify