void handle_key_1(s32 val) { if(val == 0) { return; } if(altMode) { if(check_key(1)) { // show / hide on play screen net_toggle_in_play(*pageSelect); // render to tmp buffer render_line(*pageSelect, 0xf); // copy to scroll with highlight render_to_scroll_line(SCROLL_CENTER_LINE, 1); } } else { if(check_key(1)) { // show preset name in head region draw_preset_name(); // include / exclude in preset net_toggle_in_preset(*pageSelect); // render to tmp buffer render_line(*pageSelect, 0xf); // copy to scroll with highlight render_to_scroll_line(SCROLL_CENTER_LINE, 1); } } show_foot(); }
int check_data(timing_data* data, key_data * key){ unsigned char key_guess[KEY_LENGTH]; int i; compute_cost(data, key); compute_rank_table(data, key); first_guess(data, key_guess); printf("\nInitial guess: "); for(i = 0; i < KEY_LENGTH; i++) printf(" %02x ", key_guess[i]); walk(data, key_guess); printf("Walk : "); if(check_key(key_guess, data, key) ) return 1; for(i = 0; i < KEY_LENGTH; i++) printf(" %02x ", key_guess[i]); if(check_key(key_guess, data, key) ) return 1; return 0; }
//----------------------------------------------------------------------- bool parseAccountAddressString(uint64_t& prefix, AccountPublicAddress& adr, const std::string& str) { std::string data; return Tools::Base58::decode_addr(str, prefix, data) && fromBinaryArray(adr, asBinaryArray(data)) && // ::serialization::parse_binary(data, adr) && check_key(adr.spendPublicKey) && check_key(adr.viewPublicKey); }
void use_item_2(t_data *data, t_items *tmp) { if (tmp->item_id == 0) launch_turtle(data); if (tmp->item_id == 2) check_key(data, 2); if (tmp->item_id == 4) check_key(data, 4); if (tmp->item_id == 3) carli_gift(data); if (tmp->item_id == 1) chat_gift(data); }
/*---------------------------------------------------------------------------*\ | \fn configure_assembly | \brief Configures the assembly state from the order \*---------------------------------------------------------------------------*/ void configure_assembly( TOrderMap& order ) { AssemblyState state; state.set_defaults(); /*-----------------------------------------------------------------------*\ | Check if specific items are present in order, and notify of defaults \*-----------------------------------------------------------------------*/ bool present = check_key( order, "plastic", "\t<>Unknown plastic || defaulting to ABS." ); if ( present ) { state.set_plastic_type( order["plastic"] ); } present = check_key( order, "size", "\t<>No size specified, defaulting to 100." ); if ( present ) { state.set_order_size( std::stoi( order["size"] ) ); } present = check_key( order, "packager", "\t<>Unknown packager || defaulting to Bulk packager." ); if ( present ) { state.set_packager( order["packager"] ); } present = check_key( order, "stuffer", "\t<>Unknown stuffer || defaulting to Air stuffer." ); if ( present ) { state.set_stuffer( order["stuffer"] ); } PlasticType plastic = state.get_plastic_enum(); TAssemblyLinePtr injection_line( AssemblyLineFactory::get_assembly_line( order, plastic ) ); injection_line->process_order(); }
/*---------------------------------------------------------------------------*\ | \fn AssemblyLineTemplate::load_additive_bins | \brief Step 4 | \note Has virtual hook \*---------------------------------------------------------------------------*/ void AssemblyLineTemplate::load_additive_bins() { std::cout << "\t\tLoad plastic, color, and additive bins." << std::endl; /*-----------------------------------------------------------------------*\ | Get color specified \*-----------------------------------------------------------------------*/ AssemblyState state; bool has_color = check_key( m_order, "color" ); if ( has_color ) { state.set_color( m_order[ "color" ] ); } else { std::cout << "\t\t\t<>No color specified, defaulting to black." << std::endl; } /*-----------------------------------------------------------------------*\ | Get additives \*-----------------------------------------------------------------------*/ for ( auto additive : c_valid_additives ) { bool has_additive = check_key( m_order, additive ); if ( has_additive ) { int volume = std::stoi( m_order[additive] ); state.set_additive( additive, volume ); } } load_additive_hook(); /*-----------------------------------------------------------------------*\ | Output aggregated description and volume \*-----------------------------------------------------------------------*/ int volume = m_injector->num_cavities() * m_recipe->volume(); std::cout << "\t\t\tRecipe: " << m_recipe->description() << " Total = " << volume << "." << std::endl; }
/* * Generate a random key. If key_type is provided, make * sure generated key is valid for key_type. */ void generate_key_random (struct key *key, const struct key_type *kt) { int cipher_len = MAX_CIPHER_KEY_LENGTH; int hmac_len = MAX_HMAC_KEY_LENGTH; struct gc_arena gc = gc_new (); do { CLEAR (*key); if (kt) { if (kt->cipher && kt->cipher_length > 0 && kt->cipher_length <= cipher_len) cipher_len = kt->cipher_length; if (kt->digest && kt->hmac_length > 0 && kt->hmac_length <= hmac_len) hmac_len = kt->hmac_length; } if (!rand_bytes (key->cipher, cipher_len) || !rand_bytes (key->hmac, hmac_len)) msg (M_FATAL, "ERROR: Random number generator cannot obtain entropy for key generation"); dmsg (D_SHOW_KEY_SOURCE, "Cipher source entropy: %s", format_hex (key->cipher, cipher_len, 0, &gc)); dmsg (D_SHOW_KEY_SOURCE, "HMAC source entropy: %s", format_hex (key->hmac, hmac_len, 0, &gc)); if (kt) fixup_key (key, kt); } while (kt && !check_key (key, kt)); gc_free (&gc); }
// typical usage of Elektra int main() { Key * error_key = keyNew(KEY_END); KDB * kdb_handle = kdbOpen(error_key); Key * top = keyNew(KEY_END); keySetName(top, "user/sw/MyApp"); KeySet * ks = ksNew(0); kdbGet(kdb_handle, ks, top); Key * key = keyNew(KEY_END); keySetName(key, "user/sw/MyApp/Tests/TestKey1"); // == 31 keySetString(key, "NULLTestValue"); // == 14 keySetMeta(key, "comment", "NULLTestComment"); // == 16 ksAppendKey(ks, key); // == 1 keyNeedSync(key); kdbSet(kdb_handle, ks, top); // == -1 print_warnings(top); keyDel(top); ksDel(ks); kdbClose(kdb_handle, error_key); keyDel(error_key); check_key(); return 0; }
CRYPT_RESULT _cpri__ValidateSignatureRSA( RSA_KEY *key, TPM_ALG_ID padding_alg, TPM_ALG_ID hash_alg, uint32_t digest_len, uint8_t *digest, uint32_t sig_len, uint8_t *sig, uint16_t salt_len) { struct RSA rsa; enum padding_mode padding; enum hashing_mode hashing; if (!check_key(key)) return CRYPT_FAIL; if (!check_sign_params(padding_alg, hash_alg, &padding, &hashing)) return CRYPT_FAIL; rsa.e = key->exponent; rsa.N.dmax = key->publicKey->size / sizeof(uint32_t); rsa.N.d = (struct access_helper *) &key->publicKey->buffer; rsa.d.dmax = 0; rsa.d.d = NULL; if (DCRYPTO_rsa_verify(&rsa, digest, digest_len, sig, sig_len, padding, hashing)) return CRYPT_SUCCESS; else return CRYPT_FAIL; }
// copy / clear / confirm void handle_key_2(s32 val) { if(val == 1) { return; } if(check_key(2)) { preset_clear(*pageSelect); } show_foot(); }
/** * List all possible values for a configuration key. * * @param[in] driver The sr_dev_driver struct to query. Must not be NULL. * @param[in] sdi (optional) If the key is specific to a device, this must * contain a pointer to the struct sr_dev_inst to be checked. * Otherwise it must be NULL. If sdi is != NULL, sdi->priv must * also be != NULL. * @param[in] cg The channel group on the device for which to list the * values, or NULL. * @param[in] key The configuration key (SR_CONF_*). * @param[in,out] data A pointer to a GVariant where the list will be stored. * The caller is given ownership of the GVariant and must thus * unref the GVariant after use. However if this function * returns an error code, the field should be considered * unused, and should not be unreferenced. * * @retval SR_OK Success. * @retval SR_ERR Error. * @retval SR_ERR_ARG The driver doesn't know that key, but this is not to be * interpreted as an error by the caller; merely as an indication * that it's not applicable. * * @since 0.3.0 */ SR_API int sr_config_list(const struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg, uint32_t key, GVariant **data) { int ret; if (!driver || !data) return SR_ERR; else if (!driver->config_list) return SR_ERR_ARG; else if (key != SR_CONF_SCAN_OPTIONS && key != SR_CONF_DEVICE_OPTIONS) { if (check_key(driver, sdi, cg, key, SR_CONF_LIST, NULL) != SR_OK) return SR_ERR_ARG; } if (sdi && !sdi->priv) { sr_err("Can't list config (sdi != NULL, sdi->priv == NULL)."); return SR_ERR; } if ((ret = driver->config_list(key, data, sdi, cg)) == SR_OK) { log_key(sdi, cg, key, SR_CONF_LIST, *data); g_variant_ref_sink(*data); } return ret; }
/** * Query value of a configuration key at the given driver or device instance. * * @param[in] driver The sr_dev_driver struct to query. Must not be NULL. * @param[in] sdi (optional) If the key is specific to a device, this must * contain a pointer to the struct sr_dev_inst to be checked. * Otherwise it must be NULL. If sdi is != NULL, sdi->priv must * also be != NULL. * @param[in] cg The channel group on the device for which to list the * values, or NULL. * @param[in] key The configuration key (SR_CONF_*). * @param[in,out] data Pointer to a GVariant where the value will be stored. * Must not be NULL. The caller is given ownership of the GVariant * and must thus decrease the refcount after use. However if * this function returns an error code, the field should be * considered unused, and should not be unreferenced. * * @retval SR_OK Success. * @retval SR_ERR Error. * @retval SR_ERR_ARG The driver doesn't know that key, but this is not to be * interpreted as an error by the caller; merely as an indication * that it's not applicable. * * @since 0.3.0 */ SR_API int sr_config_get(const struct sr_dev_driver *driver, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg, uint32_t key, GVariant **data) { int ret; if (!driver || !data) return SR_ERR; if (!driver->config_get) return SR_ERR_ARG; if (check_key(driver, sdi, cg, key, SR_CONF_GET, NULL) != SR_OK) return SR_ERR_ARG; if (sdi && !sdi->priv) { sr_err("Can't get config (sdi != NULL, sdi->priv == NULL)."); return SR_ERR; } if ((ret = driver->config_get(key, data, sdi, cg)) == SR_OK) { log_key(sdi, cg, key, SR_CONF_GET, *data); /* Got a floating reference from the driver. Sink it here, * caller will need to unref when done with it. */ g_variant_ref_sink(*data); } return ret; }
void handle_key_2(s32 val) { if(check_key(2)) { bfin_disable(); net_report_params(); bfin_enable(); } }
// function keys void handle_key_0(s32 val) { // load module if(val == 0) { return; } if(check_key(0)) { region_fill(headRegion, 0x0); font_string_region_clip(headRegion, "loading DSP module...", 0, 0, 0xa, 0); headRegion->dirty = 1; render_update(); net_clear_user_ops(); files_load_dsp(*pageSelect); bfin_wait_ready(); net_report_params(); bfin_enable(); // render status to head region region_fill(headRegion, 0x0); font_string_region_clip(headRegion, "finished loading.", 0, 0, 0xa, 0); headRegion->dirty = 1; render_update(); } show_foot(); }
// store void handle_key_0(s32 val) { if(val == 0) { return; } if(check_key(0)) { region_fill(headRegion, 0x0); font_string_region_clip(headRegion, "writing scene to card...", 0, 0, 0xa, 0); headRegion->dirty = 1; render_update(); region_fill(headRegion, 0x0); // files_store_scene_name(sceneData->desc.sceneName, 1); files_store_scene_name(sceneData->desc.sceneName); print_dbg("\r\n stored scene, back to handler"); font_string_region_clip(headRegion, "done writing.", 0, 0, 0xa, 0); headRegion->dirty = 1; render_update(); // refresh // redraw_lines(); redraw_scenes(); } show_foot(); }
// recall void handle_key_1(s32 val) { if(val == 1) { return; } if(check_key(1)) { preset_recall(*pageSelect); } show_foot(); }
void handle_key_2(s32 val) { if(val == 0) { return; } if(check_key(2)) { if(altMode) { // filter / all } else { if(zeroed) { /// set to max net_set_in_value(*pageSelect, OP_MAX_VAL); zeroed = 0; } else { /// set to 0 net_set_in_value(*pageSelect, 0); zeroed = 1; } // render to tmp buffer render_line(*pageSelect, 0xf); // copy to scroll with highlight render_to_scroll_line(SCROLL_CENTER_LINE, 1); } } show_foot(); }
CRYPT_RESULT _cpri__DecryptRSA(uint32_t *out_len, uint8_t *out, RSA_KEY *key, TPM_ALG_ID padding_alg, uint32_t in_len, uint8_t *in, TPM_ALG_ID hash_alg, const char *label) { struct RSA rsa; enum padding_mode padding; enum hashing_mode hashing; if (!check_key(key)) return CRYPT_FAIL; if (!check_encrypt_params(padding_alg, hash_alg, &padding, &hashing)) return CRYPT_FAIL; rsa.e = key->exponent; rsa.N.dmax = key->publicKey->size / sizeof(uint32_t); rsa.N.d = (struct access_helper *) &key->publicKey->buffer; rsa.d.dmax = key->privateKey->size / sizeof(uint32_t); rsa.d.d = (struct access_helper *) &key->privateKey->buffer; if (DCRYPTO_rsa_decrypt(&rsa, out, out_len, in, in_len, padding, hashing, label)) return CRYPT_SUCCESS; else return CRYPT_FAIL; }
// store void handle_key_0(s32 val) { if(val == 0) { return; } if(check_key(0)) { preset_store(*pageSelect); } show_foot(); }
// function keys void handle_key_0(s32 val) { // load module if(val == 0) { return; } if(check_key(0)) { notify("loading..."); // don't do this! let it break? // net_clear_user_ops(); // disconnect parameters though net_disconnect_params(); files_load_dsp(*pageSelect); bfin_wait_ready(); scene_query_module(); net_report_params(); bfin_enable(); redraw_ins(); redraw_dsp(); notify("finished loading."); } show_foot(); }
static void process_arguments(int argc, char **argv) { char co; while ((co = getopt(argc, argv, "hf:g:uc:s")) != EOF) { switch(co) { case 'h': help(); exit(0); case 's': check_key(); break; case 'g': create_new_key_and_activate(optarg); break; case 'u': delete_key(); break; case 'c': create_file_from_key(optarg); break; case 'f': load_key_from_file_and_activate(optarg); break; default: help(); break; } } }
void handle_key_1(s32 val) { s16 newOut; if(val == 0) { return; } if(check_key(1)) { if(altMode) { print_dbg("\r\n splitting output: "); print_dbg_ulong(*pageSelect); newOut = net_split_out(*pageSelect); *pageSelect = newOut; redraw_outs(); } else { // include / exclude in selected preset // show preset name in head region draw_preset_name(); // include / exclude in preset net_toggle_out_preset(*pageSelect); // re-draw selected line to update inclusion glyph // render to tmp buffer render_line(*pageSelect, 0xf); // copy to scroll with highlight render_to_scroll_line(SCROLL_CENTER_LINE, 1); } } show_foot(); }
bool checkOutsValid(const TransactionPrefix& tx, std::string* error) { for (const TransactionOutput& out : tx.outputs) { if (out.target.type() == typeid(KeyOutput)) { if (out.amount == 0) { if (error) { *error = "Zero amount ouput"; } return false; } if (!check_key(boost::get<KeyOutput>(out.target).key)) { if (error) { *error = "Output with invalid key"; } return false; } } else { if (error) { *error = "Output with invalid type"; } return false; } } return true; }
// function key handlers void handle_key_0(s32 val) { if(val == 0) { return; } if(altMode) { ///// follow // select target on ins page tmpTarget = net_get_target(*pageSelect); if(tmpTarget >= 0) { pages[ePageIns].select = tmpTarget; set_page(ePageIns); redraw_ins(); } } else { // store // show selected preset name draw_preset_name(); if(check_key(0)) { // store in preset net_set_out_preset(*pageSelect, 1); preset_store_out(preset_get_select(), *pageSelect); // redraw selected line render_line(*pageSelect, 0xa); render_scroll_apply_hl(SCROLL_CENTER_LINE, 1); // TODO: store directly in scene? } } show_foot(); }
static Session * session_new (GKeyFile *keyfile, const char *group, GError **error) { GError *local = NULL; Session *s; struct passwd *pw; s = g_new0 (Session, 1); g_assert (s); s->uid = G_MAXUINT; /* paranoia */ if (!check_key (keyfile, group, "uid", &local)) goto error; s->uid = (uid_t) g_key_file_get_integer (keyfile, group, "uid", &local); if (local) goto error; if (!check_key (keyfile, group, "is_active", &local)) goto error; s->active = g_key_file_get_boolean (keyfile, group, "is_active", &local); if (local) goto error; if (!check_key (keyfile, group, "is_local", &local)) goto error; s->local = g_key_file_get_boolean (keyfile, group, "is_local", &local); if (local) goto error; pw = getpwuid (s->uid); if (!pw) { g_set_error (&local, NM_SESSION_MONITOR_ERROR, NM_SESSION_MONITOR_ERROR_UNKNOWN_USER, "Could not get username for UID %d", s->uid); goto error; } s->user = g_strdup (pw->pw_name); return s; error: session_free (s); g_propagate_error (error, local); return NULL; }
static bool handle_key(wlc_handle view, uint32_t time, const struct wlc_modifiers *modifiers, uint32_t key, uint32_t sym, enum wlc_key_state state) { if (locked_view_focus && state == WLC_KEY_STATE_PRESSED) { return false; } // Revert floating container back to original position on keypress if (state == WLC_KEY_STATE_PRESSED && (pointer_state.floating.drag || pointer_state.floating.resize)) { reset_floating(get_focused_view(&root_container)); } struct sway_mode *mode = config->current_mode; if (sym < 70000 /* bullshit made up number */) { if (!isalnum(sym) && sym != ' ' && sym != XKB_KEY_Escape && sym != XKB_KEY_Tab) { // God f*****g dammit return false; } } // Lowercase if necessary sym = tolower(sym); int i; if (state == WLC_KEY_STATE_PRESSED) { press_key(sym); } else { // WLC_KEY_STATE_RELEASED release_key(sym); } // TODO: reminder to check conflicts with mod+q+a versus mod+q for (i = 0; i < mode->bindings->length; ++i) { struct sway_binding *binding = mode->bindings->items[i]; if ((modifiers->mods & binding->modifiers) == binding->modifiers) { bool match; int j; for (j = 0; j < binding->keys->length; ++j) { xkb_keysym_t *key = binding->keys->items[j]; if ((match = check_key(*key)) == false) { break; } } if (match) { if (state == WLC_KEY_STATE_PRESSED) { handle_command(config, binding->command); return true; } else if (state == WLC_KEY_STATE_RELEASED) { // TODO: --released } } } } return false; }
// set global A2_API inline void a2_setglobal(struct a2_state* state){ int top = a2_top(state)-1; struct a2_obj* v = a2_getcstack(state->env_p, top); struct a2_obj* k = a2_getcstack(state->env_p, top-1); check_key(k); a2_set_envglobal(state->env_p, k, v); a2_topset(state, top-1); }
// get global A2_API inline void a2_getglobal(struct a2_state* state){ struct a2_obj* k = a2_getcstack(state->env_p, a2_top(state)-1); check_key(k); struct a2_obj* v = a2_get_envglobal(state->env_p, k); if(v==NULL) obj_setX(k, A2_TNIL, point, NULL); else *k = *v; }
// del key/value A2_API inline void a2_delmap(struct a2_state* state){ int top = a2_top(state)-1; struct a2_obj* k = a2_getcstack(state->env_p, top); struct a2_obj* map = a2_getcstack(state->env_p, top-1); check_map(map); check_key(k); a2_map_del(a2_gcobj2map(obj_vX(map, obj)), k); a2_pop(state, 1); }
void award_campaign_medal (int side, int medal) { player_log_type *player; int *medals; ASSERT ((side >= 0) && (side <= NUM_ENTITY_SIDES)); player = get_current_player_log (); medals = player->side_log [side].medals; if ((medal > MEDAL_TYPE_NONE) && (medal <= MEDAL_TAIWAN)) { medals [medal] += 1; } #if DEBUG_MEDALS // clear medals memset (medals, 0, sizeof (int) * (NUM_MEDAL_TYPES - 1)); if (check_key (SDLK_F1)) { medals [MEDAL_SAUDI] = 1; } if (check_key (SDLK_F2)) { medals [MEDAL_LEBANON] = 1; } if (check_key (SDLK_F3)) { medals [MEDAL_TAIWAN] = 1; } #endif }