本文整理汇总了C++中EVP_cleanup函数的典型用法代码示例。如果您正苦于以下问题:C++ EVP_cleanup函数的具体用法?C++ EVP_cleanup怎么用?C++ EVP_cleanup使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EVP_cleanup函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例2: fopen
unsigned 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;
}
示例3: finalizeDigiDocLib
//--------------------------------------------------
// cleanup of DigiDoc library
//--------------------------------------------------
EXP_OPTION void finalizeDigiDocLib()
{
ERR_free_strings();
EVP_cleanup();
}
示例4: main
int 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;
}
示例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 void
libwebsocket_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);
}
示例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.
*
*/
void
Init_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));
示例7: hcrypt_library_exit
void hcrypt_library_exit(void)
{
ERR_free_strings();
EVP_cleanup();
}
示例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 protected]>\n\n"
cBRI " -" cPIN " %s " cBRI "-\n\n" cNOR,
allow_domains[0]);
if (!display_mode) {
http_stats(st_time);
SAY("\n");
database_stats();
} else {
http_req_list();
}
SAY(" \r");
if (fread(keybuf, 1, sizeof(keybuf), stdin) > 0) {
display_mode ^= 1;
clear_screen = 1;
}
}
gettimeofday(&tv, NULL);
en_time = tv.tv_sec * 1000LL + tv.tv_usec / 1000;
SAY("\n");
if (stop_soon)
SAY(cYEL "[!] " cBRI "Scan aborted by user, bailing out!" cNOR "\n");
term.c_lflag |= ICANON;
tcsetattr(0, TCSANOW, &term);
fcntl(0, F_SETFL, O_SYNC);
save_keywords((u8*)wordlist);
write_report(output_dir, en_time - st_time, seed);
#ifdef LOG_STDERR
SAY("\n== PIVOT DEBUG ==\n");
dump_pivots(0, 0);
SAY("\n== END OF DUMP ==\n\n");
#endif /* LOG_STDERR */
SAY(cLGN "[+] " cBRI "This was a great day for science!" cRST "\n\n");
#ifdef DEBUG_ALLOCATOR
if (!stop_soon) {
destroy_database();
destroy_http();
destroy_signatures();
__TRK_report();
}
#endif /* DEBUG_ALLOCATOR */
fflush(0);
EVP_cleanup();
CRYPTO_cleanup_all_ex_data();
return 0;
}
示例9: main
//.........这里部分代码省略.........
printf(" e.g. 471C6ABB3CAD5CD41509F961EDD3A2E08E76F61FF6D63412B79E9D500257A06A\n\n");
printf(" <iv> - 128 bit initialisation vector to be used for the encryption represented as a 32 character hex string\n");
printf(" e.g. 743D32B3BEDEEAF5\n\n");
exit(EXIT_FAILURE);
}
//Open the input file
FILE *in = fopen(argv[1], "r");
if (!in) {
printf("Error! Could not open input file\n");
exit(EXIT_FAILURE);
}
//Open the output file
FILE *out = fopen(argv[2], "w");
if (!out) {
printf("Error! Could not open output file\n");
exit(EXIT_FAILURE);
}
//Get key and iv
if (get_key(argv[3], key) != 0 || get_iv(argv[4], iv) != 0) {
printf("Error! Bad parameters\n");
exit(EXIT_FAILURE);
}
//Prepare input buffer
//Determine lenght of the input and allocate a buffer to store it.
fseek(in, 0L, SEEK_END);
plaintext_len = ftell(in);
printf("length of plaintext: %d\n", plaintext_len);
fseek(in, 0L, SEEK_SET);
if (plaintext_len <= 0) {
printf("Error! Input file is empty\n");
exit(EXIT_FAILURE);
}
plaintext = malloc(sizeof(char) * plaintext_len);
if (!plaintext) {
printf("Error! Could not allocate memory for input buffer\n");
exit(EXIT_FAILURE);
}
memset(plaintext, '\0', sizeof(char) * plaintext_len);
//Read the file data into the input buffer
fread(plaintext, 1, plaintext_len, in);
//Prepare the output buffer
//Calculate the length of the input data in blocks (128 bit (32 bytes) for AES).
rem = plaintext_len % AES_BLOCK_SIZE;
num_of_blocks = (plaintext_len - rem) / AES_BLOCK_SIZE;
if (rem != 0) {
num_of_blocks++; //Add an extra block as the the input data is not an exact multiple of blocks.
}
ciphertext_len = num_of_blocks * AES_BLOCK_SIZE; //Total memory to allocate is num of blocks times block size
printf("number of blocks: %d\ntotal buffer to allocate: %d\n",num_of_blocks, ciphertext_len);
ciphertext = malloc(sizeof(char) * ciphertext_len);
if (!ciphertext) {
printf("Error! Could not allocate memory for output buffer\n");
exit(EXIT_FAILURE);
}
memset(ciphertext, '\0', sizeof(char) * ciphertext_len);
/* Encrypt the plaintext */
ciphertext_len =
encrypt(plaintext, plaintext_len, key, iv, ciphertext);
printf("length of ciphertext: %d\n", ciphertext_len);
for (i = 0; i < ciphertext_len; i++) {
fwrite(&ciphertext[i], sizeof(unsigned char), 1, out);
}
sync(); //Force output flush
free(plaintext);
free(ciphertext);
fclose(in);
fclose(out);
/* Clean up */
EVP_cleanup();
ERR_free_strings();
return 0;
}
示例10: main
//.........这里部分代码省略.........
tvhftrace("main", channel_done);
tvhftrace("main", bouquet_done);
tvhftrace("main", dvr_done);
tvhftrace("main", subscription_done);
tvhftrace("main", access_done);
tvhftrace("main", epg_done);
tvhftrace("main", avahi_done);
tvhftrace("main", bonjour_done);
tvhftrace("main", imagecache_done);
tvhftrace("main", lang_code_done);
tvhftrace("main", api_done);
tvhtrace("main", "tasklet enter");
pthread_cond_signal(&tasklet_cond);
pthread_join(tasklet_tid, NULL);
tvhtrace("main", "tasklet thread end");
tasklet_flush();
tvhtrace("main", "tasklet leave");
tvhftrace("main", hts_settings_done);
tvhftrace("main", dvb_done);
tvhftrace("main", lang_str_done);
tvhftrace("main", esfilter_done);
tvhftrace("main", profile_done);
tvhftrace("main", intlconv_done);
tvhftrace("main", urlparse_done);
tvhftrace("main", idnode_done);
tvhftrace("main", notify_done);
tvhftrace("main", spawn_done);
tvhlog(LOG_NOTICE, "STOP", "Exiting HTS Tvheadend");
tvhlog_end();
tvhftrace("main", config_done);
if(opt_fork)
unlink(opt_pidpath);
#if ENABLE_TSFILE
free(opt_tsfile.str);
#endif
free(opt_satip_xml.str);
/* OpenSSL - welcome to the "cleanup" hell */
ENGINE_cleanup();
RAND_cleanup();
CRYPTO_cleanup_all_ex_data();
EVP_cleanup();
CONF_modules_free();
#ifndef OPENSSL_NO_COMP
COMP_zlib_cleanup();
#endif
ERR_remove_state(0);
ERR_free_strings();
#ifndef OPENSSL_NO_COMP
sk_SSL_COMP_free(SSL_COMP_get_compression_methods());
#endif
/* end of OpenSSL cleanup code */
#if ENABLE_DBUS_1
extern void dbus_shutdown(void);
if (opt_dbus) dbus_shutdown();
#endif
tvh_gettext_done();
return 0;
}
/**
*
*/
void
tvh_str_set(char **strp, const char *src)
{
free(*strp);
*strp = src ? strdup(src) : NULL;
}
/**
*
*/
int
tvh_str_update(char **strp, const char *src)
{
if(src == NULL)
return 0;
free(*strp);
*strp = strdup(src);
return 1;
}
/**
*
*/
void
scopedunlock(pthread_mutex_t **mtxp)
{
pthread_mutex_unlock(*mtxp);
}
示例11: main
main(int argc, char *argv[])
{
EVP_MD_CTX *mdctx;
EVP_MD_CTX *mdctxdup;
const EVP_MD *md;
const EVP_MD *mddup;
char mess1[] = "Hello World";
unsigned char md_value[EVP_MAX_MD_SIZE];
unsigned char md_valuedup[EVP_MAX_MD_SIZE];
int md_len,md_lendup, i;
char originalBinary[24];
char randomBinary[24];
OpenSSL_add_all_digests();
if(!argv[1]) {
printf("Usage: mdtest digestname\n");
exit(1);
}
md = EVP_get_digestbyname(argv[1]) ;
if(!md) {
printf("Unknown message digest %s\n", argv[1]);
exit(1);
}
mdctx = EVP_MD_CTX_create();
EVP_DigestInit_ex(mdctx, md, NULL);
EVP_DigestUpdate(mdctx, mess1, strlen(mess1));
EVP_DigestFinal_ex(mdctx, md_value, &md_len);
EVP_MD_CTX_destroy(mdctx);
printf("Input Original: %s\n",mess1);
printf("Digest Original: ");
for(i = 0; i < md_len; i++)
printf("%02x", md_value[i]);
printf("\n");
int dontExit =1;
char *str ;
while(dontExit)
{
str = (char*)malloc(10);
str = rand_string(str,9);
mdctxdup = EVP_MD_CTX_create();
EVP_DigestInit_ex(mdctxdup, md, NULL);
EVP_DigestUpdate(mdctxdup, str, strlen(str));
EVP_DigestFinal_ex(mdctxdup, md_valuedup, &md_lendup);
EVP_MD_CTX_destroy(mdctxdup);
if((md_value[0] == md_valuedup[0]) && (md_value[1] == md_valuedup[1]) && (md_value[2] == md_valuedup[2]) )
{
break;
}
free(str);
}
printf("Input Random: %s\n",str);
printf("Digest Random: ");
for(i = 0; i < md_lendup; i++)
printf("%02x", md_valuedup[i]);
printf("\n");
/* Call this once before exit. */
EVP_cleanup();
exit(0);
}
示例12: main
//.........这里部分代码省略.........
min_len = prefix_len + suffix_len + 1;
}
if(max_len < min_len)
{
fprintf(stderr, "Warning: maximum length (%u) is smaller than minimum length (%u). Setting maximum length to %u.\n\n", max_len, min_len, min_len);
max_len = min_len;
}
/* Check header */
fd = open(filename, O_RDONLY);
if(fd == -1)
{
perror("open file");
exit(EXIT_FAILURE);
}
memset(salt, 0, sizeof(salt));
ret = read(fd, salt, 8);
if(strncmp(salt, "Salted__", 8) != 0)
{
close(fd);
fprintf(stderr, "Error: %s is not a salted openssl file.\n\n", filename);
exit(EXIT_FAILURE);
}
/* Read salt */
ret = read(fd, salt, 8);
if(ret != 8)
{
close(fd);
fprintf(stderr, "Error: could not read salt.\n\n");
exit(EXIT_FAILURE);
}
/* Read encrypted data */
ret = fstat(fd, &file_stats);
data_len = file_stats.st_size - 16;
data = (char *) malloc(data_len);
if(data == NULL)
{
fprintf(stderr, "Error: memory allocation failed.\n\n");
exit(EXIT_FAILURE);
}
for(i = 0; i < data_len;)
{
ret = read(fd, data + i, data_len - i);
if(ret == -1)
{
close(fd);
fprintf(stderr, "Error: could not read data.\n\n");
exit(EXIT_FAILURE);
}
else if(ret > 0)
i += ret;
}
close(fd);
pthread_mutex_init(&found_password_lock, NULL);
/* Start decryption threads */
decryption_threads = (pthread_t *) malloc(nb_threads * sizeof(pthread_t));
indexes = (unsigned int **) malloc(nb_threads * sizeof(unsigned int *));
if((decryption_threads == NULL) || (indexes == NULL))
{
fprintf(stderr, "Error: memory allocation failed.\n\n");
exit(EXIT_FAILURE);
}
for(i = 0; i < nb_threads; i++)
{
indexes[i] = (unsigned int *) malloc(2 * sizeof(unsigned int));
if(indexes[i] == NULL)
{
fprintf(stderr, "Error: memory allocation failed.\n\n");
exit(EXIT_FAILURE);
}
indexes[i][0] = i * (charset_len / nb_threads);
if(i == nb_threads - 1)
indexes[i][1] = charset_len - 1;
else
indexes[i][1] = (i + 1) * (charset_len / nb_threads) - 1;
ret = pthread_create(&decryption_threads[i], NULL, &decryption_func, indexes[i]);
if(ret != 0)
{
perror("decryption thread");
exit(EXIT_FAILURE);
}
}
for(i = 0; i < nb_threads; i++)
{
pthread_join(decryption_threads[i], NULL);
free(indexes[i]);
}
free(indexes);
free(decryption_threads);
pthread_mutex_destroy(&found_password_lock);
free(data);
EVP_cleanup();
exit(EXIT_SUCCESS);
}
示例13: apn_ssl_free
void apn_ssl_free() {
ERR_free_strings();
EVP_cleanup();
}
示例14: R_unload_openssl
void R_unload_openssl(DllInfo *info) {
ERR_free_strings();
EVP_cleanup();
}
示例15: qore_cleanup
// NOTE: we do not cleanup in reverse initialization order
// the threading subsystem is deleted before the modules are
// unloaded in case there are any module-specific thread
// cleanup functions to be run...
void qore_cleanup() {
// first delete all user modules
QMM.delUser();
#ifdef _Q_WINDOWS
// do windows socket cleanup
WSACleanup();
#endif
#ifdef HAVE_SIGNAL_HANDLING
// stop signal manager
QSM.del();
#endif
// purge thread resources before deleting modules
{
ExceptionSink xsink;
purge_thread_resources(&xsink);
}
// delete all loadable modules
QMM.cleanup();
// delete thread-local data
delete_thread_local_data();
// now free memory (like ARGV, QORE_ARGV, ENV, etc)
delete_global_variables();
// delete pseudo-methods
pseudo_classes_del();
// delete static system namespace after modules
delete staticSystemNamespace;
#ifdef DEBUG
staticSystemNamespace = 0;
#endif
// delete default type values
delete_qore_types();
// delete threading infrastructure
delete_qore_threads();
// only perform openssl cleanup if not performed externally
if (!qore_check_option(QLO_DISABLE_OPENSSL_CLEANUP)) {
// cleanup openssl library
ERR_free_strings();
ENGINE_cleanup();
EVP_cleanup();
CONF_modules_finish();
CONF_modules_free();
CONF_modules_unload(1);
CRYPTO_cleanup_all_ex_data();
CRYPTO_set_id_callback(0);
CRYPTO_set_locking_callback(0);
// delete openssl locks
for (mutex_vec_t::iterator i = q_openssl_mutex_list.begin(), e = q_openssl_mutex_list.end(); i != e; ++i)
delete *i;
}
printd(5, "qore_cleanup() exiting cleanly\n");
}