📄 auth.c
字号:
if (cmd_ptr->sig.process_control & RUIM_SAVE_REGS_ON)
{
auth_saved_registers = TRUE;
}
else
{
auth_saved_registers = FALSE;
}
}
else /* The run CAVE command failed. */
{
/* The registers were NOT saved. */
auth_saved_registers = FALSE;
}
/* -------------------------------------
** Now, if required, send the signature
** back
** ------------------------------------- */
if (cmd_ptr->sig.rpt_function != NULL)
{
/* Assign the report type */
auth_rpt_buf.rpt_type = AUTH_SIGNATURE_R;
/* Copy the UIM response to the report buffer. */
auth_rpt_buf.rpt_status = uim_rpt_ptr->rpt_status;
auth_rpt_buf.rpt.auth = uim_rpt_ptr->rpt.run_cave.auth;
/* Fill in necessary fields of command block */
auth_rpt_buf.rpt_hdr.task_ptr = NULL;
/* Report to requesting task */
(*(cmd_ptr->sig.rpt_function))( &auth_rpt_buf );
MSG_MED( "Reporting auth Signature %ld",
auth_rpt_buf.rpt.auth, 0, 0 );
} /* end if - the client supplied a reportback function. */
}
else /* No UIM command buffers on the free queue. */
{
ERR( "No free buffers on auth_free_q", 0, 0, 0 );
} /* Get a UIM command buffer from the UIM free queue. */
}
#if defined( FEATURE_UIM_RUN_TIME_ENABLE )
else /* R-UIM is not available */
#endif /* FEATURE_UIM_RUN_TIME_ENABLE */
#endif /* FEATURE_UIM_RUIM */
#if !defined( FEATURE_UIM_RUIM ) || defined( FEATURE_UIM_RUN_TIME_ENABLE )
{
/* indicate that the new ssd values need to be used if they
** have been generated using the new a-key*/
if (new_ssd_valid)
{
auth_sig = CAVE_auth_signature( cmd_ptr->sig.rand_chal,
cmd_ptr->sig.auth_data, TRUE, cmd_ptr->sig.save_reg
#ifdef FEATURE_OTASP_OTAPA
, FALSE // Not for SPASM
#endif
);
/* set to TRUE since new ssd values have been used to compute
AUTHR */
used_new_ssd = TRUE;
}
else
{
auth_sig = CAVE_auth_signature( cmd_ptr->sig.rand_chal,
cmd_ptr->sig.auth_data, FALSE, cmd_ptr->sig.save_reg
#ifdef FEATURE_OTASP_OTAPA
, FALSE // Not for SPASM
#endif
);
used_new_ssd = FALSE;
}
/* ------------------------------------------------------------
** If we saved the register values, set saved_registers to TRUE
** to indicate we are ready to generate CMEA key and VPM.
** ------------------------------------------------------------ */
if (cmd_ptr->sig.save_reg)
{
auth_saved_registers = TRUE;
}
/* Report back auth signature, if requested */
if (cmd_ptr->sig.rpt_function != NULL)
{
/* Retrieve the UIM response from the UIM report buffer. */
auth_rpt_buf.rpt_type = AUTH_SIGNATURE_R;
auth_rpt_buf.rpt.auth = auth_sig;
/* Fill in necessary fields of command block */
auth_rpt_buf.rpt_hdr.task_ptr = NULL;
/* --------------------------------
** Queue report for requesting task
** -------------------------------- */
(*(cmd_ptr->sig.rpt_function))( &auth_rpt_buf );
MSG_MED( "Reporting auth %ld", auth_rpt_buf.rpt.auth, 0, 0 );
}
}
#endif /* !FEATURE_UIM_RUIM || FEATURE_UIM_RUN_TIME_ENABLE */
MSG_MED( "Received Auth Signature command ", 0, 0, 0 );
} /* end case - AUTH_SIGNATURE_F */
break;
case AUTH_GENERATE_KEY_F:
{
/* Determine if the auth registers were saved from the last
RUN CAVE command. */
if (!auth_saved_registers)
{
/* The registers were NOT saved. Generate keys will fail.
Inform the client the command failed. */
ERR( "Need to call auth_signature first", 0, 0, 0);
cmd_ptr->hdr.status = AUTH_INVALID_S;
if (cmd_ptr->hdr.cmd_hdr.task_ptr != NULL)
{
(void) rex_set_sigs( cmd_ptr->hdr.cmd_hdr.task_ptr,
cmd_ptr->hdr.cmd_hdr.sigs );
}
/* Indicate the keys are no longer valid. */
auth_valid_CMEA_key = FALSE;
auth_valid_PLCM = FALSE;
}
else
{
/* Inform the client that the command was received */
cmd_ptr->hdr.status = AUTH_RECEIVED_S;
if (cmd_ptr->hdr.cmd_hdr.task_ptr != NULL)
{
(void) rex_set_sigs( cmd_ptr->hdr.cmd_hdr.task_ptr,
cmd_ptr->hdr.cmd_hdr.sigs );
}
#ifdef FEATURE_UIM_RUIM
#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 */
{
/* Retrieve a UIM command buffer from the queue. */
if ((uim_cmd_ptr = (uim_cmd_type*) q_get( &uim_free_q )) != NULL)
{
uim_cmd_ptr->hdr.command = UIM_GENERATE_KEYS_F;
uim_cmd_ptr->gen_keys.vpm_first_octet = cmd_ptr->key.vpm_first_octet;
uim_cmd_ptr->gen_keys.vpm_last_octet = cmd_ptr->key.vpm_last_octet;
/* Send the command and wait for the response. */
auth_send_uim_command(uim_cmd_ptr);
/* Determine if the run CAVE command passed. */
if (uim_rpt_ptr->rpt_status == UIM_PASS)
{
/* With the new interface, we always compute the VPM */
/* Indocate that the keys are now valid. */
auth_valid_PLCM = TRUE;
auth_valid_CMEA_key = TRUE;
/* Update CAVE with CMEA and VPM keys */
CAVE_update_keys(uim_rpt_ptr->rpt.generate_keys.data);
}
else /* The run CAVE command failed. */
{
/* The command failed, so the keys are NOT valid. */
auth_valid_PLCM = FALSE;
auth_valid_CMEA_key = FALSE;
} /* end if - the command passed */
/* -------------------------------------
** Now, if required, send the signature
** back
** ------------------------------------- */
if (cmd_ptr->key.rpt_function != NULL)
{
/* Assign the report type */
auth_rpt_buf.rpt_type = AUTH_GENERATE_KEY_R;
/* Retrieve the UIM response from the UIM report buffer. */
auth_rpt_buf.rpt_status = uim_rpt_ptr->rpt_status;
/* Fill in necessary fields of command block */
auth_rpt_buf.rpt_hdr.task_ptr = NULL;
/* Report to requesting task */
(*(cmd_ptr->key.rpt_function))( &auth_rpt_buf );
MSG_MED( "Reporting keys generated", 0, 0, 0 );
} /* end if - the client supplied a reportback function. */
}
else /* No UIM command buffers on the free queue. */
{
ERR( "No free buffers on auth_free_q", 0, 0, 0 );
} /* Get a UIM command buffer from the UIM free queue. */
}
#if defined( FEATURE_UIM_RUN_TIME_ENABLE )
else /* R-UIM is not available */
#endif /* FEATURE_UIM_RUN_TIME_ENABLE */
#endif /* FEATURE_UIM_RUIM */
#if !defined( FEATURE_UIM_RUIM ) || defined( FEATURE_UIM_RUN_TIME_ENABLE )
{
/* Full key generation takes 100+ms of CPU time */
/* It sets auth_valid_CMEA_key as soon as the key is valid */
/* Variable used_new_ssd is sent as a parameter */
if (used_new_ssd)
{
CAVE_generate_key( cmd_ptr->key.do_vpm, &auth_valid_CMEA_key, TRUE );
MSG_HIGH( "Keys generated with new SSD", 0, 0, 0);
}
else
{
CAVE_generate_key( cmd_ptr->key.do_vpm, &auth_valid_CMEA_key, FALSE );
MSG_HIGH( "Keys generated", 0, 0, 0);
}
/* If we were told to calculate the VPM, then our PLCM is valid */
auth_valid_PLCM = cmd_ptr->key.do_vpm;
/* Report back that keys are generated, if requested */
if (cmd_ptr->key.rpt_function != NULL)
{
auth_rpt_buf.rpt_type = AUTH_GENERATE_KEY_R;
/* Fill in necessary fields of command block */
auth_rpt_buf.rpt_hdr.task_ptr = NULL;
/* --------------------------------
** Queue report for requesting task
** -------------------------------- */
(*(cmd_ptr->key.rpt_function))( &auth_rpt_buf );
MSG_MED( "Reporting keys generated", 0, 0, 0 );
}
}
#endif /* !FEATURE_UIM_RUIM || FEATURE_UIM_RUN_TIME_ENABLE */
} /* end if - the auth registers were saved. */
} /* end case - AUTH_GENERATE_KEY_F */
break;
#if !defined( FEATURE_UIM_RUIM ) || defined( FEATURE_UIM_RUN_TIME_ENABLE )
case AUTH_UPDATE_A_KEY_F:
{
cmd_ptr->hdr.status = AUTH_RECEIVED_S;
if (cmd_ptr->hdr.cmd_hdr.task_ptr != NULL)
{
(void) rex_set_sigs( cmd_ptr->hdr.cmd_hdr.task_ptr,
cmd_ptr->hdr.cmd_hdr.sigs );
}
if (CAVE_update_A_key( cmd_ptr->a_key.a_key,
cmd_ptr->a_key.nam ))
{
/* Re-initialize everything following A_key change */
auth_var_init( cmd_ptr->a_key.nam );
auth_init_status = CAVE_init( cmd_ptr->a_key.nam );
return_status = TRUE;
}
else
{
return_status = FALSE;
}
/* ------------------------------------------
** Now if a report was requested, report back
** whether or not A-KEY update was successful.
** ------------------------------------------ */
if (cmd_ptr->a_key.rpt_function != NULL)
{
auth_rpt_buf.rpt_type = AUTH_A_KEY_R;
auth_rpt_buf.rpt.a_key_update_ok = return_status;
/* Fill in necessary fields of command block */
auth_rpt_buf.rpt_hdr.task_ptr = NULL;
/* Queue report for requesting task */
(*(cmd_ptr->a_key.rpt_function))( &auth_rpt_buf );
MSG_MED( "Reporting A-key update complete", 0, 0, 0 );
}
} /* end case - AUTH_UPDATE_A_KEY_F */
break;
#endif /* !FEATURE_UIM_RUIM || FEATURE_UIM_RUN_TIME_ENABLE */
case AUTH_INC_COUNT_F:
{
/* Inform the client that the command was received */
cmd_ptr->hdr.status = AUTH_RECEIVED_S;
if (cmd_ptr->hdr.cmd_hdr.task_ptr != NULL)
{
(void) rex_set_sigs( cmd_ptr->hdr.cmd_hdr.task_ptr,
cmd_ptr->hdr.cmd_hdr.sigs );
}
#ifdef FEATURE_UIM_RUIM
#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 */
{
/* Treat this command as a write to Call Count */
/* Use a temporary buffer to hold the call count. */
temp_auth_count = (auth_count + 1) & RUIM_CC_MASK;
/* Retrieve a UIM command buffer from the queue. */
if ((uim_cmd_ptr = (uim_cmd_type*) q_get( &uim_free_q )) != NULL)
{
uim_cmd_ptr->access_uim.hdr.command = UIM_ACCESS_F;
uim_cmd_ptr->access_uim.num_bytes = 1; /* One byte in size */
uim_cmd_ptr->access_uim.offset = 1; /* Second byte */
uim_cmd_ptr->access_uim.rec_mode = UIM_PREVIOUS;
uim_cmd_ptr->access_uim.data_ptr = (byte *)&(temp_auth_count);
uim_cmd_ptr->access_uim.item = UIM_CDMA_CC; /* EF is "Call Count" */
uim_cmd_ptr->access_uim.access = UIM_WRITE_F; /* "Write" command */
/* Send the command and wait for the response. */
auth_send_uim_command(uim_cmd_ptr);
/* Determine if the run CAVE command passed. */
if (uim_rpt_ptr->rpt_status == UIM_PASS)
{
/* Copy the new call count to the call count buffer. */
auth_count = temp_auth_count & RUIM_CC_MASK;
} /* end if - the command passed */
}
else /* No UIM command buffers on the free queue. */
{
ERR( "No free buffers on auth_free_q", 0, 0, 0 );
} /* Get a UIM command buffer from the UIM free queue. */
}
#if defined( FEATURE_UIM_RUN_TIME_ENABLE )
else /* R-UIM is not available */
#endif /* FEATURE_UIM_RUN_TIME_ENABLE */
#endif /* FEATURE_UIM_RUIM */
#if !defined( FEATURE_UIM_RUIM ) || defined( FEATURE_UIM_RUN_TIME_ENABLE )
{
auth_count++;
/* Put new COUNTsp in NV */
nv_item.count.nam = auth_stored_NAM_index;
nv_item.count.count = auth_count;
auth_put_nv_item( NV_COUNT_I, &nv_item );
}
#endif /* !FEATURE_UIM_RUIM || FEATURE_UIM_RUN_TIME_ENABLE */
} /* end case - AUTH_INC_COUNT_F */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -