fsl_shw_return_t fsl_shw_read_key(fsl_shw_uco_t * user_ctx, fsl_shw_sko_t * key_info, uint8_t * key) { fsl_shw_return_t ret = FSL_RETURN_INTERNAL_ERROR_S; /* Only blocking mode calls are supported */ if (!(user_ctx->flags & FSL_UCO_BLOCKING_MODE)) { ret = FSL_RETURN_BAD_FLAG_S; goto out; } printk("Reading a key\n"); #ifdef DIAG_SECURITY_FUNC LOG_DIAG("Reading a key"); #endif if (key_info->flags & FSL_SKO_KEY_PRESENT) { memcpy(key_info->key, key, key_info->key_length); ret = FSL_RETURN_OK_S; } else if (key_info->flags & FSL_SKO_KEY_ESTABLISHED) { printk("key established\n"); if (key_info->keystore == NULL) { printk("keystore is null\n"); /* First verify that the key access is valid */ ret = system_keystore.slot_verify_access(system_keystore. user_data, key_info->userid, key_info-> handle); printk("key in system keystore\n"); /* Key is in system keystore */ ret = keystore_slot_read(&system_keystore, key_info->userid, key_info->handle, key_info->key_length, key); } else { printk("key goes in user keystore.\n"); /* Key goes in user keystore */ ret = keystore_slot_read(key_info->keystore, key_info->userid, key_info->handle, key_info->key_length, key); } } out: return ret; } /* end fn fsl_shw_read_key */
fsl_shw_return_t fsl_shw_read_key(fsl_shw_uco_t * user_ctx, fsl_shw_sko_t * key_info, uint8_t * key) { SAH_SF_DCLS; SAH_SF_USER_CHECK(); if (!(key_info->flags & FSL_SKO_KEY_ESTABLISHED) || !(key_info->flags & FSL_SKO_KEY_SW_KEY)) { ret = FSL_RETURN_BAD_FLAG_S; goto out; } if (key_info->keystore == NULL) { /* Key lives in system keystore */ ret = do_system_keystore_slot_read(user_ctx, key_info->userid, key_info->handle, key_info->key_length, key); } else { /* Key lives in user keystore */ ret = keystore_slot_read(key_info->keystore, key_info->userid, key_info->handle, key_info->key_length, key); } out: SAH_SF_DESC_CLEAN(); return ret; }
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, const uint8_t * key) { (void)user_ctx; return keystore_slot_read(&system_keystore, ownerid, slot, key_length, (void *)key); }