Exemplo n.º 1
0
fsl_shw_return_t
keystore_load_slot(fsl_shw_kso_t * keystore, uint64_t owner_id, uint32_t slot,
		   const uint8_t * key_data, uint32_t key_length)
{

#ifdef FSL_HAVE_SCC2
	    LOCK_INCLUDES;
	fsl_shw_return_t retval = FSL_RETURN_ERROR_S;
	uint32_t slot_size;
	uint32_t i;
	uint8_t * slot_location;
	ACQUIRE_LOCK;
	if ((keystore->slot_verify_access == NULL) ||
	      (keystore->user_data == NULL))
		goto out;
	if (keystore->
	      slot_verify_access(keystore->user_data, owner_id,
				 slot) !=FSL_RETURN_OK_S) {
		retval = FSL_RETURN_AUTH_FAILED_S;
		goto out;
	}
	slot_size = keystore->slot_get_slot_size(keystore->user_data, slot);
	if (key_length > slot_size) {
		retval = FSL_RETURN_BAD_DATA_LENGTH_S;
		goto out;
	}
	slot_location = keystore->slot_get_address(keystore->user_data, slot);
	for (i = 0; i < key_length; i++) {
		slot_location[i] = key_data[i];
	}
	retval = FSL_RETURN_OK_S;
out:RELEASE_LOCK;
	return retval;

#else	/* FSL_HAVE_SCC2 */
	fsl_shw_return_t retval;
	scc_return_t scc_ret;
	scc_ret =
	    scc_load_slot(owner_id, slot, (uint8_t *) key_data, key_length);
	switch (scc_ret) {
	case SCC_RET_OK:
		retval = FSL_RETURN_OK_S;
		break;
	case SCC_RET_VERIFICATION_FAILED:
		retval = FSL_RETURN_AUTH_FAILED_S;
		break;
	case SCC_RET_INSUFFICIENT_SPACE:
		retval = FSL_RETURN_BAD_DATA_LENGTH_S;
		break;
	default:
		retval = FSL_RETURN_ERROR_S;
	}
	return retval;

#endif	/* FSL_HAVE_SCC2 */
}
Exemplo n.º 2
0
/*!
 * Populate a slot in the SCC
 *
 * @brief    Deallocates a slot in the SCC
 *
 * @param   user_ctx
 * @param   uint32_t slot
 * @param   key
 * @param   key_length
 *
 * @return    A return code of type #fsl_shw_return_t.
 */
fsl_shw_return_t do_scc_slot_load_slot(fsl_shw_uco_t * user_ctx,
				       uint64_t ownerid, uint32_t slot,
				       const uint8_t * key, uint32_t key_length)
{
	scc_return_t scc_status = scc_load_slot(ownerid, slot, (void *)key,
						key_length);
	user_ctx = NULL;
	return (scc_status ==
		SCC_RET_OK) ? FSL_RETURN_OK_S : FSL_RETURN_ERROR_S;
}