mirror of
https://github.com/Next-Flip/Momentum-Firmware.git
synced 2026-04-24 03:29:57 -07:00
Move U2F counter back to sd, only key on internal
This commit is contained in:
@@ -29,7 +29,7 @@ U2fApp* u2f_app_alloc() {
|
||||
app->notifications = furi_record_open(RECORD_NOTIFICATION);
|
||||
|
||||
Storage* storage = furi_record_open(RECORD_STORAGE);
|
||||
storage_common_copy(storage, U2F_CNT_OLD_FILE, U2F_CNT_FILE);
|
||||
storage_common_rename(storage, U2F_CNT_OLD_FILE, U2F_CNT_FILE);
|
||||
storage_common_copy(storage, U2F_KEY_OLD_FILE, U2F_KEY_FILE);
|
||||
furi_record_close(RECORD_STORAGE);
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ extern "C" {
|
||||
#define U2F_DATA_FOLDER EXT_PATH("u2f/")
|
||||
#define U2F_CERT_FILE U2F_DATA_FOLDER "assets/cert.der"
|
||||
#define U2F_CERT_KEY_FILE U2F_DATA_FOLDER "assets/cert_key.u2f"
|
||||
#define U2F_CNT_OLD_FILE INT_PATH(".cnt.u2f")
|
||||
#define U2F_KEY_OLD_FILE U2F_DATA_FOLDER "key.u2f"
|
||||
#define U2F_CNT_OLD_FILE U2F_DATA_FOLDER "cnt.u2f"
|
||||
#define U2F_CNT_FILE U2F_DATA_FOLDER "cnt.u2f"
|
||||
#define U2F_KEY_FILE INT_PATH(".key.u2f")
|
||||
#define U2F_CNT_FILE INT_PATH(".cnt.u2f")
|
||||
|
||||
bool u2f_data_check(bool cert_only);
|
||||
|
||||
|
||||
@@ -195,30 +195,19 @@ static void storage_int_lfs_mount(LFSData* lfs_data, StorageData* storage) {
|
||||
if(need_format) {
|
||||
// Backup U2F keys
|
||||
// lfs_file_t file;
|
||||
// uint8_t* cnt = NULL;
|
||||
// uint32_t cnt_size;
|
||||
// uint8_t* key = NULL;
|
||||
// uint32_t key_size;
|
||||
// if(lfs_mount(lfs, &lfs_data->config) == 0) {
|
||||
// FURI_LOG_I(TAG, "Factory reset: Mounted for backup");
|
||||
|
||||
// if(lfs_file_open(lfs, &file, ".cnt.u2f", LFS_O_RDONLY) == 0) {
|
||||
// cnt_size = file.ctz.size;
|
||||
// cnt = malloc(cnt_size);
|
||||
// if(lfs_file_read(lfs, &file, cnt, cnt_size) != (int32_t)cnt_size) {
|
||||
// free(cnt);
|
||||
// cnt = NULL;
|
||||
// if(lfs_file_open(lfs, &file, ".key.u2f", LFS_O_RDONLY) == 0) {
|
||||
// key_size = file.ctz.size;
|
||||
// key = malloc(key_size);
|
||||
// if(lfs_file_read(lfs, &file, key, key_size) != (int32_t)key_size) {
|
||||
// free(key);
|
||||
// key = NULL;
|
||||
// }
|
||||
// lfs_file_close(lfs, &file);
|
||||
// if(lfs_file_open(lfs, &file, ".key.u2f", LFS_O_RDONLY) == 0) {
|
||||
// key_size = file.ctz.size;
|
||||
// key = malloc(key_size);
|
||||
// if(lfs_file_read(lfs, &file, key, key_size) != (int32_t)key_size) {
|
||||
// free(key);
|
||||
// key = NULL;
|
||||
// }
|
||||
// lfs_file_close(lfs, &file);
|
||||
// }
|
||||
// }
|
||||
|
||||
// if(lfs_unmount(lfs) == 0) {
|
||||
@@ -239,19 +228,12 @@ static void storage_int_lfs_mount(LFSData* lfs_data, StorageData* storage) {
|
||||
storage->status = StorageStatusOK;
|
||||
|
||||
// Restore U2F keys
|
||||
// if(cnt != NULL && key != NULL) {
|
||||
// if(lfs_file_open(lfs, &file, ".cnt.u2f", LFS_O_WRONLY | LFS_O_CREAT) == 0) {
|
||||
// lfs_file_write(lfs, &file, cnt, cnt_size);
|
||||
// if(key != NULL) {
|
||||
// if(lfs_file_open(lfs, &file, ".key.u2f", LFS_O_WRONLY | LFS_O_CREAT) == 0) {
|
||||
// lfs_file_write(lfs, &file, key, key_size);
|
||||
// lfs_file_close(lfs, &file);
|
||||
// if(lfs_file_open(lfs, &file, ".key.u2f", LFS_O_WRONLY | LFS_O_CREAT) ==
|
||||
// 0) {
|
||||
// lfs_file_write(lfs, &file, key, key_size);
|
||||
// lfs_file_close(lfs, &file);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if(cnt != NULL) free(cnt);
|
||||
// if(key != NULL) free(key);
|
||||
} else {
|
||||
FURI_LOG_E(TAG, "Factory reset: Mount after format failed");
|
||||
storage->status = StorageStatusNotMounted;
|
||||
@@ -260,6 +242,7 @@ static void storage_int_lfs_mount(LFSData* lfs_data, StorageData* storage) {
|
||||
FURI_LOG_E(TAG, "Factory reset: Format failed");
|
||||
storage->status = StorageStatusNoFS;
|
||||
}
|
||||
// if(key != NULL) free(key);
|
||||
} else {
|
||||
// Normal
|
||||
err = lfs_mount(lfs, &lfs_data->config);
|
||||
|
||||
Reference in New Issue
Block a user