⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 auth.c

📁 brew代码里面的一个文件
💻 C
📖 第 1 页 / 共 5 页
字号:
      break;

    case AUTH_START_TIMER_F:
      {
        /* Inform the client that the command has been 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 );
        }

        /* Set timer in case the Base Station leaves us hanging */
        MSG_MED( "Setting SSD timer", 0, 0, 0 );
        (void) rex_set_timer( &auth_ssd_timer, CAI_T64M );
      } /* end case - AUTH_START_TIMER_F */
      break;

    case AUTH_RESET_F:
      {
        /* Inform the client that the command has been 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 );
        }

        /* -------------------------------------------------------------
        ** Initialize boolean indicators.  This allows us to detect when
        ** operations are done out of order i.e. a key generation before
        ** keys are saved or an encryption request before keys are
        ** generated.
        ** ------------------------------------------------------------- */
        auth_saved_registers = FALSE;
        auth_valid_CMEA_key = FALSE;
        auth_valid_PLCM = FALSE;
        MSG_MED( "AUTH state reset", 0, 0, 0 );
      } /* end case - AUTH_RESET_F */
      break;

    case AUTH_RESYNC_F:
      {
        /* Inform the client that the command has been 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 );
        }
        if (cmd_ptr->resync.rpt_function != NULL)
        {
          auth_rpt_buf.rpt_type = AUTH_RESYNC_R;

          /* Fill in necessary fields of command block */
          auth_rpt_buf.rpt_hdr.task_ptr = NULL;

          /* --------------------------------
          ** Queue report for requesting task
          ** -------------------------------- */
          (*(cmd_ptr->resync.rpt_function))( &auth_rpt_buf );
          MSG_MED( "AUTH synchronized", 0, 0, 0 );
        }
      } /* end case - AUTH_RESYNC_F */
      break;

#ifdef FEATURE_UIM_RUIM
    case AUTH_BS_CHAL_F:
      {
        /* We do not want the RUIM to power down as the SSD update is in
           progress and RANDBS is in temporary memory in the SIM */
        uim_power_control ( UIM_AUTH, TRUE );
        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 );
        }
        /* 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_BS_CHAL_F;
          uim_cmd_ptr->bs_chal.randseed = cmd_ptr->chal.randseed;

          /* Send the command and wait for the response. */
          auth_send_uim_command(uim_cmd_ptr);

          /* Report back that Access was completed, if requested */
          if (cmd_ptr->chal.rpt_function != NULL)
          {
             auth_rpt_buf.rpt_type = AUTH_BS_CHAL_R;

             /* Copy the UIM response to the report buffer. */
             auth_rpt_buf.rpt_status = uim_rpt_ptr->rpt_status;
             auth_rpt_buf.rpt.randbs = uim_rpt_ptr->rpt.bs_chal.randbs;

             /* Fill in necessary fields of command block */
             auth_rpt_buf.rpt_hdr.task_ptr = NULL;

             /* Report to the Requesting task */
             (*(cmd_ptr->chal.rpt_function))( &auth_rpt_buf );
             MSG_MED( "Reporting RUIM Access", 0, 0, 0 );

          } /* (cmd_ptr->access_ruim.rpt_function != NULL) */
        }
        else /* No UIM command buffers on the free queue. */
        {
          ERR( "No free buffers on uim_free_q", 0, 0, 0 );
        } /* Get a UIM command buffer from the UIM free queue. */
        MSG_MED( "Received Base station Challenge command ", 0, 0, 0 );
      } /* end case - AUTH_BS_CHAL_F */
    break;
#endif /* FEATURE_UIM_RUIM */

#if !defined( FEATURE_UIM_RUIM ) || defined( FEATURE_UIM_RUN_TIME_ENABLE )
    case AUTH_UPDATE_A_KEY_TEMP_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 );
      }

      /* copy the contents of temp_a_key in the command to a_key_temp */
      qw_equ(a_key_temp, cmd_ptr->temp.a_key);

      a_key_temp_valid = TRUE;

      if (cmd_ptr->temp.rpt_function != NULL)
      {
        auth_rpt_buf.rpt_type = AUTH_UPDATE_A_KEY_TEMP_R;

        /* Fill in necessary fields of command block */
        auth_rpt_buf.rpt_hdr.task_ptr = NULL;

        /* --------------------------------
        ** Queue report for requesting task
        ** -------------------------------- */
        (*(cmd_ptr->temp.rpt_function))( &auth_rpt_buf );
        MSG_MED( "Updating A_KEY_TEMP", 0, 0, 0 );
      }
      break;

    case AUTH_COMMIT_KEYS_F:

      cmd_ptr->hdr.status = AUTH_RECEIVED_S;

      /* update the SSD */
      if (new_ssd_valid)
         (void) CAVE_update_SSD();

      return_status = CAVE_update_A_key_683( a_key_temp,
                              cmd_ptr->commit_keys.nam_index );

      /* We use the report in otasp to check the result of A-Key commit */
      if (cmd_ptr->commit_keys.rpt_function != NULL)
      {
          auth_rpt_buf.rpt_type = AUTH_COMMIT_KEYS_R;

          /* Fill in necessary fields of command block */
          auth_rpt_buf.rpt_hdr.task_ptr = NULL;

          auth_rpt_buf.rpt.commit_keys_ok = return_status;

          /* --------------------------------
          ** Queue report for requesting task
          ** -------------------------------- */
          (*(cmd_ptr->commit_keys.rpt_function))( &auth_rpt_buf );
          MSG_MED( "Reporting keys committed", 0, 0, 0 );
      }

      /* If specified in request then signal the requesting task. */
      /* signal MC that committing has been done */
      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 );
      }

      break;

#ifdef FEATURE_OTASP_OTAPA
    case AUTH_SIGNATURE_SPASM_F:

      MSG_MED("Process AUTH_SIG_SPASM_F", 0,0,0);

      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 );
      }

      /* ------------------------------------------------------------
      ** We use the SSD_A from NV, so use_new_ssd is set to FALSE.
      ** Save_registers parameter is FALSE. See IS-683A 3.3.7.
      ** ------------------------------------------------------------ */
      auth_sig = CAVE_auth_signature( cmd_ptr->sig.rand_chal,
            cmd_ptr->sig.auth_data, FALSE, FALSE, TRUE );

      MSG_MED("rand %lx, auth_data %lx",
              cmd_ptr->sig.rand_chal, cmd_ptr->sig.auth_data, 0);

      MSG_MED("new_ssd FALSE, save_reg FALSE, val_spasm TRUE",0,0,0);

      /* Report back auth signature, if requested */
      if (cmd_ptr->sig.rpt_function != NULL)
      {
         auth_rpt_buf.rpt_type = AUTH_SIGNATURE_SPASM_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 );
      }

      break;
#endif /* FEATURE_OTASP_OTAPA */

#endif /* !FEATURE_UIM_RUIM || FEATURE_UIM_RUN_TIME_ENABLE */
#endif /* FEATURE_AUTH */

#ifdef FEATURE_UIM_RUIM
    case AUTH_ACCESS_RUIM_F:
      {
        /* Inform the client that the command has been 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 );
        }
        /* 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.item = cmd_ptr->access_ruim.item;
          uim_cmd_ptr->access_uim.access = cmd_ptr->access_ruim.access;
          uim_cmd_ptr->access_uim.rec_mode = UIM_ABSOLUTE;
          uim_cmd_ptr->access_uim.num_bytes = cmd_ptr->access_ruim.num_bytes;
          uim_cmd_ptr->access_uim.offset = cmd_ptr->access_ruim.offset;
          uim_cmd_ptr->access_uim.data_ptr = cmd_ptr->access_ruim.data_ptr;

          /* Send the command and wait for the response. */
          auth_send_uim_command(uim_cmd_ptr);

          /* Report back that Access was completed, if requested */
          if (cmd_ptr->access_ruim.rpt_function != NULL)
          {
             auth_rpt_buf.rpt_type = AUTH_ACCESS_RUIM_R;

             /* Copy the UIM response to the report buffer. */
             auth_rpt_buf.rpt_status = uim_rpt_ptr->rpt_status;

             /* Fill in the number of bytes in the response that we got
                from RUIM into the NV command */
             cmd_ptr->access_ruim.num_bytes_rsp =
               uim_cmd_ptr->access_uim.num_bytes_rsp;

             /* The data is already copied to the client buffer as a result
                of copying the data_ptr from the client auth command to the
                UIM command above.  The UIM server copies the data to the
                client buffer. */

             /* Fill in necessary fields of command block */
             auth_rpt_buf.rpt_hdr.task_ptr = NULL;

             /* Report to the Requesting task */
             (*(cmd_ptr->access_ruim.rpt_function))( &auth_rpt_buf );
             MSG_MED( "Reporting RUIM Access", 0, 0, 0 );

          } /* (cmd_ptr->access_ruim.rpt_function != NULL) */
        }
        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. */
        MSG_MED( "Received RUIM Access command ", 0, 0, 0 );
      } /* end case - AUTH_ACCESS_RUIM_F */
      break;

    case AUTH_RUIM_STATUS_F:
      {
        /* Inform the client that the command has been 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 );
        }
        /* Retrieve a UIM command buffer from the queue. */
        if ((uim_cmd_ptr = (uim_cmd_type*) q_get( &uim_free_q )) != NULL)
        {
          uim_cmd_ptr->status.hdr.command = UIM_STATUS_F;

          /* Send the command and wait for the response. */
          auth_send_uim_command(uim_cmd_ptr);

          /* Report back that Access was completed, if requested */
          if (cmd_ptr->status.rpt_function != NULL)
          {
            auth_rpt_buf.rpt_type = AUTH_RUIM_STATUS_R;

            /* Copy the UIM response to the 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 the Requesting task */
            (*(cmd_ptr->status.rpt_function))( &auth_rpt_buf );
            MSG_MED( "Reporting RUIM Access", 0, 0, 0 );

          } /* (cmd_ptr->access_ruim.rpt_function != NULL) */
        }
        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. */
        MSG_MED( "Received RUIM STATUS command ", 0, 0, 0 );
      } /* end case - AUTH_RUIM_STATUS_F */
      break;

#endif /* FEATURE_UIM_RUIM */

    default:
      ERR_FATAL( "Unknown command to AUTH %d", cmd_ptr->hdr.command, 0, 0);
    break;

  } /* end switch (command_type) */

} /* auth_process_command() */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -