Exemplo n.º 1
0
/*!
 * Deallocates a slot in the SCC
 *
 * @brief    Deallocates a slot in the SCC
 *
 * @param    user_ctx
 * @param    ownerid
 * @param    slot
 * @param    key_length
 * @param    black_data
 *
 * @return    A return code of type #fsl_shw_return_t.
 */
fsl_shw_return_t do_scc_slot_decrypt(fsl_shw_uco_t * user_ctx,
				     uint64_t ownerid,
				     uint32_t slot,
				     uint32_t key_length,
				     const uint8_t * black_data)
{
	scc_return_t scc_code;

	user_ctx = NULL;	/* for unused-param warning */
	scc_code = scc_decrypt_slot(ownerid, slot, key_length, black_data);
	return (scc_code == SCC_RET_OK) ? FSL_RETURN_OK_S : FSL_RETURN_ERROR_S;
}
Exemplo n.º 2
0
fsl_shw_return_t
keystore_slot_decrypt(fsl_shw_uco_t *user_ctx, fsl_shw_kso_t *keystore,
		      uint64_t owner_id, uint32_t slot, uint32_t length,
		      const uint8_t *source)
{

#ifdef FSL_HAVE_SCC2
	LOCK_INCLUDES;
	fsl_shw_return_t retval = FSL_RETURN_ERROR_S;
	uint32_t slot_length;
	uint32_t IV[4];
	uint32_t *iv_ptr = (uint32_t *) & (owner_id);

    /* Build the IV */
    IV[0] = iv_ptr[0];
	IV[1] = iv_ptr[1];
	IV[2] = 0;
	IV[3] = 0;
	ACQUIRE_LOCK;

	/* Call scc decrypt function to decrypt the data. */

	/* Ensure that the data will fit in the key slot */
	    slot_length =
	    keystore->slot_get_slot_size(keystore->user_data, slot);
	if (length > slot_length)
		goto out;

	/* Call scc decrypt function to encrypt the data. */
	    retval = do_scc_decrypt_region(user_ctx,
					   (void *)keystore->
					   slot_get_base(keystore->user_data,
							 slot),
					   keystore->slot_get_offset(keystore->
								      user_data,
								      slot),
					   length, source, IV,
					   FSL_SHW_CYPHER_MODE_CBC);
	goto out;
out:RELEASE_LOCK;
	return retval;

#else
	scc_return_t retval;
	retval = scc_decrypt_slot(owner_id, slot, length, source);
	if (retval == SCC_RET_OK)
		return FSL_RETURN_OK_S;
	return FSL_RETURN_ERROR_S;

#endif	/* FSL_HAVE_SCC2 */
}