Files
se050-wireguard/include/se050_session_internal.h
km 11bcc5e0c3 Remove dynamic memory allocation (malloc/calloc/free)
- Add static memory pool implementation (se050_mem_pool.c/h)
- Replace all malloc/calloc with pool allocations
- Replace all free with pool deallocations
- Remove strdup usage (use fixed-size buffer instead)
- Update I2C HAL to use fixed-size dev_path array
- All 24 tests pass with static memory only

Suitable for embedded environments (u-boot, ESP32) without heap.
2026-03-29 19:07:57 +09:00

60 lines
1.8 KiB
C

/**
* @file se050_session_internal.h
* @brief SE050 Session Internal Definitions
*
* Internal definitions for session implementation.
*
* License: MIT (Clean-room implementation)
*/
#ifndef SE050_SESSION_INTERNAL_H
#define SE050_SESSION_INTERNAL_H
#include "se050_i2c_hal.h"
#include "se050_wireguard.h"
#include <stdint.h>
/* Session states */
typedef enum {
SESSION_STATE_CREATED = 0,
SESSION_STATE_OPENED,
SESSION_STATE_CLOSED,
} session_state_t;
/**
* @brief SCP03 secure channel context
*/
typedef struct se050_scp03_ctx {
struct se050_session_ctx *session; /**< Associated session */
uint8_t enc_key[16]; /**< Encryption key */
uint8_t mac_key[16]; /**< MAC key */
uint8_t dek_key[16]; /**< DEK key */
uint8_t cmd_icv[8]; /**< Command ICV */
uint8_t rsp_icv[8]; /**< Response ICV */
uint64_t cmd_counter; /**< Command counter */
uint64_t rsp_counter; /**< Response counter */
uint8_t initialized; /**< Initialization flag */
} se050_scp03_ctx_t;
/**
* @brief RNG context (forward declaration)
*/
typedef struct se050_rng_ctx se050_rng_ctx_t;
/**
* @brief Session context structure
*/
typedef struct se050_session_ctx se050_session_ctx_t;
struct se050_session_ctx {
se050_i2c_hal_t *hal; /**< I2C HAL interface */
session_state_t state; /**< Current session state */
uint32_t session_id; /**< Unique session identifier */
se050_scp03_ctx_t *scp03; /**< SCP03 secure channel context */
uint8_t session_key[32]; /**< Session encryption key */
size_t session_key_len; /**< Session key length */
se050_rng_ctx_t *rng; /**< RNG context */
};
#endif /* SE050_SESSION_INTERNAL_H */