From 6760c5a6c92b6516de68387272239dcfcbc5131d Mon Sep 17 00:00:00 2001 From: Flexperte Date: Tue, 17 Sep 2019 03:35:48 +0200 Subject: [PATCH] Ask for confirmation before getting a nonce in normal mode to avoid overwriting the generator. Probably a good idea to also add a switch "-f" to force that behavior. --- igetnonce/main.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/igetnonce/main.c b/igetnonce/main.c index e36ff27..f397272 100644 --- a/igetnonce/main.c +++ b/igetnonce/main.c @@ -105,6 +105,14 @@ int main(int argc, const char * argv[]) { } info("ecid=%llx\n",client->ecid); + if (client->mode->index == MODE_NORMAL) { + error("WARNING: Getting a nonce in normal mode will overwrite the generator in NVRAM!\n"); + info("Continue anyway? [y/n] : "); + char cont[2] = "n"; + scanf("%c", cont); + if (strncmp(cont, "y", 1) != 0) return -1; + } + unsigned char* nonce = NULL; int nonce_size = 0;