aboutsummaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2015-05-04 12:57:56 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2015-05-04 12:57:56 +0200
commit4b5dc6572fd4a10f1faf334b0c72c85dc5dbf30b (patch)
treec91e17773a37040292872f6465ac4f6f274ad47a /sw
parent7c4de55cddd48ac4420cfba1387bef9a653712dc (diff)
Adding verbose command line option.
Diffstat (limited to 'sw')
-rw-r--r--sw/trng_extractor.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/sw/trng_extractor.c b/sw/trng_extractor.c
index 5c373f4..fe37044 100644
--- a/sw/trng_extractor.c
+++ b/sw/trng_extractor.c
@@ -42,6 +42,8 @@
#include "cryptech.h"
+int verbose;
+
char *usage =
"%s [-a|r|c] [-n #] [-o file]\n\
\n\
@@ -50,6 +52,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
";
/* check availability of avalanche entropy core by reading core name and version */
@@ -103,14 +106,8 @@ int main(int argc, char *argv[])
FILE *output = stdout;
uint32_t data;
- // Check that we have can talk to the trng.
- if (avalanche_check() || rosc_check() || csprng_check()) {
- fprintf(stderr, "Can't properly access the trng.\n");
- return EXIT_FAILURE;
- }
-
/* parse command line */
- while ((opt = getopt(argc, argv, "h?arcn:o:")) != -1) {
+ while ((opt = getopt(argc, argv, "h?varcn:o:")) != -1) {
switch (opt) {
case 'h':
case '?':
@@ -128,6 +125,9 @@ int main(int argc, char *argv[])
status_addr = CSPRNG_ADDR_STATUS;
data_addr = CSPRNG_ADDR_RANDOM;
break;
+ case 'v':
+ verbose = 1;
+ break;
case 'n':
num_words = strtoul(optarg, &endptr, 10);
switch (toupper(*endptr)) {
@@ -172,6 +172,16 @@ int main(int argc, char *argv[])
goto errout;
}
+ // Check that we have can talk to the trng.
+ if (verbose)
+ 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");
+
/* get the data */
for (i = 0; i < num_words; ++i) {
if (extract(status_addr, data_addr, &data) != 0)