这篇教程C++ EVP_cleanup函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中EVP_cleanup函数的典型用法代码示例。如果您正苦于以下问题:C++ EVP_cleanup函数的具体用法?C++ EVP_cleanup怎么用?C++ EVP_cleanup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了EVP_cleanup函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: main//.........这里部分代码省略......... errorlog("ERROR: Can't exec fork()."); break; case 0: // in child logtitle = malloc((strlen(config.cap[i]->title)+24) * sizeof(char)); parent = 0; capindex = i; sprintf(logtitle, "viewssl daemon child [%s]", config.cap[capindex]->title); openlog(logtitle, LOG_PID, LOG_DAEMON); syslog(LOG_NOTICE,"started at %s",gettime()); break; default: // in parent childs.pid[childs.index] = pid; childs.title[childs.index] = malloc((strlen(config.cap[childs.index]->title)+1)*sizeof(char)); strcpy(childs.title[childs.index],config.cap[childs.index]->title); childs.index++; break; } // switch(pid) if (!parent) break; } // for (i=0;i<config.index;i++) signal(SIGTERM, fsignal); signal(SIGINT, fsignal); signal(SIGQUIT, fsignal); if (parent) { // in parent struct sockaddr_un uds_addr; struct sockaddr_un cl_addr; int ss=0, r=0; // master services socket // Master openlog("viewssl daemon master", LOG_PID, LOG_DAEMON); syslog(LOG_NOTICE, "started at %s", gettime()); ss = socket(PF_UNIX, SOCK_STREAM, 0); if (ss < 0) errorlog("socket() error."); memset(&uds_addr, 0, sizeof(uds_addr)); uds_addr.sun_family = AF_UNIX; strcpy(uds_addr.sun_path,SOCKPATH); unlink (SOCKPATH); r = bind(ss, (struct sockaddr *)&uds_addr, sizeof(uds_addr)); if (r < 0) errorlog("bind() error."); r = listen(ss, 10); if (r < 0) errorlog("listen() error."); while(1) { int cons=0; socklen_t cl_addr_len=0; memset (&cl_addr, 0, sizeof(cl_addr)); cons = accept(ss, (struct sockaddr*) &cl_addr, &cl_addr_len); close(cons); } close(ss); unlink (SOCKPATH); exit(EXIT_SUCCESS); // end master } else // child { signal(SIGCHLD, fsignal); } } // if (config.index > 1) else { // one thread openlog("viewssl daemon", LOG_PID, LOG_DAEMON); } SSL_library_init(); OpenSSL_add_all_ciphers(); OpenSSL_add_all_digests(); rc = proceed(); EVP_cleanup(); CRYPTO_cleanup_all_ex_data(); if (rc != 0) exit(EXIT_FAILURE); else exit(EXIT_SUCCESS); // end childs}
开发者ID:Jonnyliu,项目名称:viewssld,代码行数:101,
示例2: fopenunsigned char * AesFileEnc::key ( ){ FILE* keystore; keystore = fopen(this->keystore_path, "r"); unsigned char *iv = this->iv(32); unsigned char* key = new unsigned char[32]; const char *prompt; prompt = getpass("Your password to keystore: " ); unsigned char* sha; sha = SHA256(reinterpret_cast<const unsigned char*>(prompt), 32, NULL); //uwaga //printf("SHA %s aaa",(char *)sha); delete prompt; ERR_load_crypto_strings(); OpenSSL_add_all_algorithms(); OPENSSL_config(NULL); if(keystore == NULL) { keystore = fopen(this->keystore_path, "w+"); std::cout<<this->keystore_path; srand(time(0)); int j; char *buffer; buffer = new char; for(int i = 0 ; i<32; i++) { j = (int)(rand() / (RAND_MAX + 1.0) * 16); sprintf(buffer,"%x",j); key[i] = *buffer; } delete(buffer); unsigned char ciphertext[512]; int ciphertext_len; ciphertext_len = this->encrypt (key, 32, sha, iv, ciphertext); fprintf(keystore, "%s" ,(const char *)ciphertext); //printf("KLUCZ zapisywany:%s KKK %i" ,(const char *)ciphertext, ciphertext_len); }else{ unsigned char * decryptedtext = new unsigned char[512]; unsigned char* keycipher = new unsigned char[512]; int ciphertext_len = 0; int buff; while((buff = getc(keystore))!= EOF) { keycipher[ciphertext_len] = (unsigned char)buff; ciphertext_len++; } ciphertext_len--; //fscanf(keystore, "%512c", keycipher); int decryptedtext_len; //printf("KLUCZ wczytany:%s KKK %i" ,(const char *)keycipher, ciphertext_len); decryptedtext_len = decrypt(keycipher, ciphertext_len, sha, iv, decryptedtext); key = ( unsigned char *)decryptedtext;} unsigned char* KEY; KEY = new unsigned char[this->keyLength]; KEY[this->keyLength] = '/0'; printf("%s PIES /n",KEY); for(int i =0; i<this->keyLength; i++) {KEY[i] = key[i];} //delete(key); //delete(sha); //std::cout << "tutajkhjghjfghyt" <<std::endl; fclose(keystore); //std::cout<<this->keyLength <<std::endl; //printf("KLUCZ %s",KEY); std::cout << (const char *)KEY<<"PIES"<<std::endl; std::cout <<key<<"PIES"<<std::endl; EVP_cleanup(); ERR_free_strings(); return KEY; }
开发者ID:MichalKupczynski,项目名称:kryptografia,代码行数:84,
示例3: finalizeDigiDocLib//--------------------------------------------------// cleanup of DigiDoc library//--------------------------------------------------EXP_OPTION void finalizeDigiDocLib(){ ERR_free_strings(); EVP_cleanup();}
开发者ID:Krabi,项目名称:idkaart_public,代码行数:8,
示例4: mainint main(int argc, char *argv[]) { unsigned int bundleLength=0, urlLength=0; if (argc == 3) { printf("UNSUPPORTED/n"); //for now at least return EXIT_SUCCESS; } else if (argc != 4) { printf("usage: %s <host> <port> <ca-bundle>/n", argv[0]); return EXIT_FAILURE; } else if ((urlLength = strlen(argv[1]) + strlen(argv[2]) + 2) > MAX_LENGTH) { printf("Too long URL: %d characters, max: %d/n", urlLength, MAX_LENGTH); return EXIT_FAILURE; } else if ((bundleLength = strlen(argv[3]) + 1) > MAX_LENGTH) { printf("Too long ca-bundle filepath: %d characters, max: %d/n", bundleLength, MAX_LENGTH); return EXIT_FAILURE; } char url[1024]; snprintf(url, sizeof(url), "%s:%s", argv[1], argv[2]); char ca_bundle[1024]; memcpy(ca_bundle, argv[3], bundleLength); int exitvalue = 0; BIO *sbio; SSL_CTX *ssl_ctx; SSL *ssl; X509 *cert; const char *servername = NULL; X509_VERIFY_PARAM *param = NULL; SSL_load_error_strings(); SSL_library_init(); ssl_ctx = SSL_CTX_new(TLS_method()); //if you are using an older version of openssl, you may need to change this into for example: TLSv1_2_client_method param = SSL_CTX_get0_param(ssl_ctx); //set certificate verify //https://wiki.openssl.org/index.php/Hostname_validation X509_VERIFY_PARAM_set_hostflags(param, X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS); X509_VERIFY_PARAM_set1_host(param, argv[1], 0); SSL_CTX_set_verify(ssl_ctx, SSL_VERIFY_PEER, NULL); if (SSL_CTX_load_verify_locations(ssl_ctx, ca_bundle, NULL) != 1) { printf("Couldn't load certificate trust store/n"); printf("%s/n", ERR_reason_error_string(ERR_get_error())); exitvalue=EXIT_FAILURE; goto end; } sbio = BIO_new_ssl_connect(ssl_ctx); BIO_get_ssl(sbio, &ssl); if (!ssl) { printf("Connection failed/n"); printf("%s/n", ERR_reason_error_string(ERR_get_error())); exitvalue=EXIT_FAILURE; goto connect_end; } //handshake SSL_set_tlsext_host_name(ssl, url); BIO_set_conn_hostname(sbio, url); if(SSL_do_handshake(ssl) <= 0) { unsigned long int error = ERR_get_error(); printf("%s/n", ERR_reason_error_string(error)); printf("REJECT/n"); } else { printf ("ACCEPT/n"); }connect_end: BIO_free_all(sbio);end: SSL_CTX_free(ssl_ctx); EVP_cleanup(); ERR_free_strings(); return exitvalue;}
开发者ID:ouspg,项目名称:trytls,代码行数:80,
示例5: libwebsocket_context_destroy/** * libwebsocket_context_destroy() - Destroy the websocket context * @context: Websocket context * * This function closes any active connections and then frees the * context. After calling this, any further use of the context is * undefined. */LWS_VISIBLE voidlibwebsocket_context_destroy(struct libwebsocket_context *context){ int n; struct libwebsocket_protocols *protocol = context->protocols;#ifdef LWS_LATENCY if (context->worst_latency_info[0]) lwsl_notice("Worst latency: %s/n", context->worst_latency_info);#endif for (n = 0; n < context->fds_count; n++) { struct libwebsocket *wsi = context->lws_lookup[context->fds[n].fd]; if (!wsi) continue; libwebsocket_close_and_free_session(context, wsi, LWS_CLOSE_STATUS_NOSTATUS /* no protocol close */); n--; } /* * give all extensions a chance to clean up any per-context * allocations they might have made */ if (context->listen_port) { if (lws_ext_callback_for_each_extension_type(context, NULL, LWS_EXT_CALLBACK_SERVER_CONTEXT_DESTRUCT, NULL, 0) < 0) return; } else if (lws_ext_callback_for_each_extension_type(context, NULL, LWS_EXT_CALLBACK_CLIENT_CONTEXT_DESTRUCT, NULL, 0) < 0) return; /* * inform all the protocols that they are done and will have no more * callbacks */ while (protocol->callback) { protocol->callback(context, NULL, LWS_CALLBACK_PROTOCOL_DESTROY, NULL, NULL, 0); protocol++; } lws_plat_context_early_destroy(context);#ifdef LWS_OPENSSL_SUPPORT if (context->ssl_ctx) SSL_CTX_free(context->ssl_ctx); if (context->ssl_client_ctx) SSL_CTX_free(context->ssl_client_ctx); ERR_remove_state(0); ERR_free_strings(); EVP_cleanup(); CRYPTO_cleanup_all_ex_data();#endif if (context->fds) free(context->fds); if (context->lws_lookup) free(context->lws_lookup); free(context); lws_plat_context_late_destroy(context);}
开发者ID:hoangtuanbs,项目名称:libwebsockets,代码行数:76,
示例6: Init_openssl//.........这里部分代码省略......... * puts ssl_client.gets * * If the server certificate is invalid or <tt>context.ca_file</tt> is not set * when verifying peers an OpenSSL::SSL::SSLError will be raised. * */voidInit_openssl(void){ /* * Init timezone info */#if 0 tzset();#endif /* * Init all digests, ciphers */ /* CRYPTO_malloc_init(); */ /* ENGINE_load_builtin_engines(); */ OpenSSL_add_ssl_algorithms(); OpenSSL_add_all_algorithms(); ERR_load_crypto_strings(); SSL_load_error_strings(); /* * FIXME: * On unload do: */#if 0 CONF_modules_unload(1); destroy_ui_method(); EVP_cleanup(); ENGINE_cleanup(); CRYPTO_cleanup_all_ex_data(); ERR_remove_state(0); ERR_free_strings();#endif /* * Init main module */ mOSSL = rb_define_module("OpenSSL"); rb_global_variable(&mOSSL); /* * OpenSSL ruby extension version */ rb_define_const(mOSSL, "VERSION", rb_str_new2(OSSL_VERSION)); /* * Version of OpenSSL the ruby OpenSSL extension was built with */ rb_define_const(mOSSL, "OPENSSL_VERSION", rb_str_new2(OPENSSL_VERSION_TEXT)); /* * Version of OpenSSL the ruby OpenSSL extension is running with */ rb_define_const(mOSSL, "OPENSSL_LIBRARY_VERSION", rb_str_new2(SSLeay_version(SSLEAY_VERSION))); /* * Version number of OpenSSL the ruby OpenSSL extension was built with * (base 16) */ rb_define_const(mOSSL, "OPENSSL_VERSION_NUMBER", INT2NUM(OPENSSL_VERSION_NUMBER));
开发者ID:DashYang,项目名称:sim,代码行数:67,
示例7: hcrypt_library_exitvoid hcrypt_library_exit(void){ ERR_free_strings(); EVP_cleanup();}
开发者ID:sara62,项目名称:hcrypt,代码行数:5,
示例8: main//.........这里部分代码省略.........#ifdef SHOW_SPLASH if (!no_statistics) splash_screen();#endif /* SHOW_SPLASH */ if (!no_statistics) SAY("/x1b[H/x1b[J"); else SAY(cLGN "[*] " cBRI "Scan in progress, please stay tuned.../n"); /* Enter the crawler loop */ while ((next_from_queue() && !stop_soon) || (!show_once++)) { u8 keybuf[8]; u64 end_time; u64 run_time; struct timeval tv_tmp; gettimeofday(&tv_tmp, NULL); end_time = tv_tmp.tv_sec * 1000LL + tv_tmp.tv_usec / 1000; run_time = end_time - st_time; if (gtimeout > 0 && run_time && run_time/1000 > gtimeout) { DEBUG("* Stopping scan due to timeout/n"); stop_soon = 1; } req_sec = (req_count - queue_cur / 1.15) * 1000 / (run_time + 1); if (no_statistics || ((loop_cnt++ % 100) && !show_once && idle == 0)) continue; if (clear_screen) { SAY("/x1b[H/x1b[2J"); clear_screen = 0; } SAY(cYEL "/x1b[H" "skipfish version " VERSION " by <[email C++ EVP_des_cbc函数代码示例 C++ EVP_aes_256_cbc函数代码示例
|