uint32_t fpc_auth_step(uint32_t *print_id) { fpc_send_std_cmd_t* send_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer; fpc_send_auth_cmd_t* rec_cmd = (fpc_send_auth_cmd_t*) mHandle->ion_sbuffer + 64; send_cmd->cmd_id = FPC_AUTH_STEP; send_cmd->ret_val = 0x00; int ret = send_cmd_fn(mHandle,send_cmd,64,rec_cmd,64); if(ret < 0) { return -1; } //if the print didnt capture properly return error and continue if (rec_cmd->ret_val < 2) { return -1; } *print_id = fpc_get_print_id(rec_cmd->id); return 0; }
int fpc_auth_start() { int print_count = fpc_get_print_count(); fpc_fingerprint_index_t prints; ALOGI("%s : Number Of Prints Available : %d",__func__,print_count); prints = fpc_get_print_ids(print_count); fpc_get_pint_index_cmd_t* send_cmd = (fpc_get_pint_index_cmd_t*) mHandle->ion_sbuffer; fpc_send_std_cmd_t* rec_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer + 64; send_cmd->cmd_id = FPC_AUTH_START; send_cmd->p1 = prints.prints[0]; send_cmd->p2 = prints.prints[1]; send_cmd->p3 = prints.prints[2]; send_cmd->p4 = prints.prints[3]; send_cmd->p5 = prints.prints[4]; send_cmd->print_count = prints.print_count; int ret = send_cmd_fn(mHandle,send_cmd,64,rec_cmd,64); if(ret < 0) { ALOGE("Error sending FPC_AUTH_START to tz\n"); return -1; } return rec_cmd->ret_val; }
uint32_t fpc_get_user_db_length() { fpc_send_std_cmd_t* send_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer; fpc_send_std_cmd_t* rec_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer + 64; send_cmd->cmd_id = FPC_GET_DB_LENGTH; send_cmd->ret_val = 0x00; int ret = send_cmd_fn(mHandle,send_cmd,64,rec_cmd,64); if(ret < 0) { return -1; } return send_cmd->ret_val; }
uint32_t fpc_get_print_count() { fpc_send_std_cmd_t* send_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer; fpc_send_std_cmd_t* rec_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer + 64; send_cmd->cmd_id = FPC_GET_ID_COUNT; send_cmd->ret_val = 0x00; int ret = send_cmd_fn(mHandle,send_cmd,64,rec_cmd,64); if(ret < 0) { return -1; } return send_cmd->ret_val; }
uint32_t fpc_get_print_id(int id) { fpc_send_std_cmd_t* send_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer; fpc_send_std_cmd_t* rec_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer + 64; send_cmd->cmd_id = FPC_GET_PRINT_ID; send_cmd->ret_val = id; int ret = send_cmd_fn(mHandle,send_cmd,64,rec_cmd,64); if(ret < 0) { return -1; } return send_cmd->ret_val; }
int send_normal_command(uint32_t cmd, uint32_t param, struct QSEECom_handle * handle) { fpc_send_std_cmd_t* send_cmd = (fpc_send_std_cmd_t*) handle->ion_sbuffer; fpc_send_std_cmd_t* rec_cmd = (fpc_send_std_cmd_t*) handle->ion_sbuffer + 64; send_cmd->cmd_id = cmd; send_cmd->ret_val = param; int ret = send_cmd_fn(handle,send_cmd,64,rec_cmd,64); if(ret < 0) { return -1; } return rec_cmd->ret_val; }
int fpc_enroll_start(int print_index) { fpc_send_enroll_start_cmd_t* send_cmd = (fpc_send_enroll_start_cmd_t*) mHandle->ion_sbuffer; fpc_send_std_cmd_t* rec_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer + 64; send_cmd->cmd_id = FPC_ENROLL_START; send_cmd->ret_val = 0x00; send_cmd->na1 = 0x45; send_cmd->print_index = print_index; int ret = send_cmd_fn(mHandle,send_cmd,64,rec_cmd,64); if(ret < 0) { return -1; } return rec_cmd->ret_val; }
int fpc_enroll_step(uint32_t *remaining_touches) { fpc_send_std_cmd_t* send_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer; fpc_send_std_cmd_t* rec_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer + 64; send_cmd->cmd_id = FPC_ENROLL_STEP; send_cmd->ret_val = 0x24; int ret = send_cmd_fn(mHandle,send_cmd,64,rec_cmd,64); if(ret < 0) { return -1; } *remaining_touches = fpc_get_remaining_touches(); return rec_cmd->ret_val; }
fpc_fingerprint_index_t fpc_get_print_index(int count) { fpc_fingerprint_index_t data; fpc_send_std_cmd_t* send_cmd = (fpc_send_std_cmd_t*) mHandle->ion_sbuffer; fpc_get_pint_index_cmd_t* rec_cmd = (fpc_get_pint_index_cmd_t*) mHandle->ion_sbuffer + 64; send_cmd->cmd_id = FPC_GET_ID_LIST; send_cmd->ret_val = count; send_cmd->length = count; int ret = send_cmd_fn(mHandle,send_cmd,64,rec_cmd,64); data.prints[0] = fpc_get_print_id(rec_cmd->p1); data.prints[1] = fpc_get_print_id(rec_cmd->p2); data.prints[2] = fpc_get_print_id(rec_cmd->p3); data.prints[3] = fpc_get_print_id(rec_cmd->p4); data.prints[4] = fpc_get_print_id(rec_cmd->p5); data.print_count = rec_cmd->print_count; return data; }
int fpc_init() { ALOGE("INIT FPC TZ APP\n"); open_handle(); if (open_handle() < 1) { ALOGE("Qseecom Lib Not Open !\n"); return -1; } if (device_enable() < 0) { ALOGE("Error starting device\n"); return -1; } ALOGE("Starting app %s\n", FP_TZAPP_NAME); if (mStartApp(&mHandle, FP_TZAPP_PATH, FP_TZAPP_NAME, 1024) < 0) { ALOGE("Could not load app : %s\n", FP_TZAPP_NAME); return -1; } ALOGE("TZ App loaded : %s\n", FP_TZAPP_NAME); ALOGE("Starting app %s\n", KM_TZAPP_NAME); if (mStartApp(&mHdl, KM_TZAPP_PATH, KM_TZAPP_NAME, 1024) < 0) { ALOGE("Could not load app : %s\n", KM_TZAPP_NAME); return -1; } ALOGE("TZ App loaded : %s\n", KM_TZAPP_NAME); // Start creating one off command to get cert from keymaster fpc_send_std_cmd_t *req = (fpc_send_std_cmd_t *) mHdl->ion_sbuffer; req->cmd_id = 0x205; req->ret_val = 0x02; void * send_buf = mHdl->ion_sbuffer; void * rec_buf = mHdl->ion_sbuffer + 64; if (send_cmd_fn(mHdl, send_buf, 64, rec_buf, 1024-64) < 0) { return -1; } //Send command to keymaster fpc_send_std_cmd_t* ret_data = (fpc_send_std_cmd_t*) rec_buf; ALOGE("Keymaster Response Code : %u\n", ret_data->ret_val); ALOGE("Keymaster Response Length : %u\n", ret_data->length); void * data_buff = &ret_data->length + 1; if (send_modified_command_to_tz(FPC_SET_INIT_DATA,mHandle,data_buff,ret_data->length) < 0) { ALOGE("Error sending data to tz\n"); return -1; } if (send_normal_command(FPC_INIT,0,mHandle) != 0) { ALOGE("Error sending FPC_INIT to tz\n"); return -1; } if (send_normal_command(FPC_GET_INIT_STATE,0,mHandle) != 0) { ALOGE("Error sending FPC_GET_INIT_STATE to tz\n"); return -1; } if (send_normal_command(FPC_INIT_UNK_1,0,mHandle) != 12) { ALOGE("Error sending FPC_INIT_UNK_1 to tz\n"); return -1; } if (device_enable() < 0) { ALOGE("Error starting device\n"); return -1; } if (send_normal_command(FPC_INIT_UNK_2,0,mHandle) != 0) { ALOGE("Error sending FPC_INIT_UNK_2 to tz\n"); return -1; } int fpc_info = send_normal_command(FPC_INIT_UNK_0,0,mHandle); ALOGI("Got device data : %d \n", fpc_info); if (device_disable() < 0) { ALOGE("Error stopping device\n"); return -1; } set_bandwidth_fn(mHandle,true); if (send_normal_command(FPC_INIT_NEW_DB,0,mHandle) != 0) { ALOGE("Error sending FPC_INIT_NEW_DB to tz\n"); return -1; } if (send_normal_command(FPC_SET_FP_STORE,0,mHandle) != 0) { ALOGE("Error sending FPC_SET_FP_STORE to tz\n"); return -1; } set_bandwidth_fn(mHandle,false); return 1; }