[Cryptech-Commits] [core/platform/novena] 01/01: Adding verbose command line option.
git at cryptech.is
git at cryptech.is
Mon May 4 10:58:06 UTC 2015
This is an automated email from the git hooks/post-receive script.
joachim at secworks.se pushed a commit to branch master
in repository core/platform/novena.
commit 4b5dc6572fd4a10f1faf334b0c72c85dc5dbf30b
Author: Joachim Strömbergson <joachim at secworks.se>
Date: Mon May 4 12:57:56 2015 +0200
Adding verbose command line option.
---
sw/trng_extractor.c | 24 +++++++++++++++++-------
1 file 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)
More information about the Commits
mailing list