mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-08-10 15:40:03 -04:00
Add TRNG to testfw, document
This commit is contained in:
parent
c52f7d52cd
commit
65f2272a45
2 changed files with 20 additions and 5 deletions
|
@ -21,6 +21,8 @@ volatile uint32_t *timer = (volatile uint32_t *)MTA1_MKDF_MMIO_TIMER_T
|
|||
volatile uint32_t *timer_prescaler = (volatile uint32_t *)MTA1_MKDF_MMIO_TIMER_PRESCALER;
|
||||
volatile uint32_t *timer_status = (volatile uint32_t *)MTA1_MKDF_MMIO_TIMER_STATUS;
|
||||
volatile uint32_t *timer_ctrl = (volatile uint32_t *)MTA1_MKDF_MMIO_TIMER_CTRL;
|
||||
volatile uint32_t *trng_status = (volatile uint32_t *)MTA1_MKDF_MMIO_TRNG_STATUS;
|
||||
volatile uint32_t *trng_entropy = (volatile uint32_t *)MTA1_MKDF_MMIO_TRNG_ENTROPY;
|
||||
// clang-format on
|
||||
|
||||
// TODO Real UDA is 4 words (16 bytes)
|
||||
|
@ -232,6 +234,21 @@ int main()
|
|||
test_puts("All tests passed.\r\n");
|
||||
}
|
||||
|
||||
test_puts("\r\nHere are 256 bytes from the TRNG:\r\n");
|
||||
for (int j = 0; j < 8; j++) {
|
||||
for (int i = 0; i < 8; i++) {
|
||||
while ((*trng_status &
|
||||
(1 << MTA1_MKDF_MMIO_TRNG_STATUS_READY_BIT)) ==
|
||||
0) {
|
||||
}
|
||||
uint32_t rnd = *trng_entropy;
|
||||
test_puthexn((uint8_t *)&rnd, 4);
|
||||
test_puts(" ");
|
||||
}
|
||||
test_puts("\r\n");
|
||||
}
|
||||
test_puts("\r\n");
|
||||
|
||||
test_puts("Now echoing what you type...\r\n");
|
||||
for (;;) {
|
||||
in = readbyte(); // blocks
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue