2022-10-12 02:01:37 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "../../types/plugin_state.h"
|
|
|
|
#include "../../types/token_info.h"
|
2023-04-26 20:50:37 +00:00
|
|
|
#include "config_file_context.h"
|
2022-10-12 02:01:37 +00:00
|
|
|
#include "constants.h"
|
2023-04-26 20:50:37 +00:00
|
|
|
#include "token_info_iterator.h"
|
2022-10-12 02:01:37 +00:00
|
|
|
|
2022-12-26 20:31:38 +00:00
|
|
|
typedef uint8_t TotpConfigFileOpenResult;
|
|
|
|
typedef uint8_t TotpConfigFileUpdateResult;
|
2022-11-23 22:19:19 +00:00
|
|
|
|
2023-04-13 18:20:29 +00:00
|
|
|
/**
|
|
|
|
* @brief Tries to take a config file backup
|
2023-04-26 20:50:37 +00:00
|
|
|
* @param plugin_state application state
|
2023-04-13 18:20:29 +00:00
|
|
|
* @return backup path if backup successfully taken; \c NULL otherwise
|
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
char* totp_config_file_backup(const PluginState* plugin_state);
|
2023-04-13 18:20:29 +00:00
|
|
|
|
2022-11-17 19:33:31 +00:00
|
|
|
/**
|
2023-04-26 20:50:37 +00:00
|
|
|
* @brief Loads basic information from an application config file into application state without loading all the tokens
|
2022-11-17 19:33:31 +00:00
|
|
|
* @param plugin_state application state
|
2023-04-26 20:50:37 +00:00
|
|
|
* @return Config file open result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
bool totp_config_file_load(PluginState* const plugin_state);
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
2023-04-26 20:50:37 +00:00
|
|
|
* @brief Updates timezone offset in an application config file
|
2022-11-17 19:33:31 +00:00
|
|
|
* @param plugin_state application state
|
2023-04-26 20:50:37 +00:00
|
|
|
* @return Config file update result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
bool totp_config_file_update_timezone_offset(const PluginState* plugin_state);
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
2023-04-26 20:50:37 +00:00
|
|
|
* @brief Updates notification method in an application config file
|
2022-11-17 19:33:31 +00:00
|
|
|
* @param plugin_state application state
|
2023-04-26 20:50:37 +00:00
|
|
|
* @return Config file update result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
bool totp_config_file_update_notification_method(const PluginState* plugin_state);
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
2023-04-26 20:50:37 +00:00
|
|
|
* @brief Updates automation method in an application config file
|
|
|
|
* @param plugin_state application state
|
2022-12-26 20:31:38 +00:00
|
|
|
* @return Config file update result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
bool totp_config_file_update_automation_method(const PluginState* plugin_state);
|
2022-11-17 19:33:31 +00:00
|
|
|
|
|
|
|
/**
|
2023-04-26 20:50:37 +00:00
|
|
|
* @brief Updates application user settings
|
|
|
|
* @param plugin_state application state
|
2022-12-26 20:31:38 +00:00
|
|
|
* @return Config file update result
|
2022-11-17 19:33:31 +00:00
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
bool totp_config_file_update_user_settings(const PluginState* plugin_state);
|
2022-11-23 22:19:19 +00:00
|
|
|
|
|
|
|
/**
|
2023-04-26 20:50:37 +00:00
|
|
|
* @brief Updates crypto signatures information
|
|
|
|
* @param plugin_state application state
|
2022-12-26 20:31:38 +00:00
|
|
|
* @return Config file update result
|
2022-11-23 22:19:19 +00:00
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
bool totp_config_file_update_crypto_signatures(const PluginState* plugin_state);
|
2022-11-23 22:19:19 +00:00
|
|
|
|
2023-03-21 16:03:53 +00:00
|
|
|
/**
|
2023-04-26 20:50:37 +00:00
|
|
|
* @brief Reset all the settings to default
|
|
|
|
* @param plugin_state application state
|
2023-03-21 16:03:53 +00:00
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
void totp_config_file_reset(PluginState* const plugin_state);
|
2023-03-21 16:03:53 +00:00
|
|
|
|
2022-11-23 22:19:19 +00:00
|
|
|
/**
|
2023-04-26 20:50:37 +00:00
|
|
|
* @brief Closes config file and releases all the resources
|
2022-11-23 22:19:19 +00:00
|
|
|
* @param plugin_state application state
|
2022-12-26 20:31:38 +00:00
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
void totp_config_file_close(PluginState* const plugin_state);
|
2022-12-26 20:31:38 +00:00
|
|
|
|
|
|
|
/**
|
2023-04-26 20:50:37 +00:00
|
|
|
* @brief Updates config file encryption by re-encrypting it using new user's PIN and new randomly generated IV
|
2022-12-26 20:31:38 +00:00
|
|
|
* @param plugin_state application state
|
2023-04-26 20:50:37 +00:00
|
|
|
* @param new_pin new user's PIN
|
|
|
|
* @param new_pin_length new user's PIN length
|
|
|
|
* @return \c true if config file encryption successfully updated; \c false otherwise
|
2022-11-23 22:19:19 +00:00
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
bool totp_config_file_update_encryption(
|
|
|
|
PluginState* plugin_state,
|
|
|
|
const uint8_t* new_pin,
|
|
|
|
uint8_t new_pin_length);
|
2023-01-06 23:07:26 +00:00
|
|
|
|
|
|
|
/**
|
2023-04-26 20:50:37 +00:00
|
|
|
* @brief Gets token info iterator context
|
|
|
|
* @param plugin_state application state
|
|
|
|
* @return token info iterator context
|
2023-01-06 23:07:26 +00:00
|
|
|
*/
|
2023-04-26 20:50:37 +00:00
|
|
|
TokenInfoIteratorContext* totp_config_get_token_iterator_context(const PluginState* plugin_state);
|