Skip to content

Commit 0413ca4

Browse files
committed
feat: warning text, v1.0.0
1 parent 93febf3 commit 0413ca4

File tree

5 files changed

+53
-41
lines changed

5 files changed

+53
-41
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
[![Build](https://github.com/xtruan/FlipBIP/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/xtruan/FlipBIP/actions/workflows/build.yml)
44

55
## Crypto toolkit for Flipper Zero
6-
- Built against `0.79.1` Flipper Zero firmware release
76
- Using Trezor crypto libs from `core/v2.5.3` release
87
- Included in [RogueMaster Custom Firmware](https://github.com/RogueMaster/flipperzero-firmware-wPlugins)
98

application.fam

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
App(
22
appid="flipbip",
3-
name="FlipBIP Crypto Tool",
3+
name="FlipBIP Crypto Wallet",
44
apptype=FlipperAppType.EXTERNAL,
55
entry_point="flipbip_app",
66
requires=[
@@ -15,7 +15,7 @@ App(
1515
name="crypto",
1616
),
1717
],
18-
fap_category="Tools",
18+
fap_category="Misc",
1919
fap_description="Crypto toolkit for Flipper",
2020
fap_author="Struan Clark (xtruan)",
2121
fap_weburl="https://github.com/xtruan/FlipBIP",

flipbip.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#include "views/flipbip_startscreen.h"
1616
#include "views/flipbip_scene_1.h"
1717

18-
#define FLIPBIP_VERSION "v0.0.9"
18+
#define FLIPBIP_VERSION "v1.0.0"
1919

2020
#define COIN_BTC 0
2121
#define COIN_DOGE 3

lib/crypto/rand.c

Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -21,43 +21,25 @@
2121
* OTHER DEALINGS IN THE SOFTWARE.
2222
*/
2323

24-
// NOTE:
25-
// random32() and random_buffer() have been replaced in this implementation
26-
// with Flipper Zero specific code. The original code is commented out below.
24+
#define FLIPPER_HAL_RANDOM
2725

2826
#include "rand.h"
2927

30-
// Flipper Zero RNG code:
31-
#include <furi_hal_random.h>
32-
33-
#ifndef RAND_PLATFORM_INDEPENDENT
28+
#ifdef FLIPPER_HAL_RANDOM
3429

35-
// Original code:
36-
// #pragma message("NOT SUITABLE FOR PRODUCTION USE! Replace random32() function with your own secure code.")
30+
// NOTE:
31+
// random32() and random_buffer() have been replaced in this implementation
32+
// with Flipper Zero specific code. The original code is disabled by #define.
3733

38-
// The following code is not supposed to be used in a production environment.
39-
// It's included only to make the library testable.
40-
// The message above tries to prevent any accidental use outside of the test
41-
// environment.
42-
//
43-
// You are supposed to replace the random8() and random32() function with your
44-
// own secure code. There is also a possibility to replace the random_buffer()
45-
// function as it is defined as a weak symbol.
34+
// Flipper Zero RNG code:
35+
#include <furi_hal_random.h>
4636

4737
static uint32_t seed = 0;
4838

4939
void random_reseed(const uint32_t value) {
5040
seed = value;
5141
}
5242

53-
// Original code:
54-
// uint32_t random32(void) {
55-
// // Linear congruential generator from Numerical Recipes
56-
// // https://en.wikipedia.org/wiki/Linear_congruential_generator
57-
// seed = 1664525 * seed + 1013904223;
58-
// return seed;
59-
// }
60-
6143
// Flipper Zero RNG code:
6244
uint32_t random32(void) {
6345
return furi_hal_random_get();
@@ -68,22 +50,41 @@ void random_buffer(uint8_t* buf, size_t len) {
6850
furi_hal_random_fill_buf(buf, len);
6951
}
7052

71-
#endif /* RAND_PLATFORM_INDEPENDENT */
53+
#else /* PLATFORM INDEPENDENT */
54+
55+
#pragma message("NOT SUITABLE FOR PRODUCTION USE! Replace random32() function with your own secure code.")
56+
57+
// The following code is not supposed to be used in a production environment.
58+
// It's included only to make the library testable.
59+
// The message above tries to prevent any accidental use outside of the test
60+
// environment.
61+
//
62+
// You are supposed to replace the random8() and random32() function with your
63+
// own secure code. There is also a possibility to replace the random_buffer()
64+
// function as it is defined as a weak symbol.
7265

7366
//
7467
// The following code is platform independent
7568
//
7669

77-
// Original code:
78-
// void __attribute__((weak)) random_buffer(uint8_t *buf, size_t len) {
79-
// uint32_t r = 0;
80-
// for (size_t i = 0; i < len; i++) {
81-
// if (i % 4 == 0) {
82-
// r = random32();
83-
// }
84-
// buf[i] = (r >> ((i % 4) * 8)) & 0xFF;
85-
// }
86-
// }
70+
uint32_t random32(void) {
71+
// Linear congruential generator from Numerical Recipes
72+
// https://en.wikipedia.org/wiki/Linear_congruential_generator
73+
seed = 1664525 * seed + 1013904223;
74+
return seed;
75+
}
76+
77+
void __attribute__((weak)) random_buffer(uint8_t *buf, size_t len) {
78+
uint32_t r = 0;
79+
for (size_t i = 0; i < len; i++) {
80+
if (i % 4 == 0) {
81+
r = random32();
82+
}
83+
buf[i] = (r >> ((i % 4) * 8)) & 0xFF;
84+
}
85+
}
86+
87+
#endif /* FLIPPER_HAL_RANDOM */
8788

8889
uint32_t random_uniform(uint32_t n) {
8990
uint32_t x = 0, max = 0xFFFFFFFF - (0xFFFFFFFF % n);

views/flipbip_scene_1.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ static CONFIDENTIAL char* s_disp_text5 = NULL;
9999
static CONFIDENTIAL char* s_disp_text6 = NULL;
100100
// Derivation path text
101101
static const char* s_derivation_text = TEXT_DEFAULT_DERIV;
102+
// Warning text
103+
static bool s_warn_insecure = false;
104+
#define WARN_INSECURE_TEXT_1 "Recommendation:"
105+
#define WARN_INSECURE_TEXT_2 "Set BIP39 Passphrase"
102106
//static bool s_busy = false;
103107

104108
void flipbip_scene_1_set_callback(
@@ -307,7 +311,12 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) {
307311
canvas_set_font(canvas, FontPrimary);
308312
canvas_draw_str(canvas, 2, 10, TEXT_LOADING);
309313
canvas_draw_str(canvas, 7, 30, s_derivation_text);
310-
canvas_draw_icon(canvas, 86, 25, &I_Keychain_39x36);
314+
canvas_draw_icon(canvas, 86, 22, &I_Keychain_39x36);
315+
if (s_warn_insecure) {
316+
canvas_set_font(canvas, FontSecondary);
317+
canvas_draw_str(canvas, 2, 50, WARN_INSECURE_TEXT_1);
318+
canvas_draw_str(canvas, 2, 60, WARN_INSECURE_TEXT_2);
319+
}
311320
} else if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) {
312321
// draw address header
313322
canvas_set_font(canvas, FontSecondary);
@@ -629,6 +638,9 @@ void flipbip_scene_1_enter(void* context) {
629638
const char* passphrase_text = "";
630639
if(app->passphrase == FlipBipPassphraseOn && strlen(app->passphrase_text) > 0) {
631640
passphrase_text = app->passphrase_text;
641+
s_warn_insecure = false;
642+
} else {
643+
s_warn_insecure = true;
632644
}
633645

634646
// BIP44 Coin setting

0 commit comments

Comments
 (0)