Przeglądaj źródła

rework esubghz chat to use mbedtls

MX 2 lat temu
rodzic
commit
9641988c03
4 zmienionych plików z 248 dodań i 255 usunięć
  1. 1 0
      application.fam
  2. 168 160
      crypto_wrapper.c
  3. 1 1
      esubghz_chat_i.h
  4. 78 94
      scenes/esubghz_chat_pass_input.c

+ 1 - 0
application.fam

@@ -9,6 +9,7 @@ App(
     ],
     ],
     stack_size=8 * 1024,
     stack_size=8 * 1024,
     fap_category="Sub-GHz",
     fap_category="Sub-GHz",
+    fap_libs=["mbedtls"],
     fap_icon="assets/chat_10px.png",
     fap_icon="assets/chat_10px.png",
     fap_icon_assets="assets",
     fap_icon_assets="assets",
     fap_icon_assets_symbol="esubghz_chat",
     fap_icon_assets_symbol="esubghz_chat",

+ 168 - 160
crypto_wrapper.c

@@ -1,6 +1,6 @@
 #include <furi_hal.h>
 #include <furi_hal.h>
 #include <lib/mlib/m-dict.h>
 #include <lib/mlib/m-dict.h>
-#include <toolbox/sha256.h>
+#include <mbedtls/sha256.h>
 
 
 #ifndef FURI_HAL_CRYPTO_ADVANCED_AVAIL
 #ifndef FURI_HAL_CRYPTO_ADVANCED_AVAIL
 #include "crypto/gcm.h"
 #include "crypto/gcm.h"
@@ -11,219 +11,227 @@
 DICT_DEF2(ESubGhzChatReplayDict, uint64_t, uint32_t)
 DICT_DEF2(ESubGhzChatReplayDict, uint64_t, uint32_t)
 
 
 struct ESugGhzChatCryptoCtx {
 struct ESugGhzChatCryptoCtx {
-	uint8_t key[KEY_BITS / 8];
+    uint8_t key[KEY_BITS / 8];
 #ifndef FURI_HAL_CRYPTO_ADVANCED_AVAIL
 #ifndef FURI_HAL_CRYPTO_ADVANCED_AVAIL
-	gcm_context gcm_ctx;
+    gcm_context gcm_ctx;
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
-	ESubGhzChatReplayDict_t replay_dict;
-	uint64_t run_id;
-	uint32_t counter;
+    ESubGhzChatReplayDict_t replay_dict;
+    uint64_t run_id;
+    uint32_t counter;
 };
 };
 
 
 struct ESubGhzChatCryptoMsg {
 struct ESubGhzChatCryptoMsg {
-	uint64_t run_id;
-	uint32_t counter;
-	uint8_t iv[IV_BYTES];
-	uint8_t tag[TAG_BYTES];
-	uint8_t data[0];
-} __attribute__ ((packed));
-
-void crypto_init(void)
-{
+    uint64_t run_id;
+    uint32_t counter;
+    uint8_t iv[IV_BYTES];
+    uint8_t tag[TAG_BYTES];
+    uint8_t data[0];
+} __attribute__((packed));
+
+void crypto_init(void) {
 #ifndef FURI_HAL_CRYPTO_ADVANCED_AVAIL
 #ifndef FURI_HAL_CRYPTO_ADVANCED_AVAIL
-	/* init the GCM and AES tables */
-	gcm_initialize();
+    /* init the GCM and AES tables */
+    gcm_initialize();
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 }
 }
 
 
-void crypto_explicit_bzero(void *s, size_t len)
-{
-	memset(s, 0, len);
-	asm volatile("" ::: "memory");
+void crypto_explicit_bzero(void* s, size_t len) {
+    memset(s, 0, len);
+    asm volatile("" ::: "memory");
 }
 }
 
 
-ESubGhzChatCryptoCtx *crypto_ctx_alloc(void)
-{
-	ESubGhzChatCryptoCtx *ret = malloc(sizeof(ESubGhzChatCryptoCtx));
+ESubGhzChatCryptoCtx* crypto_ctx_alloc(void) {
+    ESubGhzChatCryptoCtx* ret = malloc(sizeof(ESubGhzChatCryptoCtx));
 
 
-	if (ret != NULL) {
-		memset(ret, 0, sizeof(ESubGhzChatCryptoCtx));
-		ESubGhzChatReplayDict_init(ret->replay_dict);
-		ret->run_id = 0;
-		ret->counter = 1;
-	}
+    if(ret != NULL) {
+        memset(ret, 0, sizeof(ESubGhzChatCryptoCtx));
+        ESubGhzChatReplayDict_init(ret->replay_dict);
+        ret->run_id = 0;
+        ret->counter = 1;
+    }
 
 
-	return ret;
+    return ret;
 }
 }
 
 
-void crypto_ctx_free(ESubGhzChatCryptoCtx *ctx)
-{
-	crypto_ctx_clear(ctx);
-	ESubGhzChatReplayDict_clear(ctx->replay_dict);
-	free(ctx);
+void crypto_ctx_free(ESubGhzChatCryptoCtx* ctx) {
+    crypto_ctx_clear(ctx);
+    ESubGhzChatReplayDict_clear(ctx->replay_dict);
+    free(ctx);
 }
 }
 
 
-void crypto_ctx_clear(ESubGhzChatCryptoCtx *ctx)
-{
-	crypto_explicit_bzero(ctx->key, sizeof(ctx->key));
+void crypto_ctx_clear(ESubGhzChatCryptoCtx* ctx) {
+    crypto_explicit_bzero(ctx->key, sizeof(ctx->key));
 #ifndef FURI_HAL_CRYPTO_ADVANCED_AVAIL
 #ifndef FURI_HAL_CRYPTO_ADVANCED_AVAIL
-	crypto_explicit_bzero(&(ctx->gcm_ctx), sizeof(ctx->gcm_ctx));
+    crypto_explicit_bzero(&(ctx->gcm_ctx), sizeof(ctx->gcm_ctx));
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
-	ESubGhzChatReplayDict_reset(ctx->replay_dict);
-	ctx->run_id = 0;
-	ctx->counter = 1;
+    ESubGhzChatReplayDict_reset(ctx->replay_dict);
+    ctx->run_id = 0;
+    ctx->counter = 1;
 }
 }
 
 
-static uint64_t crypto_calc_run_id(FuriString *flipper_name, uint32_t tick)
-{
-	const char *fn = furi_string_get_cstr(flipper_name);
-	size_t fn_len = strlen(fn);
+static uint64_t crypto_calc_run_id(FuriString* flipper_name, uint32_t tick) {
+    const char* fn = furi_string_get_cstr(flipper_name);
+    size_t fn_len = strlen(fn);
 
 
-	uint8_t h_in[fn_len + sizeof(uint32_t)];
-	memcpy(h_in, fn, fn_len);
-	memcpy(h_in + fn_len, &tick, sizeof(uint32_t));
+    uint8_t h_in[fn_len + sizeof(uint32_t)];
+    memcpy(h_in, fn, fn_len);
+    memcpy(h_in + fn_len, &tick, sizeof(uint32_t));
 
 
-	uint8_t h_out[256];
-	sha256(h_in, fn_len + sizeof(uint32_t), h_out);
+    uint8_t h_out[256];
+    mbedtls_sha256(h_in, fn_len + sizeof(uint32_t), h_out, 0);
 
 
-	uint64_t run_id;
-	memcpy(&run_id, h_out, sizeof(uint64_t));
+    uint64_t run_id;
+    memcpy(&run_id, h_out, sizeof(uint64_t));
 
 
-	return run_id;
+    return run_id;
 }
 }
 
 
-bool crypto_ctx_set_key(ESubGhzChatCryptoCtx *ctx, const uint8_t *key,
-		FuriString *flipper_name, uint32_t tick)
-{
-	ctx->run_id = crypto_calc_run_id(flipper_name, tick);
-	ctx->counter = 1;
+bool crypto_ctx_set_key(
+    ESubGhzChatCryptoCtx* ctx,
+    const uint8_t* key,
+    FuriString* flipper_name,
+    uint32_t tick) {
+    ctx->run_id = crypto_calc_run_id(flipper_name, tick);
+    ctx->counter = 1;
 
 
-	memcpy(ctx->key, key, KEY_BITS / 8);
+    memcpy(ctx->key, key, KEY_BITS / 8);
 #ifdef FURI_HAL_CRYPTO_ADVANCED_AVAIL
 #ifdef FURI_HAL_CRYPTO_ADVANCED_AVAIL
-	return true;
+    return true;
 #else /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 #else /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
-	return (gcm_setkey(&(ctx->gcm_ctx), key, KEY_BITS / 8) == 0);
+    return (gcm_setkey(&(ctx->gcm_ctx), key, KEY_BITS / 8) == 0);
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 }
 }
 
 
-void crypto_ctx_get_key(ESubGhzChatCryptoCtx *ctx, uint8_t *key)
-{
-	memcpy(key, ctx->key, KEY_BITS / 8);
+void crypto_ctx_get_key(ESubGhzChatCryptoCtx* ctx, uint8_t* key) {
+    memcpy(key, ctx->key, KEY_BITS / 8);
 }
 }
 
 
-bool crypto_ctx_decrypt(ESubGhzChatCryptoCtx *ctx, uint8_t *in, size_t in_len,
-		uint8_t *out)
-{
-	if (in_len < MSG_OVERHEAD + 1) {
-		return false;
-	}
-
-	struct ESubGhzChatCryptoMsg *msg = (struct ESubGhzChatCryptoMsg *) in;
-
-	// check if message is stale, if yes, discard
-	uint32_t *counter = ESubGhzChatReplayDict_get(ctx->replay_dict,
-			msg->run_id);
-	if (counter != NULL) {
-		if (*counter >= __ntohl(msg->counter)) {
-			return false;
-		}
-	}
-
-	// decrypt and auth message
+bool crypto_ctx_decrypt(ESubGhzChatCryptoCtx* ctx, uint8_t* in, size_t in_len, uint8_t* out) {
+    if(in_len < MSG_OVERHEAD + 1) {
+        return false;
+    }
+
+    struct ESubGhzChatCryptoMsg* msg = (struct ESubGhzChatCryptoMsg*)in;
+
+    // check if message is stale, if yes, discard
+    uint32_t* counter = ESubGhzChatReplayDict_get(ctx->replay_dict, msg->run_id);
+    if(counter != NULL) {
+        if(*counter >= __ntohl(msg->counter)) {
+            return false;
+        }
+    }
+
+    // decrypt and auth message
 #ifdef FURI_HAL_CRYPTO_ADVANCED_AVAIL
 #ifdef FURI_HAL_CRYPTO_ADVANCED_AVAIL
-	bool ret = (furi_hal_crypto_gcm_decrypt_and_verify(ctx->key,
-			msg->iv,
-			(uint8_t *) msg, RUN_ID_BYTES + COUNTER_BYTES,
-			msg->data, out,
-			in_len - MSG_OVERHEAD,
-			msg->tag) == FuriHalCryptoGCMStateOk);
+    bool ret =
+        (furi_hal_crypto_gcm_decrypt_and_verify(
+             ctx->key,
+             msg->iv,
+             (uint8_t*)msg,
+             RUN_ID_BYTES + COUNTER_BYTES,
+             msg->data,
+             out,
+             in_len - MSG_OVERHEAD,
+             msg->tag) == FuriHalCryptoGCMStateOk);
 #else /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 #else /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
-	bool ret = (gcm_auth_decrypt(&(ctx->gcm_ctx),
-			msg->iv, IV_BYTES,
-			(uint8_t *) msg, RUN_ID_BYTES + COUNTER_BYTES,
-			msg->data, out,
-			in_len - MSG_OVERHEAD,
-			msg->tag, TAG_BYTES) == 0);
+    bool ret =
+        (gcm_auth_decrypt(
+             &(ctx->gcm_ctx),
+             msg->iv,
+             IV_BYTES,
+             (uint8_t*)msg,
+             RUN_ID_BYTES + COUNTER_BYTES,
+             msg->data,
+             out,
+             in_len - MSG_OVERHEAD,
+             msg->tag,
+             TAG_BYTES) == 0);
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 
 
-	// if auth was successful update replay dict
-	if (ret) {
-		ESubGhzChatReplayDict_set_at(ctx->replay_dict, msg->run_id,
-				__ntohl(msg->counter));
-	}
+    // if auth was successful update replay dict
+    if(ret) {
+        ESubGhzChatReplayDict_set_at(ctx->replay_dict, msg->run_id, __ntohl(msg->counter));
+    }
 
 
-	return ret;
+    return ret;
 }
 }
 
 
-bool crypto_ctx_encrypt(ESubGhzChatCryptoCtx *ctx, uint8_t *in, size_t in_len,
-		uint8_t *out)
-{
-	struct ESubGhzChatCryptoMsg *msg = (struct ESubGhzChatCryptoMsg *) out;
+bool crypto_ctx_encrypt(ESubGhzChatCryptoCtx* ctx, uint8_t* in, size_t in_len, uint8_t* out) {
+    struct ESubGhzChatCryptoMsg* msg = (struct ESubGhzChatCryptoMsg*)out;
 
 
-	// fill message header
-	msg->run_id = ctx->run_id;
-	msg->counter = __htonl(ctx->counter);
-	furi_hal_random_fill_buf(msg->iv, IV_BYTES);
+    // fill message header
+    msg->run_id = ctx->run_id;
+    msg->counter = __htonl(ctx->counter);
+    furi_hal_random_fill_buf(msg->iv, IV_BYTES);
 
 
-	// encrypt message and store tag in header
+    // encrypt message and store tag in header
 #ifdef FURI_HAL_CRYPTO_ADVANCED_AVAIL
 #ifdef FURI_HAL_CRYPTO_ADVANCED_AVAIL
-	bool ret = (furi_hal_crypto_gcm_encrypt_and_tag(ctx->key,
-			msg->iv,
-			(uint8_t *) msg, RUN_ID_BYTES + COUNTER_BYTES,
-			in, msg->data,
-			in_len,
-			msg->tag) == FuriHalCryptoGCMStateOk);
+    bool ret =
+        (furi_hal_crypto_gcm_encrypt_and_tag(
+             ctx->key,
+             msg->iv,
+             (uint8_t*)msg,
+             RUN_ID_BYTES + COUNTER_BYTES,
+             in,
+             msg->data,
+             in_len,
+             msg->tag) == FuriHalCryptoGCMStateOk);
 #else /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 #else /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
-	bool ret = (gcm_crypt_and_tag(&(ctx->gcm_ctx), ENCRYPT,
-			msg->iv, IV_BYTES,
-			(uint8_t *) msg, RUN_ID_BYTES + COUNTER_BYTES,
-			in, msg->data,
-			in_len,
-			msg->tag, TAG_BYTES) == 0);
+    bool ret =
+        (gcm_crypt_and_tag(
+             &(ctx->gcm_ctx),
+             ENCRYPT,
+             msg->iv,
+             IV_BYTES,
+             (uint8_t*)msg,
+             RUN_ID_BYTES + COUNTER_BYTES,
+             in,
+             msg->data,
+             in_len,
+             msg->tag,
+             TAG_BYTES) == 0);
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 #endif /* FURI_HAL_CRYPTO_ADVANCED_AVAIL */
 
 
-	// update replay dict and increase internal counter
-	if (ret) {
-		ESubGhzChatReplayDict_set_at(ctx->replay_dict, ctx->run_id,
-				ctx->counter);
-		ctx->counter++;
-	}
+    // update replay dict and increase internal counter
+    if(ret) {
+        ESubGhzChatReplayDict_set_at(ctx->replay_dict, ctx->run_id, ctx->counter);
+        ctx->counter++;
+    }
 
 
-	return ret;
+    return ret;
 }
 }
 
 
-size_t crypto_ctx_dump_replay_dict(ESubGhzChatCryptoCtx *ctx,
-		CryptoCtxReplayDictWriter writer, void *writer_ctx)
-{
-	size_t ret = 0;
-	ESubGhzChatReplayDict_it_t i;
-
-	for (ESubGhzChatReplayDict_it(i, ctx->replay_dict);
-			!ESubGhzChatReplayDict_end_p(i);
-			ESubGhzChatReplayDict_next(i), ret++) {
-		ESubGhzChatReplayDict_itref_t *ref =
-			ESubGhzChatReplayDict_ref(i);
-		if (!writer(ref->key, ref->value, writer_ctx)) {
-			break;
-		}
-	}
-
-	return ret;
+size_t crypto_ctx_dump_replay_dict(
+    ESubGhzChatCryptoCtx* ctx,
+    CryptoCtxReplayDictWriter writer,
+    void* writer_ctx) {
+    size_t ret = 0;
+    ESubGhzChatReplayDict_it_t i;
+
+    for(ESubGhzChatReplayDict_it(i, ctx->replay_dict); !ESubGhzChatReplayDict_end_p(i);
+        ESubGhzChatReplayDict_next(i), ret++) {
+        ESubGhzChatReplayDict_itref_t* ref = ESubGhzChatReplayDict_ref(i);
+        if(!writer(ref->key, ref->value, writer_ctx)) {
+            break;
+        }
+    }
+
+    return ret;
 }
 }
 
 
-size_t crypto_ctx_read_replay_dict(ESubGhzChatCryptoCtx *ctx,
-		CryptoCtxReplayDictReader reader, void *reader_ctx)
-{
-	size_t ret = 0;
+size_t crypto_ctx_read_replay_dict(
+    ESubGhzChatCryptoCtx* ctx,
+    CryptoCtxReplayDictReader reader,
+    void* reader_ctx) {
+    size_t ret = 0;
 
 
-	uint64_t run_id;
-	uint32_t counter;
+    uint64_t run_id;
+    uint32_t counter;
 
 
-	while (reader(&run_id, &counter, reader_ctx)) {
-		ESubGhzChatReplayDict_set_at(ctx->replay_dict, run_id,
-				counter);
-		ret++;
-	}
+    while(reader(&run_id, &counter, reader_ctx)) {
+        ESubGhzChatReplayDict_set_at(ctx->replay_dict, run_id, counter);
+        ret++;
+    }
 
 
-	return ret;
+    return ret;
 }
 }

+ 1 - 1
esubghz_chat_i.h

@@ -12,7 +12,7 @@
 #include <gui/modules/text_input.h>
 #include <gui/modules/text_input.h>
 #include <notification/notification_messages.h>
 #include <notification/notification_messages.h>
 #include <lib/subghz/subghz_tx_rx_worker.h>
 #include <lib/subghz/subghz_tx_rx_worker.h>
-#include <toolbox/sha256.h>
+#include <mbedtls/sha256.h>
 
 
 #include "crypto_wrapper.h"
 #include "crypto_wrapper.h"
 #include "scenes/esubghz_chat_scene.h"
 #include "scenes/esubghz_chat_scene.h"

+ 78 - 94
scenes/esubghz_chat_pass_input.c

@@ -1,125 +1,109 @@
 #include "../esubghz_chat_i.h"
 #include "../esubghz_chat_i.h"
 
 
 /* Sends PassEntered event to scene manager. */
 /* Sends PassEntered event to scene manager. */
-static void pass_input_cb(void *context)
-{
-	furi_assert(context);
-	ESubGhzChatState* state = context;
+static void pass_input_cb(void* context) {
+    furi_assert(context);
+    ESubGhzChatState* state = context;
 
 
-	crypto_explicit_bzero(state->text_input_store,
-			sizeof(state->text_input_store));
+    crypto_explicit_bzero(state->text_input_store, sizeof(state->text_input_store));
 
 
-	view_dispatcher_send_custom_event(state->view_dispatcher,
-			ESubGhzChatEvent_PassEntered);
+    view_dispatcher_send_custom_event(state->view_dispatcher, ESubGhzChatEvent_PassEntered);
 }
 }
 
 
 /* If a password was entered this derives a key from the password using a
 /* If a password was entered this derives a key from the password using a
  * single pass of SHA256 and initiates the AES-GCM context for encryption. If
  * single pass of SHA256 and initiates the AES-GCM context for encryption. If
  * the initiation fails, the password is rejected. */
  * the initiation fails, the password is rejected. */
-static bool pass_input_validator(const char *text, FuriString *error,
-		void *context)
-{
-	furi_assert(text);
-	furi_assert(error);
+static bool pass_input_validator(const char* text, FuriString* error, void* context) {
+    furi_assert(text);
+    furi_assert(error);
 
 
-	furi_assert(context);
-	ESubGhzChatState* state = context;
+    furi_assert(context);
+    ESubGhzChatState* state = context;
 
 
-	if (strlen(text) == 0) {
-		furi_string_printf(error, "Enter a\npassword!");
-		return false;
-	}
+    if(strlen(text) == 0) {
+        furi_string_printf(error, "Enter a\npassword!");
+        return false;
+    }
 
 
-	unsigned char key[KEY_BITS / 8];
+    unsigned char key[KEY_BITS / 8];
 
 
-	/* derive a key from the password */
-	sha256((unsigned char *) text, strlen(text), key);
+    /* derive a key from the password */
+    mbedtls_sha256((unsigned char*)text, strlen(text), key, 0);
 
 
-	/* initiate the crypto context */
-	bool ret = crypto_ctx_set_key(state->crypto_ctx, key,
-			state->name_prefix, furi_get_tick());
+    /* initiate the crypto context */
+    bool ret = crypto_ctx_set_key(state->crypto_ctx, key, state->name_prefix, furi_get_tick());
 
 
-	/* cleanup */
-	crypto_explicit_bzero(key, sizeof(key));
+    /* cleanup */
+    crypto_explicit_bzero(key, sizeof(key));
 
 
-	if (!ret) {
-		crypto_ctx_clear(state->crypto_ctx);
-		furi_string_printf(error, "Failed to\nset key!");
-		return false;
-	}
+    if(!ret) {
+        crypto_ctx_clear(state->crypto_ctx);
+        furi_string_printf(error, "Failed to\nset key!");
+        return false;
+    }
 
 
-	state->encrypted = true;
+    state->encrypted = true;
 
 
-	return true;
+    return true;
 }
 }
 
 
 /* Prepares the password input scene. */
 /* Prepares the password input scene. */
-void scene_on_enter_pass_input(void* context)
-{
-	FURI_LOG_T(APPLICATION_NAME, "scene_on_enter_pass_input");
-
-	furi_assert(context);
-	ESubGhzChatState* state = context;
-
-	state->text_input_store[0] = 0;
-	text_input_reset(state->text_input);
-	text_input_set_result_callback(
-			state->text_input,
-			pass_input_cb,
-			state,
-			state->text_input_store,
-			sizeof(state->text_input_store),
-			true);
-	text_input_set_validator(
-			state->text_input,
-			pass_input_validator,
-			state);
-	text_input_set_header_text(
-			state->text_input,
-			"Password");
-
-	view_dispatcher_switch_to_view(state->view_dispatcher, ESubGhzChatView_Input);
+void scene_on_enter_pass_input(void* context) {
+    FURI_LOG_T(APPLICATION_NAME, "scene_on_enter_pass_input");
+
+    furi_assert(context);
+    ESubGhzChatState* state = context;
+
+    state->text_input_store[0] = 0;
+    text_input_reset(state->text_input);
+    text_input_set_result_callback(
+        state->text_input,
+        pass_input_cb,
+        state,
+        state->text_input_store,
+        sizeof(state->text_input_store),
+        true);
+    text_input_set_validator(state->text_input, pass_input_validator, state);
+    text_input_set_header_text(state->text_input, "Password");
+
+    view_dispatcher_switch_to_view(state->view_dispatcher, ESubGhzChatView_Input);
 }
 }
 
 
 /* Handles scene manager events for the password input scene. */
 /* Handles scene manager events for the password input scene. */
-bool scene_on_event_pass_input(void* context, SceneManagerEvent event)
-{
-	FURI_LOG_T(APPLICATION_NAME, "scene_on_event_pass_input");
-
-	furi_assert(context);
-	ESubGhzChatState* state = context;
-
-	bool consumed = false;
-
-	switch(event.type) {
-	case SceneManagerEventTypeCustom:
-		switch(event.event) {
-		/* switch to frequency input scene */
-		case ESubGhzChatEvent_PassEntered:
-			scene_manager_next_scene(state->scene_manager,
-					ESubGhzChatScene_FreqInput);
-			consumed = true;
-			break;
-		}
-		break;
-
-	default:
-		consumed = false;
-		break;
-	}
-
-	return consumed;
+bool scene_on_event_pass_input(void* context, SceneManagerEvent event) {
+    FURI_LOG_T(APPLICATION_NAME, "scene_on_event_pass_input");
+
+    furi_assert(context);
+    ESubGhzChatState* state = context;
+
+    bool consumed = false;
+
+    switch(event.type) {
+    case SceneManagerEventTypeCustom:
+        switch(event.event) {
+        /* switch to frequency input scene */
+        case ESubGhzChatEvent_PassEntered:
+            scene_manager_next_scene(state->scene_manager, ESubGhzChatScene_FreqInput);
+            consumed = true;
+            break;
+        }
+        break;
+
+    default:
+        consumed = false;
+        break;
+    }
+
+    return consumed;
 }
 }
 
 
 /* Cleans up the password input scene. */
 /* Cleans up the password input scene. */
-void scene_on_exit_pass_input(void* context)
-{
-	FURI_LOG_T(APPLICATION_NAME, "scene_on_exit_pass_input");
+void scene_on_exit_pass_input(void* context) {
+    FURI_LOG_T(APPLICATION_NAME, "scene_on_exit_pass_input");
 
 
-	furi_assert(context);
-	ESubGhzChatState* state = context;
+    furi_assert(context);
+    ESubGhzChatState* state = context;
 
 
-	text_input_reset(state->text_input);
-	crypto_explicit_bzero(state->text_input_store,
-			sizeof(state->text_input_store));
+    text_input_reset(state->text_input);
+    crypto_explicit_bzero(state->text_input_store, sizeof(state->text_input_store));
 }
 }