From 4cbf29505d25f6fcabeaac2db645169e214b2831 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Tue, 31 Mar 2015 16:31:29 +0200 Subject: [PATCH] don't clear PIN on Initialize --- firmware/fsm.c | 4 ++-- firmware/storage.c | 8 +++++--- firmware/storage.h | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/firmware/fsm.c b/firmware/fsm.c index fea3eef66a..b4025c5ee6 100644 --- a/firmware/fsm.c +++ b/firmware/fsm.c @@ -113,7 +113,7 @@ void fsm_msgInitialize(Initialize *msg) (void)msg; recovery_abort(); signing_abort(); - session_clear(); + session_clear(false); // do not clear PIN fsm_msgGetFeatures(0); } @@ -447,7 +447,7 @@ void fsm_msgCipherKeyValue(CipherKeyValue *msg) void fsm_msgClearSession(ClearSession *msg) { (void)msg; - session_clear(); + session_clear(true); // clear PIN as well fsm_sendSuccess("Session cleared"); } diff --git a/firmware/storage.c b/firmware/storage.c index 6eed1865c1..5718247c2a 100644 --- a/firmware/storage.c +++ b/firmware/storage.c @@ -117,14 +117,16 @@ void storage_reset(void) // reset storage struct memset(&storage, 0, sizeof(storage)); storage.version = STORAGE_VERSION; - session_clear(); + session_clear(true); // clear PIN as well } -void session_clear(void) +void session_clear(bool clear_pin) { sessionRootNodeCached = false; memset(&sessionRootNode, 0, sizeof(sessionRootNode)); sessionPassphraseCached = false; memset(&sessionPassphrase, 0, sizeof(sessionPassphrase)); - sessionPinCached = false; + if (clear_pin) { + sessionPinCached = false; + } } static uint8_t meta_backup[FLASH_META_LEN]; diff --git a/firmware/storage.h b/firmware/storage.h index 2b7b9b4e75..b1041a8b93 100644 --- a/firmware/storage.h +++ b/firmware/storage.h @@ -29,7 +29,7 @@ void storage_init(void); void storage_reset_uuid(void); void storage_reset(void); void storage_commit(void); -void session_clear(void); +void session_clear(bool clear_pin); void storage_loadDevice(LoadDevice *msg);