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

shw_driver.c File Reference


Detailed Description

This is the user-mode driver code for the FSL Security Hardware (SHW) API. as well as the 'common' FSL SHW API code for kernel API users.

Its interaction with the Linux kernel is from calls to shw_init() when the driver is loaded, and shw_shutdown() should the driver be unloaded.

The User API (driver interface) is handled by the following functions:

The driver also provides the following functions for kernel users of the FSL SHW API: All other functions are internal to the driver.

The life of the driver starts at boot (or module load) time, with a call by the kernel to shw_init().

The life of the driver ends when the kernel is shutting down (or the driver is being unloaded). At this time, shw_shutdown() is called. No function will ever be called after that point.

In the case that the driver is reloaded, a new copy of the driver, with fresh global values, etc., is loaded, and there will be a new call to shw_init().

In user mode, the user's fsl_shw_register_user() call causes an open() event on the driver followed by a ioctl() with the registration information. Any subsequent API calls by the user are handled through the ioctl() function and shuffled off to the appropriate routine (or driver) for service. The fsl_shw_deregister_user() call by the user results in a close() function call on the driver.

In kernel mode, the driver provides the functions fsl_shw_register_user(), fsl_shw_deregister_user(), fsl_shw_get_capabilities(), and fsl_shw_get_results(). Other parts of the API are provided by other drivers, if available, to support the cryptographic functions.

Definition in file shw_driver.c.

#include "portable_os.h"
#include "fsl_shw.h"
#include "fsl_shw_keystore.h"
#include "shw_internals.h"
#include <linux/mxc_scc_driver.h>

Go to the source code of this file.

Defines

#define FALSE   0
#define TRUE   1

Functions

static os_error_code add_entropy (fsl_shw_uco_t *user_ctx, void *user_mode_add_entropy_req)
fsl_shw_return_t alloc_slot (fsl_shw_uco_t *user_ctx, fsl_shw_sko_t *key_info)
static void * copy_array (void *userloc, void *userend, void *data_start, unsigned element_size, unsigned element_count)
static os_error_code copy_fsl_code (void *user_header, fsl_shw_return_t result_code)
fsl_shw_return_t dealloc_slot (fsl_shw_uco_t *user_ctx, fsl_shw_sko_t *key_info)
fsl_shw_return_t do_scc_decrypt_region (fsl_shw_uco_t *user_ctx, void *partition_base, uint32_t offset_bytes, uint32_t byte_count, const uint8_t *black_data, uint32_t *IV, fsl_shw_cypher_mode_t cypher_mode)
fsl_shw_return_t do_scc_encrypt_region (fsl_shw_uco_t *user_ctx, void *partition_base, uint32_t offset_bytes, uint32_t byte_count, uint8_t *black_data, uint32_t *IV, fsl_shw_cypher_mode_t cypher_mode)
fsl_shw_return_t do_system_keystore_slot_alloc (fsl_shw_uco_t *user_ctx, uint32_t key_length, uint64_t ownerid, uint32_t *slot)
fsl_shw_return_t do_system_keystore_slot_dealloc (fsl_shw_uco_t *user_ctx, uint64_t ownerid, uint32_t slot)
fsl_shw_return_t do_system_keystore_slot_decrypt (fsl_shw_uco_t *user_ctx, uint64_t ownerid, uint32_t slot, uint32_t key_length, const uint8_t *black_data)
fsl_shw_return_t do_system_keystore_slot_encrypt (fsl_shw_uco_t *user_ctx, uint64_t ownerid, uint32_t slot, uint32_t key_length, uint8_t *black_data)
fsl_shw_return_t do_system_keystore_slot_load (fsl_shw_uco_t *user_ctx, uint64_t ownerid, uint32_t slot, const uint8_t *key, uint32_t key_length)
fsl_shw_return_t do_system_keystore_slot_read (fsl_shw_uco_t *user_ctx, uint64_t ownerid, uint32_t slot, uint32_t key_length, uint8_t *key_data)
fsl_shw_return_t fsl_shw_add_entropy (fsl_shw_uco_t *user_ctx, uint32_t length, uint8_t *data)
fsl_shw_return_t fsl_shw_auth_decrypt (fsl_shw_uco_t *user_ctx, fsl_shw_acco_t *auth_ctx, fsl_shw_sko_t *cipher_key_info, fsl_shw_sko_t *auth_key_info, uint32_t auth_data_length, const uint8_t *auth_data, uint32_t payload_length, const uint8_t *ct, const uint8_t *auth_value, uint8_t *payload)
 Authenticate and decrypt a (CCM) stream.
fsl_shw_return_t fsl_shw_deregister_user (fsl_shw_uco_t *user_ctx)
fsl_shw_return_t fsl_shw_diminish_perms (fsl_shw_uco_t *user_ctx, void *address, uint32_t permissions)
fsl_shw_return_t fsl_shw_gen_encrypt (fsl_shw_uco_t *user_ctx, fsl_shw_acco_t *auth_ctx, fsl_shw_sko_t *cipher_key_info, fsl_shw_sko_t *auth_key_info, uint32_t auth_data_length, const uint8_t *auth_data, uint32_t payload_length, const uint8_t *payload, uint8_t *ct, uint8_t *auth_value)
fsl_shw_return_t fsl_shw_gen_random_pf_key (fsl_shw_uco_t *user_ctx)
fsl_shw_pco_tfsl_shw_get_capabilities (fsl_shw_uco_t *user_ctx)
fsl_shw_return_t fsl_shw_get_random (fsl_shw_uco_t *user_ctx, uint32_t length, uint8_t *data)
fsl_shw_return_t fsl_shw_get_results (fsl_shw_uco_t *user_ctx, unsigned result_size, fsl_shw_result_t results[], unsigned *result_count)
fsl_shw_return_t fsl_shw_hash (fsl_shw_uco_t *user_ctx, fsl_shw_hco_t *hash_ctx, const uint8_t *msg, uint32_t length, uint8_t *result, uint32_t result_len)
fsl_shw_return_t fsl_shw_hmac (fsl_shw_uco_t *user_ctx, fsl_shw_sko_t *key_info, fsl_shw_hmco_t *hmac_ctx, const uint8_t *msg, uint32_t length, uint8_t *result, uint32_t result_len)
fsl_shw_return_t fsl_shw_hmac_precompute (fsl_shw_uco_t *user_ctx, fsl_shw_sko_t *key_info, fsl_shw_hmco_t *hmac_ctx)
fsl_shw_return_t fsl_shw_register_user (fsl_shw_uco_t *user_ctx)
fsl_shw_return_t fsl_shw_sfree (fsl_shw_uco_t *user_ctx, void *address)
void * fsl_shw_smalloc (fsl_shw_uco_t *user_ctx, uint32_t size, const uint8_t *UMID, uint32_t permissions)
fsl_shw_return_t fsl_shw_sstatus (fsl_shw_uco_t *user_ctx, void *address, fsl_shw_partition_status_t *part_status)
static os_error_code get_capabilities (fsl_shw_uco_t *user_ctx, void *user_mode_pco_request)
static os_error_code get_random (fsl_shw_uco_t *user_ctx, void *user_mode_get_random_req)
static os_error_code get_results (fsl_shw_uco_t *user_ctx, void *user_mode_results_req)
static os_error_code init_uco (fsl_shw_uco_t *user_ctx, void *user_mode_uco)
fsl_shw_return_t load_slot (fsl_shw_uco_t *user_ctx, fsl_shw_sko_t *key_info, const uint8_t *key)
 OS_DEV_CLOSE (shw_release)
 OS_DEV_INIT (shw_init)
 OS_DEV_INIT_DCL (shw_init)
 OS_DEV_IOCTL (shw_ioctl)
 OS_DEV_IOCTL_DCL (shw_ioctl)
 OS_DEV_MMAP (shw_mmap)
 OS_DEV_MMAP_DCL (shw_mmap)
 OS_DEV_OPEN (shw_open)
 OS_DEV_SHUTDOWN (shw_shutdown)
 OS_DEV_SHUTDOWN_DCL (shw_shutdown)
static void process_hdr (fsl_shw_uco_t *user_ctx, struct shw_req_header *hdr)
static void shw_cleanup (void)
static os_error_code shw_handle_scc_decrypt (fsl_shw_uco_t *user_ctx, uint32_t info)
static os_error_code shw_handle_scc_drop_perms (fsl_shw_uco_t *user_ctx, uint32_t info)
static os_error_code shw_handle_scc_encrypt (fsl_shw_uco_t *user_ctx, uint32_t info)
static os_error_code shw_handle_scc_sfree (fsl_shw_uco_t *user_ctx, uint32_t info)
static os_error_code shw_handle_scc_sstatus (fsl_shw_uco_t *user_ctx, uint32_t info)
static os_error_code shw_setup_user_driver_interaction (void)
static void shw_user_callback (fsl_shw_uco_t *user_ctx)

Variables

static fsl_shw_pco_t cap
static fsl_shw_hash_alg_t pf_hashes []
static fsl_shw_sym_mode_t pf_modes []
static fsl_shw_key_alg_t pf_syms []
static os_driver_reg_t reg_handle
static int shw_device_registered = 0
static int shw_major_node = SHW_MAJOR_NODE
os_lock_t shw_queue_lock = NULL
fsl_shw_kso_t system_keystore
fsl_shw_uco_tuser_list


Generated by  Doxygen 1.6.0   Back to index