aboutsummaryrefslogtreecommitdiff
path: root/sw/trng_extractor.c
diff options
context:
space:
mode:
authorPaul Selkirk <paul@psgd.org>2015-05-05 16:15:10 -0400
committerPaul Selkirk <paul@psgd.org>2015-05-05 16:15:10 -0400
commit05b139f4407890a8671bc3f40c48e4d54e3a83c5 (patch)
tree1d1e9ab6ed090baaf0b8bd71c33fd0b67aff0f23 /sw/trng_extractor.c
parent5311cc678dc82222146a384080d5f2bc95cb1eb6 (diff)
Rename bitmask symbols.
Diffstat (limited to 'sw/trng_extractor.c')
-rw-r--r--sw/trng_extractor.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/sw/trng_extractor.c b/sw/trng_extractor.c
index fe37044..e25ebf0 100644
--- a/sw/trng_extractor.c
+++ b/sw/trng_extractor.c
@@ -42,8 +42,6 @@
#include "cryptech.h"
-int verbose;
-
char *usage =
"%s [-a|r|c] [-n #] [-o file]\n\
\n\
@@ -52,7 +50,7 @@ char *usage =
-c csprng (default data source)\n\
-n number of 4-byte samples (scale with K, M, or G suffix)\n\
-o output file (defaults to stdout)\n\
--v verbose operation
+-v verbose operation\n\
";
/* check availability of avalanche entropy core by reading core name and version */
@@ -98,13 +96,14 @@ static int extract(off_t status_addr, off_t data_addr, uint32_t *data)
/* main */
int main(int argc, char *argv[])
{
- int i, opt;
- unsigned long num_words = 1;
+ int opt;
+ unsigned long num_words = 1, i;
char *endptr;
off_t status_addr = CSPRNG_ADDR_STATUS;
off_t data_addr = CSPRNG_ADDR_RANDOM;
FILE *output = stdout;
uint32_t data;
+ int verbose = 0;
/* parse command line */
while ((opt = getopt(argc, argv, "h?varcn:o:")) != -1) {
@@ -125,9 +124,9 @@ int main(int argc, char *argv[])
status_addr = CSPRNG_ADDR_STATUS;
data_addr = CSPRNG_ADDR_RANDOM;
break;
- case 'v':
- verbose = 1;
- break;
+ case 'v':
+ verbose = 1;
+ break;
case 'n':
num_words = strtoul(optarg, &endptr, 10);
switch (toupper(*endptr)) {
@@ -172,15 +171,15 @@ int main(int argc, char *argv[])
goto errout;
}
- // Check that we have can talk to the trng.
+ // Check that we can talk to the trng.
if (verbose)
- printf("Checking that we can access the TRNG...\n");
+ printf("Checking that we can access the TRNG...\n");
if (avalanche_check() || rosc_check() || csprng_check()) {
fprintf(stderr, "Can't properly access the trng.\n");
return EXIT_FAILURE;
}
if (verbose)
- printf("TRNG access ok..\n");
+ printf("TRNG access ok..\n");
/* get the data */
for (i = 0; i < num_words; ++i) {
@@ -191,6 +190,10 @@ int main(int argc, char *argv[])
fclose(output);
return EXIT_FAILURE;
}
+ if (verbose && ((i & 0xffff) == 0)) {
+ fprintf(stderr, ".");
+ fflush(stderr);
+ }
}
fclose(output);