From d488a7f93ec4952f606ba82a48f446b7d15659b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Stro=CC=88mbergson?= Date: Mon, 20 Apr 2015 17:14:11 +0200 Subject: Adding functions to check core strings as a way to detect that we can talk to the trng before extracting data. --- eim/sw/trng_extractor_eim.c | 54 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) (limited to 'eim') diff --git a/eim/sw/trng_extractor_eim.c b/eim/sw/trng_extractor_eim.c index be6ab16..36e653e 100644 --- a/eim/sw/trng_extractor_eim.c +++ b/eim/sw/trng_extractor_eim.c @@ -43,7 +43,7 @@ #include "tc_eim.h" #include "cryptech_memory_map.h" -char *usage = +char *usage = "%s [-a|r|c] [-n #] [-o file]\n\ \n\ -a avalanche entropy\n\ @@ -55,6 +55,58 @@ char *usage = int debug = 0; /* for dump() */ + +// Check availability of avalanche entropy core by reading core name and version. +uint32_t avalanche_check(void) +{ + uint8_t name0[4] = "extn"; + uint8_t name1[4] = "oise"; + uint8_t version[4] = "0.10"; + + printf("Reading name and version words from avalanche_entropy core.\n"); + + return + tc_expected(ENTROPY1_ADDR_NAME0, name0, 4) || + tc_expected(ENTROPY1_ADDR_NAME1, name1, 4) || + tc_expected(ENTROPY1_ADDR_VERSION, version, 4); +} + + +// check availability of rosc core by reading the core name and version. +uint32_t rosc_check(void) +{ + uint8_t name0[4] = "rosc"; + uint8_t name1[4] = " ent"; + uint8_t version[4] = "0.10"; + + printf("Reading name and version words from rosc_entropy core.\n"); + + return + tc_expected(ENTROPY2_ADDR_NAME0, name0, 4) || + tc_expected(ENTROPY2_ADDR_NAME1, name1, 4) || + tc_expected(ENTROPY2_ADDR_VERSION, version, 4); +} + + +// Check availability of trng by reading core name and version. +uint32_t trng_check(void) +{ +// uint8_t name0[4] = "extn"; +// uint8_t name1[4] = "oise"; +// uint8_t version[4] = "0.10"; +// +// if (!quiet) +// printf("TC2: Reading name and version words from avalanche_entropy core.\n"); +// +// return +// tc_expected(ENTROPY1_ADDR_NAME0, name0, 4) || +// tc_expected(ENTROPY1_ADDR_NAME1, name1, 4) || +// tc_expected(ENTROPY1_ADDR_VERSION, version, 4); + + return (uint32_t) 0; +} + + /* extract one data sample */ static int extract(off_t status_addr, off_t data_addr, uint32_t *data) { -- cgit v1.2.3