Просмотр исходного кода

Merge pull request #15 from xtruan/develop

Minor updates
Struan Clark 2 лет назад
Родитель
Сommit
740a2f8f88
8 измененных файлов с 61 добавлено и 48 удалено
  1. 2 2
      .github/workflows/build.yml
  2. 1 1
      .github/workflows/release.yml
  3. 1 1
      README.md
  4. 4 4
      application.fam
  5. 1 1
      flipbip.h
  6. 37 36
      lib/crypto/rand.c
  7. 14 2
      views/flipbip_scene_1.c
  8. 1 1
      views/flipbip_startscreen.c

+ 2 - 2
.github/workflows/build.yml

@@ -7,7 +7,7 @@ on:
       - develop
 
 env:
-  firmware_version: '0.79.1'
+  firmware_version: '0.86.1'
 
 jobs:
   build:
@@ -27,4 +27,4 @@ jobs:
       - name: Build FAPs
         run: ./fbt COMPACT=1 DEBUG=0 faps
       - name: Check FlipBIP Built
-        run: test -f build/f7-firmware-C/.extapps/FlipBIP.fap
+        run: test -f build/f7-firmware-C/.extapps/flipbip.fap

+ 1 - 1
.github/workflows/release.yml

@@ -6,7 +6,7 @@ on:
       - 'v[0-9]+.[0-9]+.[0-9]+'
 
 env:
-  firmware_version: '0.79.1'
+  firmware_version: '0.86.1'
 
 jobs:
   build:

+ 1 - 1
README.md

@@ -3,7 +3,7 @@
 [![Build](https://github.com/xtruan/FlipBIP/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/xtruan/FlipBIP/actions/workflows/build.yml)
 
 ## Crypto toolkit for Flipper Zero
-- Built against `0.79.1` Flipper Zero firmware release
+- Last built against `0.86.1` Flipper Zero firmware release
 - Using Trezor crypto libs from `core/v2.5.3` release
 - Included in [RogueMaster Custom Firmware](https://github.com/RogueMaster/flipperzero-firmware-wPlugins)
 

+ 4 - 4
application.fam

@@ -1,6 +1,6 @@
 App(
-    appid="FlipBIP",
-    name="FlipBIP Crypto Tool",
+    appid="flipbip",
+    name="FlipBIP Crypto Wallet",
     apptype=FlipperAppType.EXTERNAL,
     entry_point="flipbip_app",
     requires=[
@@ -15,8 +15,8 @@ App(
             name="crypto",
         ),
     ],
-    fap_category="Tools",
+    fap_category="Misc",
     fap_description="Crypto toolkit for Flipper",
     fap_author="Struan Clark (xtruan)",
     fap_weburl="https://github.com/xtruan/FlipBIP",
-)
+)

+ 1 - 1
flipbip.h

@@ -15,7 +15,7 @@
 #include "views/flipbip_startscreen.h"
 #include "views/flipbip_scene_1.h"
 
-#define FLIPBIP_VERSION "v0.0.9"
+#define FLIPBIP_VERSION "v1.0.0"
 
 #define COIN_BTC 0
 #define COIN_DOGE 3

+ 37 - 36
lib/crypto/rand.c

@@ -21,28 +21,18 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 
-// NOTE:
-// random32() and random_buffer() have been replaced in this implementation
-// with Flipper Zero specific code. The original code is commented out below.
+#define FLIPPER_HAL_RANDOM
 
 #include "rand.h"
 
-// Flipper Zero RNG code:
-#include <furi_hal_random.h>
-
-#ifndef RAND_PLATFORM_INDEPENDENT
+#ifdef FLIPPER_HAL_RANDOM
 
-// Original code:
-// #pragma message("NOT SUITABLE FOR PRODUCTION USE! Replace random32() function with your own secure code.")
+// NOTE:
+// random32() and random_buffer() have been replaced in this implementation
+// with Flipper Zero specific code. The original code is disabled by #define.
 
-// The following code is not supposed to be used in a production environment.
-// It's included only to make the library testable.
-// The message above tries to prevent any accidental use outside of the test
-// environment.
-//
-// You are supposed to replace the random8() and random32() function with your
-// own secure code. There is also a possibility to replace the random_buffer()
-// function as it is defined as a weak symbol.
+// Flipper Zero RNG code:
+#include <furi_hal_random.h>
 
 static uint32_t seed = 0;
 
@@ -50,14 +40,6 @@ void random_reseed(const uint32_t value) {
     seed = value;
 }
 
-// Original code:
-// uint32_t random32(void) {
-//   // Linear congruential generator from Numerical Recipes
-//   // https://en.wikipedia.org/wiki/Linear_congruential_generator
-//   seed = 1664525 * seed + 1013904223;
-//   return seed;
-// }
-
 // Flipper Zero RNG code:
 uint32_t random32(void) {
     return furi_hal_random_get();
@@ -68,22 +50,41 @@ void random_buffer(uint8_t* buf, size_t len) {
     furi_hal_random_fill_buf(buf, len);
 }
 
-#endif /* RAND_PLATFORM_INDEPENDENT */
+#else /* PLATFORM INDEPENDENT */
+
+#pragma message("NOT SUITABLE FOR PRODUCTION USE! Replace random32() function with your own secure code.")
+
+// The following code is not supposed to be used in a production environment.
+// It's included only to make the library testable.
+// The message above tries to prevent any accidental use outside of the test
+// environment.
+//
+// You are supposed to replace the random8() and random32() function with your
+// own secure code. There is also a possibility to replace the random_buffer()
+// function as it is defined as a weak symbol.
 
 //
 // The following code is platform independent
 //
 
-// Original code:
-// void __attribute__((weak)) random_buffer(uint8_t *buf, size_t len) {
-//   uint32_t r = 0;
-//   for (size_t i = 0; i < len; i++) {
-//     if (i % 4 == 0) {
-//       r = random32();
-//     }
-//     buf[i] = (r >> ((i % 4) * 8)) & 0xFF;
-//   }
-// }
+uint32_t random32(void) {
+  // Linear congruential generator from Numerical Recipes
+  // https://en.wikipedia.org/wiki/Linear_congruential_generator
+  seed = 1664525 * seed + 1013904223;
+  return seed;
+}
+
+void __attribute__((weak)) random_buffer(uint8_t *buf, size_t len) {
+  uint32_t r = 0;
+  for (size_t i = 0; i < len; i++) {
+    if (i % 4 == 0) {
+      r = random32();
+    }
+    buf[i] = (r >> ((i % 4) * 8)) & 0xFF;
+  }
+}
+
+#endif /* FLIPPER_HAL_RANDOM */
 
 uint32_t random_uniform(uint32_t n) {
     uint32_t x = 0, max = 0xFFFFFFFF - (0xFFFFFFFF % n);

+ 14 - 2
views/flipbip_scene_1.c

@@ -6,7 +6,7 @@
 //#include <dolphin/dolphin.h>
 #include <storage/storage.h>
 #include <string.h>
-#include "FlipBIP_icons.h"
+#include "flipbip_icons.h"
 #include "../helpers/flipbip_haptic.h"
 #include "../helpers/flipbip_led.h"
 #include "../helpers/flipbip_string.h"
@@ -99,6 +99,10 @@ static CONFIDENTIAL char* s_disp_text5 = NULL;
 static CONFIDENTIAL char* s_disp_text6 = NULL;
 // Derivation path text
 static const char* s_derivation_text = TEXT_DEFAULT_DERIV;
+// Warning text
+static bool s_warn_insecure = false;
+#define WARN_INSECURE_TEXT_1 "Recommendation:"
+#define WARN_INSECURE_TEXT_2 "Set BIP39 Passphrase"
 //static bool s_busy = false;
 
 void flipbip_scene_1_set_callback(
@@ -307,7 +311,12 @@ void flipbip_scene_1_draw(Canvas* canvas, FlipBipScene1Model* model) {
         canvas_set_font(canvas, FontPrimary);
         canvas_draw_str(canvas, 2, 10, TEXT_LOADING);
         canvas_draw_str(canvas, 7, 30, s_derivation_text);
-        canvas_draw_icon(canvas, 86, 25, &I_Keychain_39x36);
+        canvas_draw_icon(canvas, 86, 22, &I_Keychain_39x36);
+        if (s_warn_insecure) {
+            canvas_set_font(canvas, FontSecondary);
+            canvas_draw_str(canvas, 2, 50, WARN_INSECURE_TEXT_1);
+            canvas_draw_str(canvas, 2, 60, WARN_INSECURE_TEXT_2);
+        }
     } else if(model->page >= PAGE_ADDR_BEGIN && model->page <= PAGE_ADDR_END) {
         // draw address header
         canvas_set_font(canvas, FontSecondary);
@@ -629,6 +638,9 @@ void flipbip_scene_1_enter(void* context) {
     const char* passphrase_text = "";
     if(app->passphrase == FlipBipPassphraseOn && strlen(app->passphrase_text) > 0) {
         passphrase_text = app->passphrase_text;
+        s_warn_insecure = false;
+    } else {
+        s_warn_insecure = true;
     }
 
     // BIP44 Coin setting

+ 1 - 1
views/flipbip_startscreen.c

@@ -3,7 +3,7 @@
 #include <furi_hal.h>
 #include <input/input.h>
 #include <gui/elements.h>
-#include "FlipBIP_icons.h"
+#include "flipbip_icons.h"
 
 struct FlipBipStartscreen {
     View* view;