void maliciousot::OtExtensionMaliciousReceiverInterface::init_ot_receiver() { int nSndVals = 2; int wdsize = 1 << (CEIL_LOG2(m_num_base_ots)); int nblocks = CEIL_DIVIDE(m_num_ots, NUMOTBLOCKS * wdsize); int s2ots = nblocks * m_num_base_ots; m_sender_key_seeds = (BYTE*) malloc(AES_KEY_BYTES * m_num_base_ots);//m_security_level.symbits); m_receiver_key_seeds_matrix = (BYTE*) malloc(AES_KEY_BYTES * 2 * s2ots); // client connect m_connection_manager->setup_connection(); // 1st step: pre-compute the PVW base OTs precompute_base_ots_receiver(); assert(nblocks <= NUMOTBLOCKS); // 2nd step: OT extension step to obtain the base-OTs for the next step m_sender = new Mal_OTExtensionSender(nSndVals, m_security_level.symbits, m_connection_manager->get_sockets_data(), U, m_sender_key_seeds, m_num_base_ots, m_num_checks, s2ots, m_sender_seed); CBitVector seedA(s2ots * AES_KEY_BITS); CBitVector seedB(s2ots * AES_KEY_BITS); XORMasking* masking_function = new XORMasking(AES_KEY_BITS); m_sender->send(s2ots, AES_KEY_BITS, seedA, seedB, R_OT, 1, masking_function); delete masking_function; for(int i = 0; i < s2ots; i++) { memcpy(m_receiver_key_seeds_matrix + 2 * i * AES_KEY_BYTES, seedA.GetArr() + i * AES_KEY_BYTES, AES_KEY_BYTES); memcpy(m_receiver_key_seeds_matrix + (2*i+1) * AES_KEY_BYTES, seedB.GetArr() + i * AES_KEY_BYTES, AES_KEY_BYTES); } m_receiver = new Mal_OTExtensionReceiver(nSndVals, m_security_level.symbits, m_connection_manager->get_sockets_data(), m_receiver_key_seeds_matrix, m_receiver_seed, m_num_base_ots, s2ots); }
/** ihist_stats_config: * @entry: Pointer to entry struct of ihist stats * @pix_settings: Pointer to the pipeline settings * @in_param_size: Size of pix_settings * * Configure the entry and reg_cmd for ihist_stats using values passed in pix * settings * * * Return 0 on Success, negative on ERROR **/ static int ihist_stats_config(isp_stats_entry_t *entry, isp_hw_pix_setting_params_t *pix_settings, uint32_t in_param_size) { ISP_StatsIhist_CfgType *pcmd = entry->reg_cmd; uint32_t window_w_t, window_h_t, total_pixels; isp_pix_camif_cfg_t *camif_cfg = &pix_settings->camif_cfg; int32_t shift_bits; if (!entry->enable) { ISP_DBG(ISP_MOD_STATS, "%s: ihist not enabled", __func__); return 0; } entry->session_id = pix_settings->outputs->stream_param.session_id; entry->is_ispif_split = pix_settings->camif_cfg.ispif_out_info.is_split; if (pix_settings->camif_cfg.ispif_out_info.is_split) { if (!(pix_settings->outputs[0].isp_out_info.stripe_id == 0)) entry->buf_offset = ISP_STATS_IHIST_BUF_SIZE; } else { entry->buf_offset = 0; } entry->ion_fd = pix_settings->ion_fd; entry->hfr_mode = pix_settings->camif_cfg.hfr_mode; entry->comp_flag = 1; if (pix_settings->outputs[0].stream_param.width > 0) { window_w_t = camif_cfg->sensor_out_info.request_crop.last_pixel - camif_cfg->sensor_out_info.request_crop.first_pixel + 1; window_h_t = camif_cfg->sensor_out_info.request_crop.last_line - camif_cfg->sensor_out_info.request_crop.first_line + 1; } else { CDBG_ERROR("%s: error, width = 0\n", __func__); return -1; } pcmd->channelSelect = 0; pcmd->rgnHNum = FLOOR16(window_w_t/2)-1; pcmd->rgnVNum = FLOOR16(window_h_t/2)-1; pcmd->rgnHOffset = 0; pcmd->rgnVOffset = 0; /* calculate shift bits */ total_pixels = (float)((pcmd->rgnHNum + 1) * (pcmd->rgnVNum + 1)) / 2.0; shift_bits = CEIL_LOG2(total_pixels); shift_bits -= 16; shift_bits = MAX(0, shift_bits); shift_bits = MIN(4, shift_bits); ISP_DBG(ISP_MOD_STATS, "%s: tot %d shift %d", __func__, total_pixels, shift_bits); pcmd->shiftBits = shift_bits; pcmd->siteSelect = 0; entry->is_ispif_split = pix_settings->camif_cfg.ispif_out_info.is_split; if (entry->is_ispif_split) { uint32_t end_point_stats_bound; uint32_t overlap = pix_settings->camif_cfg.ispif_out_info.overlap; isp_out_info_t *isp_out = &pix_settings->outputs[0].isp_out_info; /* Its possible that end point of stats boundary is falling completely within the left strip so the calculation for the no_regions_left will depend on the end of the stats boundary. */ end_point_stats_bound = pcmd->rgnHOffset + 2 * (pcmd->rgnHNum + 1); if (end_point_stats_bound > isp_out->right_stripe_offset + overlap) end_point_stats_bound = isp_out->right_stripe_offset + overlap; entry->buf_offset = isp_out->stripe_id * ISP_STATS_IHIST_BUF_SIZE; entry->num_left_rgns = (end_point_stats_bound > pcmd->rgnHOffset) ? (end_point_stats_bound - pcmd->rgnHOffset) / 2 : 0; entry->num_right_rgns = (pcmd->rgnHNum + 1) - entry->num_left_rgns; if (isp_out->stripe_id == ISP_STRIPE_LEFT) { /* Make sure if number of region is zero for each side, we don't actually program 0 region */ pcmd->rgnHNum = (entry->num_left_rgns > 0) ? entry->num_left_rgns - 1 : 1; pcmd->rgnHOffset = (entry->num_left_rgns > 0) ? pcmd->rgnHOffset : 2; // Default offset for IHIST stats } else { /* ISP_STRIPE_RIGHT */ pcmd->rgnHNum = (entry->num_right_rgns > 0) ? entry->num_right_rgns - 1 : 1; pcmd->rgnHOffset = pcmd->rgnHOffset + (entry->num_left_rgns * 2) - isp_out->right_stripe_offset; pcmd->rgnHOffset = (entry->num_right_rgns > 0) ? pcmd->rgnHOffset : 2; // Default offset for IHIST stats } } ISP_DBG(ISP_MOD_STATS, "IHIST statsconfig shiftBits %d\n", pcmd->shiftBits); ISP_DBG(ISP_MOD_STATS, "IHIST statsconfig channelSelect %d\n", pcmd->channelSelect); ISP_DBG(ISP_MOD_STATS, "IHIST statsconfig siteSelect %d\n", pcmd->siteSelect); ISP_DBG(ISP_MOD_STATS, "IHIST statsconfig rgnHNum %d\n", pcmd->rgnHNum); ISP_DBG(ISP_MOD_STATS, "IHIST statsconfig rgnVNum %d\n", pcmd->rgnVNum); entry->hw_update_pending = 1; return 0; }
/*=========================================================================== * FUNCTION - test_vector_parse_input - * * DESCRIPTION: *==========================================================================*/ vfe_status_t test_vector_parse_input(vfe_test_vector_t *mod) { vfe_status_t status = VFE_SUCCESS; char *token, *last; int bytes_read; /*calculate size*/ fseek(mod->fp, 0L, SEEK_END); mod->input_size = ftell(mod->fp); fseek(mod->fp, 0L, SEEK_SET); CDBG("%s: input_size %d", __func__, mod->input_size); mod->input_data = (char *)malloc(mod->input_size * sizeof(char)); if (mod->input_data == NULL) { CDBG_ERROR("%s: cannot allocate input", __func__); return VFE_ERROR_NO_MEMORY; } bytes_read = fread (mod->input_data, 1, mod->input_size, mod->fp); CDBG("%s: bytes_read %d input_size %d", __func__, bytes_read, mod->input_size); if (bytes_read < mod->input_size) { CDBG_ERROR("%s: cannot get the data from file %d %d", __func__, bytes_read, mod->input_size); return VFE_ERROR_GENERAL; } fclose(mod->fp); /* close file handle */ mod->parse_mode = VFE_TEST_VEC_PARSE_INPUT; token = strtok_r (mod->input_data, "\n", &last); while (token != NULL) { int len = strlen(token); if (len > 0) token[len-1] = '\0'; CDBG ("%s: token %s\n", __func__, token); if((len <=2) && (token[0] == '/') && (token[1] == '/')) { CDBG("%s: comment %s", __func__, token); } else if (mod->parse_mode == VFE_TEST_VEC_PARSE_INPUT) { status = test_vector_extract_input_params(mod, token); if (status != VFE_SUCCESS) { return status; } } else { /* parse output */ uint32_t module_type; char *mod_ptr = NULL; status = test_vector_extract_input_module_params(mod, token, &module_type); if (status != VFE_SUCCESS) return status; if (module_type != VFE_MOD_INVALID) { uint32_t index = CEIL_LOG2(module_type); CDBG("%s: module_type %d index %d", __func__, module_type, index); if (index > VFE_MOD_COUNT) { CDBG_ERROR("%s: Invalid module %d", __func__, module_type); return VFE_ERROR_GENERAL; } mod->current_index = index; } else { status = test_vector_parse_module_data(mod, token); if (status != VFE_SUCCESS) return status; } } token = strtok_r (NULL, "\n", &last); } return status; }/*test_vector_parse_input*/
SML_PRIMITIVE void * sml_alloc(unsigned int objsize, void *frame_pointer) { size_t alloc_size; unsigned int blocksize_log2; struct alloc_ptr *ptr; void *obj; /* ensure that alloc_size is at least BLOCKSIZE_MIN. */ alloc_size = ALIGNSIZE(OBJ_HEADER_SIZE + objsize, BLOCKSIZE_MIN); if (alloc_size > BLOCKSIZE_MAX) { GCSTAT_ALLOC_COUNT(malloc, 0, alloc_size); sml_save_frame_pointer(frame_pointer); return sml_obj_malloc(alloc_size); } blocksize_log2 = CEIL_LOG2(alloc_size); ASSERT(BLOCKSIZE_MIN_LOG2 <= blocksize_log2 && blocksize_log2 <= BLOCKSIZE_MAX_LOG2); ptr = &ALLOC_PTR_SET()->alloc_ptr[blocksize_log2]; if (!BITPTR_TEST(ptr->freebit)) { GCSTAT_ALLOC_COUNT(fast, blocksize_log2, alloc_size); BITPTR_INC(ptr->freebit); obj = ptr->free; ptr->free += ptr->blocksize_bytes; goto alloced; } sml_save_frame_pointer(frame_pointer); if (ptr->free != NULL) { obj = find_bitmap(ptr); if (obj) goto alloced; } obj = find_segment(ptr); if (obj) goto alloced; GCSTAT_TRIGGER(blocksize_log2); do_gc(MAJOR); obj = find_segment(ptr); if (obj) goto alloced_major; extend_heap(heap_space.extend_step); obj = find_segment(ptr); if (obj) goto alloced_major; sml_fatal(0, "heap exceeded: intended to allocate %u bytes.", ptr->blocksize_bytes); alloced_major: ASSERT(check_newobj(obj)); /* NOTE: sml_run_finalizer may cause garbage collection. */ obj = sml_run_finalizer(obj); goto finished; alloced: ASSERT(check_newobj(obj)); finished: OBJ_HEADER(obj) = 0; return obj; }