/**
 * Security Manager - Authentication and Access Control
 * Handles Wi-Fi security, web authentication, and system security
 */

#ifndef SECURITY_MANAGER_H
#define SECURITY_MANAGER_H

#include "esp_err.h"
#include <stdint.h>
#include <stdbool.h>
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>

#ifdef __cplusplus
extern "C" {
#endif

// Function prototypes
esp_err_t security_manager_init(void);
esp_err_t security_manager_deinit(void);

// Authentication functions
esp_err_t security_manager_authenticate(const char* username, const char* password, 
                                       const char* ip_address, char* session_id, size_t session_id_size);

// Password hashing functions
esp_err_t security_manager_hash_password(const char* password, char* salt, size_t salt_size, 
                                       char* hash, size_t hash_size);
bool verify_password_hash(const char* password, const char* stored_hash);

// Session management
esp_err_t security_manager_validate_session(const char* session_id, char* username, size_t username_size);
esp_err_t security_manager_logout(const char* session_id);
esp_err_t security_manager_cleanup_expired_sessions(void);
esp_err_t security_manager_get_active_sessions(int* count);

// Configuration
esp_err_t security_manager_is_authentication_required(bool* required);

#ifdef __cplusplus
}
#endif

#endif // SECURITY_MANAGER_H 