@@ -37,7 +37,7 @@ static void input_callback(InputEvent* input_event, FuriMessageQueue* event_queu
37
37
furi_message_queue_put (event_queue , & event , FuriWaitForever );
38
38
}
39
39
40
- static void totp_state_init (PluginState * const plugin_state ) {
40
+ static bool totp_state_init (PluginState * const plugin_state ) {
41
41
plugin_state -> gui = furi_record_open (RECORD_GUI );
42
42
plugin_state -> notification = furi_record_open (RECORD_NOTIFICATION );
43
43
plugin_state -> dialogs = furi_record_open (RECORD_DIALOGS );
@@ -61,8 +61,20 @@ static void totp_state_init(PluginState* const plugin_state) {
61
61
totp_scene_director_activate_scene (plugin_state , TotpSceneAuthentication , NULL );
62
62
} else {
63
63
totp_crypto_seed_iv (plugin_state , NULL , 0 );
64
- totp_scene_director_activate_scene (plugin_state , TotpSceneGenerateToken , NULL );
64
+ if (totp_crypto_verify_key (plugin_state )) {
65
+ totp_scene_director_activate_scene (plugin_state , TotpSceneGenerateToken , NULL );
66
+ } else {
67
+ FURI_LOG_E (LOGGING_TAG , "Digital signature verification failed. Looks like conf file was created on another flipper and can't be used on any other" );
68
+ DialogMessage * message = dialog_message_alloc ();
69
+ dialog_message_set_buttons (message , "Exit" , NULL , NULL );
70
+ dialog_message_set_text (message , "Digital signature verification failed" , SCREEN_WIDTH_CENTER , SCREEN_HEIGHT_CENTER , AlignCenter , AlignCenter );
71
+ dialog_message_show (plugin_state -> dialogs , message );
72
+ dialog_message_free (message );
73
+ return false;
74
+ }
65
75
}
76
+
77
+ return true;
66
78
}
67
79
68
80
static void dispose_plugin_state (PluginState * plugin_state ) {
@@ -94,7 +106,11 @@ int32_t totp_app() {
94
106
FuriMessageQueue * event_queue = furi_message_queue_alloc (8 , sizeof (PluginEvent ));
95
107
PluginState * plugin_state = malloc (sizeof (PluginState ));
96
108
97
- totp_state_init (plugin_state );
109
+ if (!totp_state_init (plugin_state )) {
110
+ FURI_LOG_E (LOGGING_TAG , "App state initialization failed\r\n" );
111
+ dispose_plugin_state (plugin_state );
112
+ return 254 ;
113
+ }
98
114
99
115
ValueMutex state_mutex ;
100
116
if (!init_mutex (& state_mutex , plugin_state , sizeof (PluginState ))) {
@@ -126,7 +142,7 @@ int32_t totp_app() {
126
142
}
127
143
128
144
processing = totp_scene_director_handle_event (& event , plugin_state );
129
- } else if (plugin_state -> current_scene != TotpSceneAuthentication && furi_get_tick () - last_user_interaction_time > IDLE_TIMEOUT ) {
145
+ } else if (plugin_state -> pin_set && plugin_state -> current_scene != TotpSceneAuthentication && furi_get_tick () - last_user_interaction_time > IDLE_TIMEOUT ) {
130
146
totp_scene_director_activate_scene (plugin_state , TotpSceneAuthentication , NULL );
131
147
}
132
148
0 commit comments