#ifndef IFAA_FINGERPRINT_ID_TABLE_H
#define IFAA_FINGERPRINT_ID_TABLE_H

#include "ifaa_ta_common.h"

#define FID_TABLE_PATH         "IFAA_FID_TABLE"
#define FID_TABLE_PATH_LEN     14
#define FID_TABLE_MAX          10
#define FID_LEN                128
#ifndef XOR_FID_FOR_SERVER
#define XOR_FID_FOR_SERVER     0x3223
#endif
#ifndef XOR_FID_FOR_SERVER_V1
#define XOR_FID_FOR_SERVER_V1     0x8998
#endif

#ifndef ROTATE_FID_FOR_SERVER
#define ROTATE_FID_FOR_SERVER  16
#endif

#define SYSTEM_FID_TABLE_PATH         "SYSTEM_FID_TABLE"
#define SYSTEM_FID_TABLE_PATH_LEN     16

typedef struct SystemFidStruct {
    uint32_t realFpIndex;
    uint8_t realFid[FID_LEN];
}SystemFidStruct;

IFAA_Result load_system_fid_table(SystemFidStruct *enrolledFps, uint8_t *cnt);
IFAA_Result save_system_fid_table(const SystemFidStruct *pEnrolledFps, const uint8_t cnt);
IFAA_Result update_ifaa_fid(SystemFidStruct *enrolledFps, uint32_t *ifaaIds, uint8_t realCnt);


typedef struct FingerprintIdStruct {
    uint8_t *fingerprint_id;
    uint32_t ifaa_fid;
} FingerprintIdStruct;

IFAA_Result load_fid_table(const char *path, uint32_t path_len);
IFAA_Result save_fid_table(const char *path, uint32_t path_len, bool is_free);
uint32_t get_ifaa_fid(const uint8_t *fingerprint_id, uint8_t fid_index);
uint32_t auto_get_ifaa_fid(const char *path, uint32_t path_len, const uint8_t *fingerprint_id, uint8_t fid_index);

uint8_t get_fid_table_count();

#endif // IFAA_FINGERPRINT_ID_TABLE_H

