📄 auth.c
字号:
LOCAL void auth_uim_response_callback ( uim_rpt_type *uim_rpt_buf_ptr );
#endif /*FEATURE_UIM_RUIM */
#ifdef FEATURE_AUTH
/* <EJECT> */
/*===========================================================================
FUNCTION AUTH_GET_NV_ITEM
DESCRIPTION
This function gets a specific item from NV.
DEPENDENCIES
None.
RETURN VALUE
Status returned from the NV read request. Status can be either:
NV_DONE_S - request done
NV_NOTACTIVE_S - item was not active
Any other status causes ERR_FATAL and the function does not return.
SIDE EFFECTS
While this function is running all other task activities are
suspended except for watchdog kicking, and until the NV item is
read in. If any of read status other then the one described above
is returned then an ERR_FATAL call is made.
===========================================================================*/
nv_stat_enum_type auth_get_nv_item
(
nv_items_enum_type item_code, /* Item to get */
nv_item_type *item_ptr /* Pointer where to put the item */
)
{
static nv_cmd_type nv_cmd_buf;
/* Command buffer to NV */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Prepare command buffer to NV. */
nv_cmd_buf.cmd = NV_READ_F;
nv_cmd_buf.tcb_ptr = &auth_tcb;
nv_cmd_buf.sigs = AUTH_NV_CMD_SIG;
nv_cmd_buf.done_q_ptr = NULL; /* No buffer to return */
nv_cmd_buf.item = item_code;
nv_cmd_buf.data_ptr = item_ptr;
/* Clear signal, issue the command, and wait for the respone. */
(void) rex_clr_sigs(&auth_tcb, AUTH_NV_CMD_SIG);
nv_cmd(&nv_cmd_buf);
/* -----------------------------
** Kick watchdog and reset timer
** ----------------------------- */
dog_report(DOG_AUTH_RPT);
(void) rex_set_timer( &auth_rpt_timer, DOG_AUTH_RPT_TIME );
/* Wait for NV to finish processing NV_READ_F command */
(void) rex_wait( AUTH_NV_CMD_SIG );
/* Check and return status. */
if ((nv_cmd_buf.status != NV_DONE_S) &&
(nv_cmd_buf.status != NV_NOTACTIVE_S))
{
ERR_FATAL("Bad NV read status %d", nv_cmd_buf.status, 0, 0);
}
return (nv_cmd_buf.status);
} /* auth_get_nv_item */
/*===========================================================================
FUNCTION AUTH_PUT_NV_ITEM
DESCRIPTION
This function puts a specific item to NV.
DEPENDENCIES
None.
RETURN VALUE
None.
SIDE EFFECTS
While this function is running all other task activities are
suspended except for watchdog kicking, and until the NV item is
written.
===========================================================================*/
void auth_put_nv_item
(
nv_items_enum_type item_code, /* Item to put */
nv_item_type *item_ptr /* Pointer where to get the item */
)
{
static nv_cmd_type nv_cmd_buf; /* Command buffer to NV */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Prepare command buffer to NV. */
nv_cmd_buf.cmd = NV_WRITE_F;
nv_cmd_buf.tcb_ptr = &auth_tcb;
nv_cmd_buf.sigs = AUTH_NV_CMD_SIG;
nv_cmd_buf.done_q_ptr = NULL; /* No buffer to return */
nv_cmd_buf.item = item_code;
nv_cmd_buf.data_ptr = item_ptr;
(void) rex_clr_sigs(&auth_tcb, AUTH_NV_CMD_SIG);
nv_cmd(&nv_cmd_buf);
/* -----------------------------
** Kick watchdog and reset timer
** ----------------------------- */
dog_report(DOG_AUTH_RPT);
(void) rex_set_timer( &auth_rpt_timer, DOG_AUTH_RPT_TIME );
/* Wait for NV to finish processing NV_WRITE_F command */
(void) rex_wait( AUTH_NV_CMD_SIG );
if (nv_cmd_buf.status != NV_DONE_S)
{
ERR_FATAL("Failed to write item to NV %d", item_code, 0, 0);
}
} /* auth_put_nv_item */
/* <EJECT> */
/*===========================================================================
FUNCTION AUTH_VAR_INIT
DESCRIPTION
This procedure initializes the authentication task variables after a
powerup, NAM change, or A_Key change.
DEPENDENCIES
None
RETURN VALUE
None
SIDE EFFECTS
None
===========================================================================*/
LOCAL void auth_var_init
(
byte nam
/* The nam active during this initialization */
)
{
nv_item_type nv_item;
/* Item to hold values retrieved from NV */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Initialize boolean indicators */
auth_saved_registers = FALSE;
auth_ssd_update_in_progress = FALSE;
auth_valid_CMEA_key = FALSE;
auth_valid_PLCM = FALSE;
/* Store NAM index */
auth_stored_NAM_index = nam;
/* Get value of COUNTsp from NV */
nv_item.count.nam = auth_stored_NAM_index;
if (auth_get_nv_item( NV_COUNT_I, &nv_item ) == NV_NOTACTIVE_S)
{
/* Write a zero in for the COUNTsp if no count has ever been used */
nv_item.count.nam = auth_stored_NAM_index;
nv_item.count.count = 0;
auth_put_nv_item( NV_COUNT_I, &nv_item );
auth_count = 0;
}
else
{
auth_count = nv_item.count.count;
}
} /* auth_var_init() */
#endif /* FEATURE_AUTH */
#ifdef FEATURE_UIM_RUIM
/* <EJECT> */
/*===========================================================================
FUNCTION AUTH_SEND_UIM_COMMAND
DESCRIPTION
This function sends a UIM command top the UIM server.
DEPENDENCIES
None
RETURN VALUE
None
SIDE EFFECTS
This function waits for the response before returning to the calling
function.
===========================================================================*/
void auth_send_uim_command
(
uim_cmd_type *uim_cmd_ptr
)
{
/* Indicate command completion is to be signaled:
* Do not signal the Auth task upon receipt of command
* Use no signal for receipt of command
* No "done" queue
* Status call-back function
* Always Report status
*/
uim_cmd_ptr->hdr.cmd_hdr.task_ptr = NULL;
uim_cmd_ptr->hdr.cmd_hdr.sigs = 0;
uim_cmd_ptr->hdr.cmd_hdr.done_q_ptr = &uim_free_q;
uim_cmd_ptr->hdr.options = UIM_OPTION_ALWAYS_RPT;
uim_cmd_ptr->hdr.protocol = UIM_CDMA;
uim_cmd_ptr->hdr.slot = UIM_SLOT_AUTOMATIC;
uim_cmd_ptr->hdr.rpt_function = auth_uim_response_callback;
/* Send the command to the UIM server:
* Clear the "command done signal"
* Send the command
* Wait for the command to be done
*/
(void) rex_clr_sigs( &auth_tcb, AUTH_UIM_CMD_RSP_SIG );
/* Send the command to the UIM server. */
uim_cmd ( uim_cmd_ptr );
/* Wait for the response. Process the watchdog, stop, and offline
signals. */
(void) auth_wait( AUTH_UIM_CMD_RSP_SIG );
} /* auth_send_uim_command */
/* <EJECT> */
/*===========================================================================
FUNCTION AUTH_UIM_RESPONSE_CALLBACK
DESCRIPTION
This procedure initiates the processing of the response that has been recd
from the RUIM.
DEPENDENCIES
None
RETURN VALUE
None
SIDE EFFECTS
Sets the RUIM_CMD_RSP_SIG.
===========================================================================*/
LOCAL void auth_uim_response_callback ( uim_rpt_type *uim_rpt_buf_ptr )
{
/* Copy the report into the local buffer. */
auth_uim_rsp_buf = *uim_rpt_buf_ptr;
/* set the command response signal */
MSG_LOW(" Recd Command Response Signal",0,0,0);
rex_set_sigs(&auth_tcb, AUTH_UIM_CMD_RSP_SIG);
} /* auth_uim_response_callback */
#endif /* FEATURE_UIM_RUIM */
/* <EJECT> */
/*===========================================================================
FUNCTION AUTH_PROCESS_COMMAND
DESCRIPTION
This procedure processes a command sent to the Authentication task. If
the FEATURE_UIM_RUIM is defined, it sets the RUIM state variable and does
not actually perform the AUTH computations.
DEPENDENCIES
None
RETURN VALUE
None
SIDE EFFECTS
If the command is AUTH_GENERATE_KEY_F, lots of CPU time will be taken
to do this huge calculation.
If FEATURE_UIM_RUIM is defined, it sets the RUIM state variable amongst others.
===========================================================================*/
LOCAL void auth_process_command
(
auth_cmd_type *cmd_ptr
/* Pointer to received command */
)
{
#if defined (FEATURE_AUTH) && (!defined(FEATURE_UIM_RUIM) || \
defined(FEATURE_UIM_RUN_TIME_ENABLE))
static dword authbs;
/* Value computed internally during SSD Update, compared to BS version */
nv_item_type nv_item;
/* Item to hold values retrieved from NV */
boolean return_status;
/* Status to be returned for Finish SSD Update or Update A Key */
dword auth_sig;
/* Auth signature value returned from CAVE */
#endif /* FEATURE_AUTH && (!FEATURE_UIM_RUIM || FEATURE_UIM_RUN_TIME_ENABLE) */
#ifdef FEATURE_UIM_RUIM
uim_cmd_type *uim_cmd_ptr;
/* UIM command pointer points to UIM command buffer for sending commands
to the UIM server. */
uim_rpt_type *uim_rpt_ptr = &auth_uim_rsp_buf;
/* Pointer to UIM report */
#endif /* FEATURE_UIM_RUIM */
/*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/
/* Copy command to local buffer */
#if !defined( FEATURE_UIM_RUIM ) || defined( FEATURE_UIM_RUN_TIME_ENABLE )
#if defined( FEATURE_UIM_RUN_TIME_ENABLE )
/* Determine if the R-UIM is available for this NAM */
if (!nv_rtre_use_ruim_for_nam(auth_stored_NAM_index))
#endif /* FEATURE_UIM_RUN_TIME_ENABLE */
{
if ((auth_init_status == AUTH_UNINITIALIZED) &&
((cmd_ptr->hdr.command != AUTH_INIT_F) &&
(cmd_ptr->hdr.command != AUTH_UPDATE_A_KEY_F) &&
(cmd_ptr->hdr.command != AUTH_RESYNC_F) &&
(cmd_ptr->hdr.command != AUTH_RESET_F)))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -