4
4
#include <input/input.h>
5
5
#include <gui/elements.h>
6
6
#include <dolphin/dolphin.h>
7
+ #include "../helpers/flipbip39_haptic.h"
8
+ #include "../helpers/flipbip39_speaker.h"
9
+ #include "../helpers/flipbip39_led.h"
7
10
8
11
#include <string.h>
9
- #include "../crypto/bip32.h"
12
+ // #include "../crypto/bip32.h"
10
13
#include "../crypto/bip39.h"
11
- #include "../crypto/ecdsa.h"
12
- #include "../crypto/curves.h"
14
+ // #include "../crypto/ecdsa.h"
15
+ // #include "../crypto/curves.h"
16
+ #include "../crypto/memzero.h"
13
17
14
18
struct FlipBip39Scene1 {
15
19
View * view ;
@@ -19,6 +23,7 @@ struct FlipBip39Scene1 {
19
23
20
24
21
25
typedef struct {
26
+ int strength ;
22
27
const char * mnemonic1 ;
23
28
const char * mnemonic2 ;
24
29
const char * mnemonic3 ;
@@ -45,6 +50,7 @@ void flipbip39_scene_1_draw(Canvas* canvas, FlipBip39Scene1Model* model) {
45
50
//canvas_draw_str_aligned(canvas, 0, 10, AlignLeft, AlignTop, "This is Scene 1");
46
51
47
52
canvas_set_font (canvas , FontSecondary );
53
+ //canvas_draw_str_aligned(canvas, 1, 2, AlignLeft, AlignTop, model->strength == 128 ? "128-bit" : "256-bit");
48
54
canvas_draw_str_aligned (canvas , 1 , 2 , AlignLeft , AlignTop , model -> mnemonic1 );
49
55
canvas_draw_str_aligned (canvas , 1 , 12 , AlignLeft , AlignTop , model -> mnemonic2 );
50
56
canvas_draw_str_aligned (canvas , 1 , 22 , AlignLeft , AlignTop , model -> mnemonic3 );
@@ -56,6 +62,7 @@ void flipbip39_scene_1_draw(Canvas* canvas, FlipBip39Scene1Model* model) {
56
62
57
63
static void flipbip39_scene_1_model_init (FlipBip39Scene1Model * const model , const int strength ) {
58
64
// Generate a random mnemonic using trezor-crypto
65
+ model -> strength = strength ;
59
66
const char * mnemonic = mnemonic_generate (strength );
60
67
61
68
// Delineate 6 sections of the mnemonic
@@ -128,14 +135,36 @@ bool flipbip39_scene_1_input(InputEvent* event, void* context) {
128
135
129
136
void flipbip39_scene_1_exit (void * context ) {
130
137
furi_assert (context );
138
+ FlipBip39Scene1 * instance = (FlipBip39Scene1 * )context ;
139
+
140
+ with_view_model (
141
+ instance -> view ,
142
+ FlipBip39Scene1Model * model ,
143
+ {
144
+ // Clear the mnemonic from memory
145
+ model -> strength = 0 ;
146
+ memzero ((void * )model -> mnemonic1 , strlen (model -> mnemonic1 ));
147
+ memzero ((void * )model -> mnemonic2 , strlen (model -> mnemonic2 ));
148
+ memzero ((void * )model -> mnemonic3 , strlen (model -> mnemonic3 ));
149
+ memzero ((void * )model -> mnemonic4 , strlen (model -> mnemonic4 ));
150
+ memzero ((void * )model -> mnemonic5 , strlen (model -> mnemonic5 ));
151
+ memzero ((void * )model -> mnemonic6 , strlen (model -> mnemonic6 ));
152
+ },
153
+ true
154
+ );
131
155
}
132
156
133
157
void flipbip39_scene_1_enter (void * context ) {
134
158
furi_assert (context );
135
159
FlipBip39Scene1 * instance = (FlipBip39Scene1 * )context ;
136
160
137
161
FlipBip39 * app = instance -> context ;
138
- int strength = app -> bip39_strength ;
162
+ int strength_setting = app -> bip39_strength ;
163
+ int strength = 256 ;
164
+ if (strength_setting == 0 ) strength = 128 ;
165
+
166
+ flipbip39_play_happy_bump (app );
167
+ flipbip39_led_set_rgb (app , 255 , 0 , 0 );
139
168
140
169
with_view_model (
141
170
instance -> view ,
@@ -157,8 +186,10 @@ FlipBip39Scene1* flipbip39_scene_1_alloc() {
157
186
view_set_enter_callback (instance -> view , flipbip39_scene_1_enter );
158
187
view_set_exit_callback (instance -> view , flipbip39_scene_1_exit );
159
188
160
- // FlipBip39* app = instance->view->context;
161
- // int strength = app->bip39_strength;
189
+ // FlipBip39* app = instance->context;
190
+ // int strength_setting = app->bip39_strength;
191
+ // int strength = 256;
192
+ // if (strength_setting == 0) strength = 128;
162
193
163
194
// with_view_model(
164
195
// instance->view,
0 commit comments