int Tree::retrieve(char * keyword, list_node *& match_list) { int key = create_key(keyword); int count = 0; if(root == NULL) return 0; if(root->key == key) { if(strcmp(root->keyword, keyword) == 0) { match_list->app = root->match; ++count; match_list->next = NULL; } count = count + retrieve(keyword, match_list->next, root->left, key); } if(root->key > key) count = count + retrieve(keyword, match_list, root->left, key); if(root->key < key) count = count + retrieve(keyword, match_list, root->right, key); return count; }
int main(int argc, char **argv) { int opt=-1; ppdp_init(); if(argc < 2 )return -1; while((opt = getopt_long(argc, argv, "kt:v:", longopts, NULL)) != -1){ switch(opt){ case 'k': if(!create_key())printf("Couldn't create keys\n"); break; case 't': if(!tag_file(optarg))printf("Couldn't tag file\n"); break; case 'v': if(!verify_file(optarg))printf("Couldn't verify file\n"); break; default: break; } } ppdp_clean(); return 0; }
int Tree::add_node(char * keyword, application * app) { int key = create_key(keyword); if(root == NULL) { node * current; current = new node; current->match = app; int len = 0; len = strlen(keyword); current->keyword = new char[len+1]; strcpy(current->keyword, keyword); current->key = key; current->left = NULL; current->right = NULL; root = current; return 1; } if(root->key >= key) add_node(keyword, app, root->left, key); if(root->key < key) add_node(keyword, app, root->right, key); return 1; }
TPW_RESULT create_auth_key(TSS_HCONTEXT tss_context, TSS_UUID uuid, TSS_HKEY *auth_key, TSS_HKEY srk_key, char *auth, int authlen) { TPW_RESULT result; TSS_FLAG aflags = TSS_KEY_TYPE_STORAGE | TSS_KEY_SIZE_2048 | TSS_KEY_NON_VOLATILE | TSS_KEY_NOT_MIGRATABLE; TSS_HKEY tmp; result = create_key(tss_context, aflags, auth_key, srk_key, auth, authlen); if(TPW_SUCCESS != result) { Log_Text("create auth key", TPW_KEY_ERROR); return result; } result = keyUnregisterKey(tss_context, uuid); if(TPW_SUCCESS != result) ; //Log_Text("unreisterkey auth key", TPW_KEY_ERROR); //return result; else printf("unregisterKey success!!"); result = keyRegisterKey(tss_context, *auth_key, uuid, SRK_UUID); if(TPW_SUCCESS != result) { Log_Text("reisterkey auth key", TPW_KEY_ERROR); return result; } return TPW_SUCCESS; }
/** Creates a new empty shared matrix of dimensions width x height */ void MatrixDouble::create(size_t width, size_t height, const char* shared_id) { if(shared_id) { bShared = true; if(attach(shared_id)) { if(this->width==width && this->height==height) return; cout << "But matrix dimensions does not agree : reshaping ... ok\n"; delete_shared(); } key = create_key(id); try { size_t* _data = (size_t*)create_shared_mem(key, width*height*sizeof(double) + 2*sizeof(size_t), &_shmid); *_data++ = width; *_data++ = height; data = (double*)_data; //this->clear(); } catch(const char* e) { data = 0; cerr << "Couldn't allocate shared matrix " << shared_id << " with size [" << width << "x" << height << "] (" << e << ")\n"; unlink(id.c_str()); throw "Couldn't allocate shared matrix"; } } else { bShared = false; data = new double[width*height]; //this->clear(); } this->width = width; this->height = height; }
void KEYBOARD::write_signal(int id, uint32 data, uint32 mask) { if(id == SIG_KEYBOARD_Z80PIO_A) { // from Z-80PIO Port A sel = data & mask; create_key(); } }
SERVICE_CTX *service_ctx_find(SERVICE *service, char type, unsigned int id) { SERVICE_CTX *ctx; char key[KEY_LEN]; create_key(key, sizeof(key), type, id); ctx = (SERVICE_CTX*) acl_htable_find(service->table, key); return (ctx); }
void lemur::file::Keyfile::create( const char* filename, int cacheSize ) { _buildHandle( cacheSize ); int error = create_key( _handle, const_cast<char*>(filename), _handleSize ); if( error ) LEMUR_THROW(LEMUR_KEYFILE_IO_ERROR, "Unable to create '" + filename + "'"); }
void create_keyfile(int number) { char path[MAX_PATH_LEN+1]; int key_fd, result; int bytes_written; char *last_slash; struct stat buf; unsigned char key[KEY_SIZE_BYTES]; create_key(key, sizeof(key)); get_keyfile_path(path, sizeof(path), number); last_slash = strrchr(path, '/'); *last_slash = '\0'; if (stat(path, &buf) == -1 && errno == ENOENT) { debug_printf("Creating directory for keyfile: %s\n", path); result = mkdir(path, 0700); if (result == -1) { fprintf(stderr, "Failed to create directory for spindle key: %s\n", path); exit(-1); } } *last_slash = '/'; debug_printf("Creating keyfile at %s\n", path); key_fd = open(path, O_CREAT|O_EXCL|O_WRONLY, 0600); if (key_fd == -1) { fprintf(stderr, "Failed to create security keyfile %s: %s\n", path, strerror(errno)); exit(-1); } bytes_written = 0; do { result = write(key_fd, key + bytes_written, sizeof(key) - bytes_written); if (result == -1 && errno == EINTR) continue; if (result <= 0) { fprintf(stderr, "Failed to write key to %s: %s\n", path, strerror(errno)); close(key_fd); clean_keyfile(number); exit(-1); } bytes_written += result; } while (bytes_written < sizeof(key)); result = close(key_fd); if (result == -1) { clean_keyfile(number); fprintf(stderr, "Failed to close key file %s: %s\n", path, strerror(errno)); exit(-1); } debug_printf("Finished creating keyfile\n"); }
// Index works as follows: All non-NULL values are stored as if they had appended an 'X' character at the end. So // "foo" is stored as if it was "fooX", and "" (empty string) is stored as "X". And NULLs are stored as empty strings. inline StringIndex::key_type StringIndex::create_key(StringData str, size_t offset) noexcept { if (str.is_null()) return 0; if (offset > str.size()) return 0; // for very short strings size_t tail = str.size() - offset; if (tail <= sizeof(key_type)-1) { char buf[sizeof(key_type)]; memset(buf, 0, sizeof(key_type)); buf[tail] = 'X'; memcpy(buf, str.data() + offset, tail); return create_key(StringData(buf, tail + 1)); } // else fallback return create_key(str.substr(offset)); }
NTSTATUS NTAPI NtCreateKey( PHANDLE KeyHandle, ACCESS_MASK DesiredAccess, POBJECT_ATTRIBUTES ObjectAttributes, ULONG TitleIndex, PUNICODE_STRING Class, ULONG CreateOptions, PULONG Disposition ) { object_attributes_t oa; NTSTATUS r; regkey_t *key = NULL; trace("%p %08lx %p %lu %p %lu %p\n", KeyHandle, DesiredAccess, ObjectAttributes, TitleIndex, Class, CreateOptions, Disposition ); if (Disposition) { r = verify_for_write( Disposition, sizeof *Disposition ); if (r < STATUS_SUCCESS) return r; } r = oa.copy_from_user( ObjectAttributes ); if (r < STATUS_SUCCESS) return r; trace("len %08lx root %p attr %08lx %pus\n", oa.Length, oa.RootDirectory, oa.Attributes, oa.ObjectName); unicode_string_t cls; if (Class) { r = cls.copy_from_user( Class ); if (r < STATUS_SUCCESS) return r; } bool opened_existing = false; r = create_key( &key, &oa, opened_existing ); if (r == STATUS_SUCCESS) { if (Disposition) { ULONG dispos = opened_existing ? REG_OPENED_EXISTING_KEY : REG_CREATED_NEW_KEY; copy_to_user( Disposition, &dispos, sizeof *Disposition ); } key->cls.copy( &cls ); r = alloc_user_handle( key, DesiredAccess, KeyHandle ); //release( event ); } return r; }
int crypt(char *msg, char *nb1, char *nb2, char *nb3, char *nb4, char *base, char *flag) { int **key; int **res; key = create_key(nb1, nb2, nb3, nb4); res = create_matr_alpha(msg, (createTable(2, my_strlen(msg))), key); my_putchar('\n'); aff_base_res((int**)res, base, my_strlen(msg) /2); my_putchar('\n'); return (0); }
TPW_RESULT create_process_key(TSS_HCONTEXT tss_context, TSS_HKEY *process_key, TSS_HKEY auth_key) { TPW_RESULT result; TSS_FLAG aflags = TSS_KEY_TYPE_SIGNING | TSS_KEY_SIZE_2048 | TSS_KEY_NON_VOLATILE | TSS_KEY_NOT_MIGRATABLE; result = create_key(tss_context, aflags, process_key, auth_key, NULL, 0); if(TPW_SUCCESS != result) { Log_Text("create process key", TPW_KEY_ERROR); return result; } return TPW_SUCCESS; }
bool SessionStore::delete_session_data(const std::string& call_id, const role_of_node_t role, const node_functionality_t function, SAS::TrailId trail) { std::string key = create_key(call_id, role, function); LOG_DEBUG("Deleting session data for %s", key.c_str()); Store::Status status = _store->delete_data("session", key, trail); LOG_DEBUG("Store returned %d", status); return (status = Store::Status::OK); }
static void pidgin_media_insert_widget(PidginMedia *gtkmedia, GtkWidget *widget, const gchar *session_id, const gchar *participant) { gchar *key = create_key(session_id, participant); PurpleMediaSessionType type = purple_media_get_session_type(gtkmedia->priv->media, session_id); if (type & PURPLE_MEDIA_AUDIO) g_hash_table_insert(gtkmedia->priv->recv_progressbars, key, widget); else if (type & PURPLE_MEDIA_VIDEO) g_hash_table_insert(gtkmedia->priv->remote_videos, key, widget); }
/** * Generate 2 blocks of open info and create secret key. **/ void generate_key_infos( const std::string &key, std::string &s1, std::string &s2, std::string &result ) { random_device rd( false ); std::string ts1( rd.generate_block( 256 ) ); std::string ts2( rd.generate_block( 256 ) ); create_key( key, ts1, ts2, result ); s1.swap( ts1 ); s2.swap( ts2 ); }
libspectrum_error libspectrum_verify_signature( libspectrum_signature *signature, libspectrum_rzx_dsa_key *key ) { libspectrum_error error; gcry_error_t gcrypt_error; gcry_sexp_t hash, key_sexp, signature_sexp; error = get_hash( &hash, signature->start, signature->length ); if( error ) return error; error = create_key( &key_sexp, key, 0 ); if( error ) { gcry_sexp_release( hash ); return error; } error = gcry_sexp_build( &signature_sexp, NULL, signature_format, signature->r, signature->s ); if( error ) { libspectrum_print_error( LIBSPECTRUM_ERROR_LOGIC, "create_signature: error building signature sexp: %s", gcry_strerror( error ) ); gcry_sexp_release( key_sexp ); gcry_sexp_release( hash ); return LIBSPECTRUM_ERROR_LOGIC; } gcrypt_error = gcry_pk_verify( signature_sexp, hash, key_sexp ); gcry_sexp_release( signature_sexp ); gcry_sexp_release( key_sexp ); gcry_sexp_release( hash ); if( gcrypt_error ) { if( gcry_err_code( gcrypt_error ) == GPG_ERR_BAD_SIGNATURE ) { return LIBSPECTRUM_ERROR_SIGNATURE; } else { libspectrum_print_error( LIBSPECTRUM_ERROR_LOGIC, "libgcrypt error verifying signature: %s", gcry_strerror( gcrypt_error ) ); return LIBSPECTRUM_ERROR_LOGIC; } } return LIBSPECTRUM_ERROR_NONE; }
static void pidgin_media_remove_widget(PidginMedia *gtkmedia, const gchar *session_id, const gchar *participant) { GtkWidget *widget = pidgin_media_get_widget(gtkmedia, session_id, participant); if (widget) { PurpleMediaSessionType type = purple_media_get_session_type(gtkmedia->priv->media, session_id); gchar *key = create_key(session_id, participant); GtkRequisition req; if (type & PURPLE_MEDIA_AUDIO) { g_hash_table_remove(gtkmedia->priv->recv_progressbars, key); if (g_hash_table_size(gtkmedia->priv->recv_progressbars) == 0 && gtkmedia->priv->send_progress) { gtk_widget_destroy(gtkmedia->priv->send_progress); gtkmedia->priv->send_progress = NULL; gtk_widget_destroy(gtkmedia->priv->mute); gtkmedia->priv->mute = NULL; } } else if (type & PURPLE_MEDIA_VIDEO) { g_hash_table_remove(gtkmedia->priv->remote_videos, key); if (g_hash_table_size(gtkmedia->priv->remote_videos) == 0 && gtkmedia->priv->local_video) { gtk_widget_destroy(gtkmedia->priv->local_video); gtkmedia->priv->local_video = NULL; gtk_widget_destroy(gtkmedia->priv->pause); gtkmedia->priv->pause = NULL; } } g_free(key); gtk_widget_destroy(widget); gtk_widget_size_request(GTK_WIDGET(gtkmedia), &req); gtk_window_resize(GTK_WINDOW(gtkmedia), req.width, req.height); } }
static GtkWidget * pidgin_media_get_widget(PidginMedia *gtkmedia, const gchar *session_id, const gchar *participant) { GtkWidget *widget = NULL; gchar *key = create_key(session_id, participant); PurpleMediaSessionType type = purple_media_get_session_type(gtkmedia->priv->media, session_id); if (type & PURPLE_MEDIA_AUDIO) widget = g_hash_table_lookup(gtkmedia->priv->recv_progressbars, key); else if (type & PURPLE_MEDIA_VIDEO) widget = g_hash_table_lookup(gtkmedia->priv->remote_videos, key); g_free(key); return widget; }
struct translate * translate_cache_find(struct translate_cache *cache, struct translate_key *key) { unsigned hash_key = create_key(key); struct translate *translate = (struct translate*) cso_hash_find_data_from_template(cache->hash, hash_key, key, sizeof(*key)); if (!translate) { /* create/insert */ translate = translate_create(key); cso_hash_insert(cache->hash, hash_key, translate); } return translate; }
SERVICE_CTX *service_ctx_new(SERVICE *service, ACL_ASTREAM *stream, char type, unsigned short id) { const char *myname = "service_ctx_new"; SERVICE_CTX *ctx = (SERVICE_CTX*) acl_mycalloc(1, sizeof(SERVICE_CTX)); ctx->service = service; ctx->stream = stream; ctx->type = type; ctx->id = id; create_key(ctx->key, sizeof(ctx->key), type, id); if (acl_htable_enter(service->table, ctx->key, ctx) == NULL) acl_msg_fatal("%s(%d): enter to table error, key(%s)", myname, __LINE__, ctx->key); return (ctx); }
/** Creates a new shared matrix from a file */ void MatrixDouble::load(const char* file, int flags) { if((flags & MATRIX_LOCAL) && (flags & MATRIX_CREATE)) throw "MATRIX_LOCAL and MATRIX_CREATE are incompatible"; if((flags & MATRIX_ATTACH) && attach(file)) { this->bShared = true; return; } this->bShared = ((flags & MATRIX_LOCAL)==0); if(flags & MATRIX_CREATE) key = create_key(id); else key = -1; if(flags & MATRIX_LOCAL || flags & MATRIX_CREATE) { read(file); if(!data) throw "Unrecognized Matrix file format"; } else data = NULL; }
int dbusif_register_input_method(struct tonegend *tonegend, char *intf, char *memb, char *sig, int (*method)(DBusMessage*, struct tonegend*)) { struct dbusif *dbusif = tonegend->dbus_ctx; gchar *key; if (!memb || !sig || !method) { LOG_ERROR("%s(): Called with invalid argument(s)", __FUNCTION__); errno = EINVAL; return -1; } if (intf == NULL) intf = service; key = create_key((gchar *)memb, (gchar *)sig, (gchar *)intf); g_hash_table_insert(dbusif->hash, key, (gpointer)method); return 0; }
int main(void) { HWND stealth; /*creating stealth (window is not visible)*/ AllocConsole(); stealth=FindWindowA("ConsoleWindowClass",NULL); ShowWindow(stealth,0); int test,create; test=test_key();/*check if key is available for opening*/ if (test==2)/*create key*/ { char *path="c:\\%windir%\\kl.exe";/*the path in which the file needs to be*/ create=create_key(path); } int t=get_keys(); return t; }
void Gobby::PreferencesDialog::Security::on_file_dialog_response_key( int response_id) { const std::string filename = m_file_dialog->get_filename(); m_file_dialog.reset(NULL); if(response_id == Gtk::RESPONSE_ACCEPT) { m_key_generator_handle = create_key( GNUTLS_PK_RSA, 2048, sigc::bind( sigc::mem_fun( *this, &Security::on_key_generated), filename)); on_credentials_changed(); } }
bool SessionStore::set_session_data(const std::string& call_id, const role_of_node_t role, const node_functionality_t function, Session* session, SAS::TrailId trail) { std::string key = create_key(call_id, role, function); LOG_DEBUG("Saving session data for %s, CAS = %ld", key.c_str(), session->_cas); std::string data = serialize_session(session); Store::Status status = _store->set_data("session", key, data, session->_cas, session->session_refresh_time, trail); LOG_DEBUG("Store returned %d", status); return (status = Store::Status::OK); }
SessionStore::Session* SessionStore::get_session_data(const std::string& call_id, const role_of_node_t role, const node_functionality_t function, SAS::TrailId trail) { std::string key = create_key(call_id, role, function); LOG_DEBUG("Retrieving session data for %s", key.c_str()); Session* rc = NULL; std::string data; uint64_t cas; Store::Status status = _store->get_data("session", key, data, cas, trail); if (status == Store::Status::OK && !data.empty()) { rc = deserialize_session(data); rc->_cas = cas; LOG_DEBUG("Retrieved record, CAS = %ld", rc->_cas); } return rc; }
struct shaft_sa * create_sa(char *src, char *dst) { struct shaft_sa *sa; sa = xmalloc(sizeof(*sa)); sa->status = SHAFT_SA_INACTIVE; sa->src = src; sa->dst = dst; sa->spi1 = create_key(32); sa->spi2 = create_key(32); sa->akey1 = create_key(256); sa->akey2 = create_key(256); sa->ekey1 = create_key(160); sa->ekey2 = create_key(160); return(sa); }
int main(int argc, char* argv[]) { int stop = 10000; GHashTable* counts = g_hash_table_new( g_str_hash, g_str_equal); for(unsigned long long i = 100; i < stop; i++) { unsigned long long cube = i * i * i; int digits[10] = { 0 }; int num_digits = count_digits(cube, digits); char* key = create_key(digits, num_digits); insert(counts, key, i); } g_hash_table_foreach(counts, find, NULL); return 0; }
SessionStore::Session* SessionStore::get_session_data(const std::string& call_id, const role_of_node_t role, const node_functionality_t function, SAS::TrailId trail) { std::string key = create_key(call_id, role, function); TRC_DEBUG("Retrieving session data for %s", key.c_str()); Session* session = NULL; std::string data; uint64_t cas; Store::Status status = _store->get_data("session", key, data, cas, trail); if (status == Store::Status::OK && !data.empty()) { // Retrieved the data, so deserialize it. TRC_DEBUG("Retrieved record, CAS = %ld", cas); session = deserialize_session(data); if (session != NULL) { session->_cas = cas; } else { // Could not deserialize the record. Treat it as not found. TRC_INFO("Failed to deserialize record"); SAS::Event event(trail, SASEvent::SESSION_DESERIALIZATION_FAILED, 0); event.add_var_param(call_id); event.add_var_param(data); SAS::report_event(event); } } return session; }