cryptochip: check if the device is configured before continuing
RNG and encryption operations won't work unless the cryptochip is configured for TLS operations. Print a warning if the chip hasn't been configured yet. https://jira.digi.com/browse/DEL-5710 Signed-off-by: Gabriel Valcazar <gabriel.valcazar@digi.com>
This commit is contained in:
parent
9cf9701082
commit
a2a5d119b9
|
|
@ -22,9 +22,19 @@
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
uint8_t random_number[32];
|
uint8_t random_number[32];
|
||||||
|
bool is_locked = false;
|
||||||
|
|
||||||
atcab_init(&cfg_ateccx08a_i2c_default);
|
atcab_init(&cfg_ateccx08a_i2c_default);
|
||||||
|
|
||||||
|
/* Check if config zone is locked */
|
||||||
|
atcab_is_locked(LOCK_ZONE_CONFIG, &is_locked);
|
||||||
|
if (!is_locked) {
|
||||||
|
printf("**WARNING**: the cryptochip is currently not configured. Run "
|
||||||
|
"ecc-test-main at least once to be able to run this example.\n");
|
||||||
|
atcab_release();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
atcab_random(random_number);
|
atcab_random(random_number);
|
||||||
write(STDOUT_FILENO, random_number, sizeof(random_number));
|
write(STDOUT_FILENO, random_number, sizeof(random_number));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue