Logo Search packages:      
Sourcecode: linux-fsl-imx51 version File versions  Download package

scc_return_t scc_read_slot ( uint64_t  owner_id,
uint32_t  slot,
uint32_t  key_length,
uint8_t *  key_data 
)

Read a value from a slot.

Parameters:
owner_id Value of owner of slot
slot Handle of slot
key_length Length, in bytes, of key_data to copy from SCC.
key_data Location to write the key
Returns:
SCC_RET_OK on success. SCC_RET_FAIL will be returned if slot specified cannot be accessed for any reason, or SCC_RET_INSUFFICIENT_SPACE if key_length exceeds the size of the slot.

Definition at line 1967 of file mxc_scc.c.

References copy_from_scc(), scc_crypto_lock, scc_key_info, SCC_KEY_SLOT_SIZE, SCC_RET_FAIL, SCC_RET_OK, and SCM_RED_MEMORY.

{
      scc_return_t status;
      unsigned long irq_flags;

      /* ACQUIRE LOCK to prevent others from using SCC crypto */
      spin_lock_irqsave(&scc_crypto_lock, irq_flags);

      status = verify_slot_access(owner_id, slot, key_length);
      if ((status == SCC_RET_OK) && (key_data != NULL)) {
            status = SCC_RET_FAIL;  /* reset expectations */

            if (key_length > SCC_KEY_SLOT_SIZE) {
                  pr_debug
                      ("SCC: scc_read_slot() rejecting key of %d bytes.\n",
                       key_length);
                  status = SCC_RET_INSUFFICIENT_SPACE;
            } else {
                  if (copy_from_scc
                      (SCM_RED_MEMORY + scc_key_info[slot].offset,
                       key_data, key_length, NULL)) {
                        pr_debug("SCC: RED copy_from_scc() failed for"
                               " scc_read_slot()\n");
                  } else {
                        status = SCC_RET_OK;
                  }
            }
      }

      spin_unlock_irqrestore(&scc_crypto_lock, irq_flags);

      return status;
}                       /* scc_read_slot */


Generated by  Doxygen 1.6.0   Back to index