Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/tls-earlyentropy]: src/sbin/rndctl Update rndctl(8) to add the -v option...
details: https://anonhg.NetBSD.org/src/rev/f68c97e08906
branches: tls-earlyentropy
changeset: 795266:f68c97e08906
user: tls <tls%NetBSD.org@localhost>
date: Mon Apr 07 02:49:52 2014 +0000
description:
Update rndctl(8) to add the -v option, which gives us more robust information
on entropy collection and estimation.
diffstat:
sbin/rndctl/rndctl.8 | 5 ++-
sbin/rndctl/rndctl.c | 94 +++++++++++++++++++++++++++++++++++++--------------
2 files changed, 72 insertions(+), 27 deletions(-)
diffs (200 lines):
diff -r 5c7add994f9e -r f68c97e08906 sbin/rndctl/rndctl.8
--- a/sbin/rndctl/rndctl.8 Mon Apr 07 02:24:31 2014 +0000
+++ b/sbin/rndctl/rndctl.8 Mon Apr 07 02:49:52 2014 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: rndctl.8,v 1.20 2011/11/23 12:15:30 wiz Exp $
+.\" $NetBSD: rndctl.8,v 1.20.16.1 2014/04/07 02:49:52 tls Exp $
.\"
.\" Copyright (c) 1997 Michael Graff
.\" All rights reserved.
@@ -39,6 +39,7 @@
.Nm
.Fl ls
.Op Fl d Ar devname | Fl t Ar devtype
+.Op Fl v
.Nm
.Fl L Ar save-file
.Nm
@@ -119,6 +120,8 @@
.It Ic rng
Random number generators.
.El
+.It Fl v
+Verbose output: show entropy estimation statistics for each source.
.El
.Sh FILES
.Bl -tag -width /dev/urandomx -compact
diff -r 5c7add994f9e -r f68c97e08906 sbin/rndctl/rndctl.c
--- a/sbin/rndctl/rndctl.c Mon Apr 07 02:24:31 2014 +0000
+++ b/sbin/rndctl/rndctl.c Mon Apr 07 02:49:52 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rndctl.c,v 1.27 2014/01/15 15:05:27 apb Exp $ */
+/* $NetBSD: rndctl.c,v 1.27.2.1 2014/04/07 02:49:52 tls Exp $ */
/*-
* Copyright (c) 1997 Michael Graff.
@@ -33,7 +33,7 @@
#include <sha1.h>
#ifndef lint
-__RCSID("$NetBSD: rndctl.c,v 1.27 2014/01/15 15:05:27 apb Exp $");
+__RCSID("$NetBSD: rndctl.c,v 1.27.2.1 2014/04/07 02:49:52 tls Exp $");
#endif
@@ -78,6 +78,8 @@
static void do_list(int, u_int32_t, char *);
static void do_stats(void);
+static int vflag;
+
static void
usage(void)
{
@@ -254,19 +256,28 @@
{
static char str[512];
- str[0] = 0;
+ str[0] = '\0';
if (fl & RND_FLAG_NO_ESTIMATE)
;
else
- strlcat(str, "estimate", sizeof(str));
+ strlcat(str, "estimate, ", sizeof(str));
if (fl & RND_FLAG_NO_COLLECT)
;
- else {
- if (str[0])
- strlcat(str, ", ", sizeof(str));
- strlcat(str, "collect", sizeof(str));
- }
+ else
+ strlcat(str, "collect, ", sizeof(str));
+
+ if (fl & RND_FLAG_COLLECT_VALUE)
+ strlcat(str, "v, ", sizeof(str));
+ if (fl & RND_FLAG_COLLECT_TIME)
+ strlcat(str, "t, ", sizeof(str));
+ if (fl & RND_FLAG_ESTIMATE_VALUE)
+ strlcat(str, "dv, ", sizeof(str));
+ if (fl & RND_FLAG_ESTIMATE_TIME)
+ strlcat(str, "dt, ", sizeof(str));
+
+ if (str[strlen(str) - 2] == ',')
+ str[strlen(str) - 2] = '\0';
return (str);
}
@@ -276,8 +287,8 @@
static void
do_list(int all, u_int32_t type, char *name)
{
- rndstat_t rstat;
- rndstat_name_t rstat_name;
+ rndstat_est_t rstat;
+ rndstat_est_name_t rstat_name;
int fd;
int res;
uint32_t i;
@@ -289,15 +300,29 @@
if (all == 0 && type == 0xff) {
strncpy(rstat_name.name, name, sizeof(rstat_name.name));
- res = ioctl(fd, RNDGETSRCNAME, &rstat_name);
+ res = ioctl(fd, RNDGETESTNAME, &rstat_name);
if (res < 0)
- err(1, "ioctl(RNDGETSRCNAME)");
+ err(1, "ioctl(RNDGETESTNAME)");
printf(HEADER);
printf("%-16s %10u %-4s %s\n",
- rstat_name.source.name,
- rstat_name.source.total,
- find_name(rstat_name.source.type),
- strflags(rstat_name.source.flags));
+ rstat_name.source.rt.name,
+ rstat_name.source.rt.total,
+ find_name(rstat_name.source.rt.type),
+ strflags(rstat_name.source.rt.flags));
+ if (vflag) {
+ printf("\tDt samples = %d\n",
+ rstat_name.source.dt_samples);
+ printf("\tDt bits = %d\n",
+ rstat_name.source.dt_total);
+ printf("\tDv samples = %d\n",
+ rstat_name.source.dv_samples);
+ printf("\tDv bits = %d\n",
+ rstat_name.source.dv_total);
+ printf("\tLZ bytes in = %d\n",
+ rstat_name.source.lzv_bytes);
+ printf("\tLZ bits out = %d\n",
+ rstat_name.source.lzv_total);
+ }
close(fd);
return;
}
@@ -311,22 +336,36 @@
for (;;) {
rstat.count = RND_MAXSTATCOUNT;
rstat.start = start;
- res = ioctl(fd, RNDGETSRCNUM, &rstat);
+ res = ioctl(fd, RNDGETESTNUM, &rstat);
if (res < 0)
- err(1, "ioctl(RNDGETSRCNUM)");
+ err(1, "ioctl(RNDGETESTNUM)");
if (rstat.count == 0)
break;
for (i = 0; i < rstat.count; i++) {
if (all != 0 ||
- type == rstat.source[i].type)
+ type == rstat.source[i].rt.type)
printf("%-16s %10u %-4s %s\n",
- rstat.source[i].name,
- rstat.source[i].total,
- find_name(rstat.source[i].type),
- strflags(rstat.source[i].flags));
- }
+ rstat.source[i].rt.name,
+ rstat.source[i].rt.total,
+ find_name(rstat.source[i].rt.type),
+ strflags(rstat.source[i].rt.flags));
+ if (vflag) {
+ printf("\tDt samples = %d\n",
+ rstat.source[i].dt_samples);
+ printf("\tDt bits = %d\n",
+ rstat.source[i].dt_total);
+ printf("\tDv samples = %d\n",
+ rstat.source[i].dv_samples);
+ printf("\tDv bits = %d\n",
+ rstat.source[i].dv_total);
+ printf("\tLZ bytes in = %d\n",
+ rstat.source[i].lzv_bytes);
+ printf("\tLZ bits out = %d\n",
+ rstat.source[i].lzv_total);
+ }
+ }
start += rstat.count;
}
@@ -375,7 +414,7 @@
sflag = 0;
type = 0xff;
- while ((ch = getopt(argc, argv, "CES:L:celt:d:s")) != -1) {
+ while ((ch = getopt(argc, argv, "CES:L:celt:d:sv")) != -1) {
switch (ch) {
case 'C':
rctl.flags |= RND_FLAG_NO_COLLECT;
@@ -430,6 +469,9 @@
case 's':
sflag++;
break;
+ case 'v':
+ vflag++;
+ break;
case '?':
default:
usage();
Home |
Main Index |
Thread Index |
Old Index