aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoachim StroĢˆmbergson <joachim@secworks.se>2015-04-02 12:46:17 +0200
committerJoachim StroĢˆmbergson <joachim@secworks.se>2015-04-02 12:46:17 +0200
commitaea9e93e560b1468bf0ff2cf5b61e5409ce60dc5 (patch)
tree0535f05acb6e7c99919b2ae7a9d5bc9a6284b447
parent38d62bec91558562f738dd4730d7a9dbb3fabf7d (diff)
Added support in tc7 for dumping raw data to std out.
-rw-r--r--eim/sw/trng_tester_eim.c33
1 files changed, 26 insertions, 7 deletions
diff --git a/eim/sw/trng_tester_eim.c b/eim/sw/trng_tester_eim.c
index f60aeec..0cb9312 100644
--- a/eim/sw/trng_tester_eim.c
+++ b/eim/sw/trng_tester_eim.c
@@ -55,6 +55,7 @@
int debug = 0;
int quiet = 0;
int repeat = 0;
+int dump_data = 1;
int num_words = 10;
/* ---------------- sanity test case ---------------- */
@@ -230,32 +231,50 @@ int TC6(void)
/* TC7: Read random data from trng_csprng. */
int TC7(void)
{
- int i, n;
- unsigned long random;
+ int i;
+#ifdef WAIT_STATS
+ int n;
+#endif
+ uint32_t random;
if (!quiet)
printf("TC7: Read random data from trng_csprng.\n");
for (i = 0; i < num_words; ++i) {
/* check status */
- n = 0;
- if (tc_wait(CSPRNG_ADDR_STATUS, CSPRNG_STATUS_VALID, &n) != 0)
+#ifdef WAIT_STATS
+ if ((n = tc_wait(CSPRNG_ADDR_STATUS, CSPRNG_STATUS_VALID)) < 0)
+#else
+ if (tc_wait(CSPRNG_ADDR_STATUS, CSPRNG_STATUS_VALID) != 0)
+#endif
return 1;
/* read random data */
if (tc_read(CSPRNG_ADDR_RANDOM, (uint8_t *)&random, 4) != 0)
return 1;
/* display random data */
- if (!debug)
+ if (!debug) {
+ if (dump_data) {
+ // Raw data output to std out.
+ printf("%c%c%c%c", (int8_t)(random >> 24 & 0xff),
+ (int8_t)(random >> 16 & 0xff),
+ (int8_t)(random >> 8 & 0xff),
+ (int8_t)(random & 0xff));
+ }
+ else
+ {
#ifdef WAIT_STATS
- printf("%08lx %d\n", random, n);
+ printf("0x%08x %d\n", random, n);
#else
- printf("%08lx\n", random);
+ printf("0x%08x\n", random);
#endif
+ }
+ }
}
return 0;
}
+
/* ---------------- main ---------------- */
/* signal handler for ctrl-c to end repeat testing */