Browse Source

Fixed #155 (#156)

* Fixed #155
Alexander Kopachov 2 years ago
parent
commit
74ba300c4b
2 changed files with 9 additions and 6 deletions
  1. 3 3
      fbt.ps1
  2. 6 3
      totp/services/crypto/crypto.c

+ 3 - 3
fbt.ps1

@@ -3,7 +3,7 @@ Push-Location $PSScriptRoot
 $firmware_path = ""
 $firmware_path = ""
 $firmware_name = ""
 $firmware_name = ""
 $FW_CDEF = ""
 $FW_CDEF = ""
-if (('official-dev', 'off-dev', 'od', 'unleashed', 'un', 'u').Contains($args[0])) {
+if (('official-dev', 'off-dev', 'od').Contains($args[0])) {
     $firmware_path = "flipperzero-firmware_official_dev"
     $firmware_path = "flipperzero-firmware_official_dev"
     $firmware_name = "Official Dev"
     $firmware_name = "Official Dev"
     $FW_CDEF = "TOTP_FIRMWARE_OFFICIAL_DEV"
     $FW_CDEF = "TOTP_FIRMWARE_OFFICIAL_DEV"
@@ -12,9 +12,9 @@ elseif (('official-stable', 'off-stbl', 'os').Contains($args[0])) {
     $firmware_path = "flipperzero-firmware_official_stable"
     $firmware_path = "flipperzero-firmware_official_stable"
     $firmware_name = "Official Stable"
     $firmware_name = "Official Stable"
     $FW_CDEF = "TOTP_FIRMWARE_OFFICIAL_STABLE"
     $FW_CDEF = "TOTP_FIRMWARE_OFFICIAL_STABLE"
-} elseif (('xtreme', 'xt', 'x').Contains($args[0])) {
+} elseif (('xtreme', 'xt', 'x', 'unleashed', 'un', 'u').Contains($args[0])) {
     $firmware_path = "flipperzero-firmware_xtreme"
     $firmware_path = "flipperzero-firmware_xtreme"
-    $firmware_name = "Xtreme"
+    $firmware_name = "Xtreme \ Unleashed"
     $FW_CDEF = "TOTP_FIRMWARE_XTREME_UL"
     $FW_CDEF = "TOTP_FIRMWARE_XTREME_UL"
 }
 }
 else {
 else {

+ 6 - 3
totp/services/crypto/crypto.c

@@ -6,10 +6,11 @@
 #include "memset_s.h"
 #include "memset_s.h"
 
 
 #define CRYPTO_KEY_SLOT (2)
 #define CRYPTO_KEY_SLOT (2)
-#define CRYPTO_VERIFY_KEY "FFF_Crypto_pass"
 #define CRYPTO_VERIFY_KEY_LENGTH (16)
 #define CRYPTO_VERIFY_KEY_LENGTH (16)
 #define CRYPTO_ALIGNMENT_FACTOR (16)
 #define CRYPTO_ALIGNMENT_FACTOR (16)
 
 
+static const char* CRYPTO_VERIFY_KEY = "FFF_Crypto_pass";
+
 uint8_t* totp_crypto_encrypt(
 uint8_t* totp_crypto_encrypt(
     const uint8_t* plain_data,
     const uint8_t* plain_data,
     const size_t plain_data_length,
     const size_t plain_data_length,
@@ -104,7 +105,7 @@ CryptoSeedIVResult
         plugin_state->crypto_verify_data_length = CRYPTO_VERIFY_KEY_LENGTH;
         plugin_state->crypto_verify_data_length = CRYPTO_VERIFY_KEY_LENGTH;
 
 
         plugin_state->crypto_verify_data = totp_crypto_encrypt(
         plugin_state->crypto_verify_data = totp_crypto_encrypt(
-            (uint8_t*)CRYPTO_VERIFY_KEY,
+            (const uint8_t*)CRYPTO_VERIFY_KEY,
             CRYPTO_VERIFY_KEY_LENGTH,
             CRYPTO_VERIFY_KEY_LENGTH,
             &plugin_state->iv[0],
             &plugin_state->iv[0],
             &plugin_state->crypto_verify_data_length);
             &plugin_state->crypto_verify_data_length);
@@ -119,7 +120,7 @@ CryptoSeedIVResult
 
 
 bool totp_crypto_verify_key(const PluginState* plugin_state) {
 bool totp_crypto_verify_key(const PluginState* plugin_state) {
     size_t decrypted_key_length;
     size_t decrypted_key_length;
-    const uint8_t* decrypted_key = totp_crypto_decrypt(
+    uint8_t* decrypted_key = totp_crypto_decrypt(
         plugin_state->crypto_verify_data,
         plugin_state->crypto_verify_data,
         plugin_state->crypto_verify_data_length,
         plugin_state->crypto_verify_data_length,
         &plugin_state->iv[0],
         &plugin_state->iv[0],
@@ -130,5 +131,7 @@ bool totp_crypto_verify_key(const PluginState* plugin_state) {
         if(decrypted_key[i] != CRYPTO_VERIFY_KEY[i]) key_valid = false;
         if(decrypted_key[i] != CRYPTO_VERIFY_KEY[i]) key_valid = false;
     }
     }
 
 
+    free(decrypted_key);
+
     return key_valid;
     return key_valid;
 }
 }