diff options
author | Joachim StroĢmbergson <joachim@secworks.se> | 2015-04-20 17:14:11 +0200 |
---|---|---|
committer | Joachim StroĢmbergson <joachim@secworks.se> | 2015-04-20 17:14:11 +0200 |
commit | d488a7f93ec4952f606ba82a48f446b7d15659b7 (patch) | |
tree | 84d4880dec144146254fe3e4b15a03b2e197fefa /eim/sw | |
parent | 74e8113c1efd6d4940dd7b36ed5a20e053d3848c (diff) |
Adding functions to check core strings as a way to detect that we can talk to the trng before extracting data.
Diffstat (limited to 'eim/sw')
-rw-r--r-- | eim/sw/trng_extractor_eim.c | 54 |
1 files changed, 53 insertions, 1 deletions
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) { |