Example #1
0
void silc_client_free(SilcClient client)
{
  if (client->schedule)
    silc_schedule_uninit(client->schedule);

  if (client->rng)
    silc_rng_free(client->rng);

  if (!client->internal->params->dont_register_crypto_library) {
    silc_cipher_unregister_all();
    silc_pkcs_unregister_all();
    silc_hash_unregister_all();
    silc_hmac_unregister_all();
  }

  if (client->internal->packet_engine)
    silc_packet_engine_stop(client->internal->packet_engine);
  if (client->internal->ftp_sessions)
    silc_dlist_uninit(client->internal->ftp_sessions);
  if (client->internal->lock)
    silc_mutex_free(client->internal->lock);
  silc_atomic_uninit32(&client->internal->conns);
  silc_free(client->username);
  silc_free(client->hostname);
  silc_free(client->realname);
  silc_free(client->internal->params);
  silc_free(client->internal->silc_client_version);
  silc_free(client->internal);
  silc_free(client);
}
Example #2
0
int main(int argc, char **argv)
{
  SilcBool success = FALSE;
  SilcSchedule schedule;
  SilcFSM fsm;
  Foo f;

  if (argc > 1 && !strcmp(argv[1], "-d")) {
    silc_log_debug(TRUE);
    silc_log_debug_hexdump(TRUE);
    silc_log_quick(TRUE);
    silc_log_set_debug_string("*fsm*,*async*");
  }

  SILC_LOG_DEBUG(("Allocating scheduler"));
  schedule = silc_schedule_init(0, NULL);

  f = silc_calloc(1, sizeof(*f));
  if (!f)
    goto err;
  f->schedule = schedule;

  SILC_LOG_DEBUG(("Allocating FSM context"));
  f->fsm = fsm = silc_fsm_alloc(f, destructor, f, schedule);
  if (!fsm)
    goto err;
  silc_fsm_start(fsm, test_st_start);

  SILC_LOG_DEBUG(("Running scheduler"));
  silc_schedule(schedule);

  if (f->error)
    goto err;

  silc_schedule_uninit(schedule);
  silc_free(f);

  success = TRUE;

 err:
  SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
  fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");

  return success;
}
Example #3
0
int main(int argc, char **argv)
{
  SilcFSM fsm;

  if (argc > 1 && !strcmp(argv[1], "-d")) {
    silc_log_debug(TRUE);
    silc_log_debug_hexdump(TRUE);
    silc_log_set_debug_string("*fdstream*");
  }

  SILC_LOG_DEBUG(("Allocating scheduler"));
  schedule = silc_schedule_init(0, NULL);
  if (!schedule)
    goto err;

  SILC_LOG_DEBUG(("Allocating FSM"));
  fsm = silc_fsm_alloc(NULL, fsm_dest, NULL, schedule);
  if (!fsm)
    goto err;

  silc_fsm_start(fsm, st_write);

  SILC_LOG_DEBUG(("Running scheduler"));
  silc_schedule(schedule);

  if (!success)
    goto err;

  silc_schedule_uninit(schedule);
  success = TRUE;

 err:
  SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
  fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");

  return success;
}
int main(int argc, char **argv)
{
  SilcFSM fsm;

  silc_runtime_init();

  if (argc > 1 && !strcmp(argv[1], "-d")) {
    silc_log_debug(TRUE);
    silc_log_debug_hexdump(TRUE);
    silc_log_set_debug_string("*thread*");
  }

  SILC_LOG_DEBUG(("Allocating scheduler"));
  schedule = silc_schedule_init(0, NULL, NULL, NULL);
  if (!schedule)
    goto err;

  SILC_LOG_DEBUG(("Allocating FSM context"));
  fsm = silc_fsm_alloc(NULL, destructor, NULL, schedule);
  if (!fsm)
    goto err;
  silc_fsm_start(fsm, test_st_start);

  SILC_LOG_DEBUG(("Running scheduler"));
  silc_schedule(schedule);

  silc_schedule_uninit(schedule);

 err:
  SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
  fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");

  silc_runtime_uninit();

  return !success;
}
Example #5
0
int main(int argc, char **argv)
{
  SilcBool success = FALSE;
  SilcSchedule schedule;
  SilcSKR skr;
  SilcSKRFind find;
  SilcPublicKey pk;

  if (argc > 1 && !strcmp(argv[1], "-d")) {
    silc_log_debug(TRUE);
    silc_log_debug_hexdump(TRUE);
    silc_log_set_debug_string("*skr*");
  }

  SILC_LOG_DEBUG(("Allocating scheduler"));
  schedule = silc_schedule_init(0, NULL, NULL);

  SILC_LOG_DEBUG(("Allocating SKR"));
  skr = silc_skr_alloc();
  if (!skr)
    goto err;

  SILC_LOG_DEBUG(("Adding public key to SKR"));
  pk = silc_calloc(1, sizeof(*pk));
  pk->len = 1;
  pk->pk_type = SILC_PKCS_SILC;
  pk->name = strdup("rsa");
  pk->pk = strdup("  ");
  pk->pk_len = 2;
  pk->identifier = silc_pkcs_encode_identifier("foo", "foo.com",
					       "Foo T. Bar", "*****@*****.**",
					       "ORG", "FI");
  silc_skr_add_public_key(skr, pk, 0, NULL);

  SILC_LOG_DEBUG(("Adding public key to SKR"));
  pk = silc_calloc(1, sizeof(*pk));
  pk->len = 1;
  pk->pk_type = SILC_PKCS_SILC;
  pk->name = strdup("rsa");
  pk->pk = strdup("  ");
  pk->pk_len = 2;
  pk->identifier = silc_pkcs_encode_identifier("bar", "bar.com",
					       "Bar T. Bar", "*****@*****.**",
					       "ORG", "FI");
  silc_skr_add_public_key(skr, pk, SILC_SKR_USAGE_IDENTIFICATION |
			  SILC_SKR_USAGE_AUTH, NULL);

  SILC_LOG_DEBUG(("Attempting to add key twice"));
  if (silc_skr_add_public_key(skr, pk, 0, NULL) == SILC_SKR_OK) {
    SILC_LOG_DEBUG(("Adding key twice not detected"));
    goto err;
  }

  SILC_LOG_DEBUG(("Finding public key by email"));
  find = silc_skr_find_alloc();
  silc_skr_find_set_email(find, "*****@*****.**");
  silc_skr_find(skr, schedule, find, skr_found, NULL);
  silc_skr_find_free(find);
  if (!found)
    goto err;

  SILC_LOG_DEBUG(("Finding public key by country"));
  find = silc_skr_find_alloc();
  silc_skr_find_set_country(find, "FI");
  silc_skr_find(skr, schedule, find, skr_found, NULL);
  silc_skr_find_free(find);
  if (!found)
    goto err;

  SILC_LOG_DEBUG(("Finding public key by country, ORG and hostname"));
  find = silc_skr_find_alloc();
  silc_skr_find_set_country(find, "FI");
  silc_skr_find_set_org(find, "ORG");
  silc_skr_find_set_host(find, "foo.com");
  silc_skr_find(skr, schedule, find, skr_found, NULL);
  silc_skr_find_free(find);
  if (!found)
    goto err;

  SILC_LOG_DEBUG(("Finding public key by SILC public key"));
  silc_skr_find_silc(skr, pk, skr_found, NULL);
  if (!found)
    goto err;

  SILC_LOG_DEBUG(("Finding public key by country and usage (must not find)"));
  find = silc_skr_find_alloc();
  silc_skr_find_set_country(find, "FI");
  silc_skr_find_set_usage(find, SILC_SKR_USAGE_ENC);
  silc_skr_find(skr, schedule, find, skr_found, NULL);
  silc_skr_find_free(find);
  if (found)
    goto err;

  SILC_LOG_DEBUG(("Finding public key by country and usage"));
  find = silc_skr_find_alloc();
  silc_skr_find_set_country(find, "FI");
  silc_skr_find_set_usage(find, SILC_SKR_USAGE_IDENTIFICATION);
  silc_skr_find(skr, schedule, find, skr_found, NULL);
  silc_skr_find_free(find);
  if (!found)
    goto err;

  silc_skr_free(skr);
  silc_schedule_uninit(schedule);

  success = TRUE;

 err:
  SILC_LOG_DEBUG(("Testing was %s", success ? "SUCCESS" : "FAILURE"));
  fprintf(stderr, "Testing was %s\n", success ? "SUCCESS" : "FAILURE");

  return success;
}