static void gcr_secret_exchange_class_init (GcrSecretExchangeClass *klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); gobject_class->get_property = gcr_secret_exchange_get_property; gobject_class->set_property = gcr_secret_exchange_set_property; gobject_class->finalize = gcr_secret_exchange_finalize; klass->generate_exchange_key = gcr_secret_exchange_default_generate_exchange_key; klass->derive_transport_key = gcr_secret_exchange_default_derive_transport_key; klass->decrypt_transport_data = gcr_secret_exchange_default_decrypt_transport_data; klass->encrypt_transport_data = gcr_secret_exchange_default_encrypt_transport_data; g_type_class_add_private (gobject_class, sizeof (GcrSecretExchangePrivate)); egg_libgcrypt_initialize (); /** * GcrSecretExchange:protocol: * * The protocol being used for the exchange. * * Will be %NULL if no protocol was specified when creating this object, * and either gcr_secret_exchange_begin() or gcr_secret_exchange_receive() * have not been called successfully. */ g_object_class_install_property (gobject_class, PROP_PROTOCOL, g_param_spec_string ("protocol", "Protocol", "Exchange protocol", GCR_SECRET_EXCHANGE_PROTOCOL_1, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); }
int main (int argc, char **argv) { g_test_init (&argc, &argv, NULL); egg_libgcrypt_initialize (); g_test_add_func ("/symkey/generate_key_simple", test_generate_key_simple); g_test_add_func ("/symkey/generate_key_pkcs12", test_generate_key_pkcs12); g_test_add_func ("/symkey/generate_key_pbkdf2", test_generate_key_pbkdf2); g_test_add_func ("/symkey/generate_key_pbe", test_generate_key_pbe); return g_test_run (); }
int main (int argc, char **argv) { #if !GLIB_CHECK_VERSION(2,35,0) g_type_init (); #endif egg_libgcrypt_initialize(); g_test_init (&argc, &argv, NULL); g_test_add ("/gkm/data-asn1/integers", Test, NULL, setup, test_asn1_integers, teardown); g_test_add ("/gkm/data-asn1/string_mpi", Test, NULL, setup, test_asn1_string_mpi, teardown); g_test_add ("/gkm/data-asn1/bit_string", Test, NULL, setup, test_asn1_bit_string, teardown); g_test_add ("/gkm/data-asn1/string", Test, NULL, setup, test_asn1_string, teardown); g_test_add ("/gkm/data-asn1/oid", Test, NULL, setup, test_asn1_oid, teardown); return g_test_run (); }
static GVariant * request_open_session_aes (SecretSession *session) { gcry_error_t gcry; gcry_mpi_t base; unsigned char *buffer; size_t n_buffer; GVariant *argument; g_assert (session->prime == NULL); g_assert (session->privat == NULL); g_assert (session->publi == NULL); egg_libgcrypt_initialize (); /* Initialize our local parameters and values */ if (!egg_dh_default_params ("ietf-ike-grp-modp-1024", &session->prime, &base)) g_return_val_if_reached (NULL); #if 0 g_printerr ("\n lib prime: "); gcry_mpi_dump (session->prime); g_printerr ("\n lib base: "); gcry_mpi_dump (base); g_printerr ("\n"); #endif if (!egg_dh_gen_pair (session->prime, base, 0, &session->publi, &session->privat)) g_return_val_if_reached (NULL); gcry_mpi_release (base); gcry = gcry_mpi_aprint (GCRYMPI_FMT_USG, &buffer, &n_buffer, session->publi); g_return_val_if_fail (gcry == 0, NULL); argument = g_variant_new_from_data (G_VARIANT_TYPE ("ay"), buffer, n_buffer, TRUE, gcry_free, buffer); return g_variant_new ("(sv)", ALGORITHMS_AES, argument); }
/** * main: * @argc: * @argv[]: Sent to gtk_init * * Prompt for GnuPG and SSH. Communicates using stdin/stdout. Communication data * is in ini-file structures * * Returns: 0 */ int main (int argc, char *argv[]) { GError *err = NULL; gchar *data; gboolean ret; gsize length; /* Exit on HUP signal */ signal(SIGINT, hup_handler); prepare_logging (); egg_libgcrypt_initialize (); input_data = g_key_file_new (); output_data = g_key_file_new (); gtk_init (&argc, &argv); #ifdef HAVE_LOCALE_H /* internationalisation */ setlocale (LC_ALL, ""); #endif #ifdef HAVE_GETTEXT bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); textdomain (GETTEXT_PACKAGE); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif data = read_all_input (); g_assert (data); if (!data[0]) fatal ("no auth dialog instructions", NULL); ret = g_key_file_load_from_data (input_data, data, strlen (data), G_KEY_FILE_NONE, &err); g_free (data); if (!ret) fatal ("couldn't parse auth dialog instructions", egg_error_message (err)); run_dialog (); /* Cleanup after any key */ if (the_key) { egg_secure_clear (the_key, n_the_key); egg_secure_free (the_key); the_key = NULL; n_the_key = 0; } g_key_file_free (input_data); data = g_key_file_to_data (output_data, &length, &err); g_key_file_free (output_data); if (!data) fatal ("couldn't format auth dialog response: %s", egg_error_message (err)); write_all_output (data, length); g_free (data); return 0; }
int main (int argc, char *argv[]) { /* * The gnome-keyring startup is not as simple as I wish it could be. * * It's often started in the primordial stages of a session, where * there's no DBus, and no proper X display. This is the strange world * of PAM. * * When started with the --login option, we do as little initialization * as possible. We expect a login password on the stdin, and unlock * or create the login keyring. * * Then later we expect gnome-keyring-dameon to be run again with the * --start option. This second gnome-keyring-daemon will hook the * original daemon up with environment variables necessary to initialize * itself and bring it into the session. This second daemon usually exits. * * Without either of these options, we follow a more boring and * predictable startup. */ /* * Before we do ANYTHING, we drop privileges so we don't become * a security issue ourselves. */ gkd_capability_obtain_capability_and_drop_privileges (); #ifdef WITH_STRICT g_setenv ("DBUS_FATAL_WARNINGS", "1", FALSE); if (!g_getenv ("G_DEBUG")) g_log_set_always_fatal (G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING); #endif #if !GLIB_CHECK_VERSION(2,35,0) g_type_init (); #endif #ifdef HAVE_LOCALE_H /* internationalisation */ setlocale (LC_ALL, ""); #endif #ifdef HAVE_GETTEXT bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); textdomain (GETTEXT_PACKAGE); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif egg_libgcrypt_initialize (); /* Send all warning or error messages to syslog */ prepare_logging (); parse_arguments (&argc, &argv); /* The --version option. This is machine parseable output */ if (run_version) { g_print ("gnome-keyring-daemon: %s\n", VERSION); g_print ("testing: %s\n", #ifdef WITH_DEBUG "enabled"); #else "disabled"); #endif exit (0); } /* The --start option */ if (run_for_start) { if (discover_other_daemon (initialize_daemon_at, TRUE)) { /* * Another daemon was initialized, print out environment * for any callers, and quit or go comatose. */ print_environment (); if (run_foreground) while (sleep(0x08000000) == 0); cleanup_and_exit (0); } /* The --replace option */ } else if (run_for_replace) { discover_other_daemon (replace_daemon_at, FALSE); if (control_directory) g_message ("Replacing daemon, using directory: %s", control_directory); else g_message ("Could not find daemon to replace, staring normally"); } /* Initialize the main directory */ gkd_util_init_master_directory (control_directory); /* Initialize our daemon main loop and threading */ loop = g_main_loop_new (NULL, FALSE); /* Initialize our control socket */ if (!gkd_control_listen ()) return FALSE; if (perform_unlock) { login_password = read_login_password (STDIN); atexit (clear_login_password); } /* The --login option. Delayed initialization */ if (run_for_login) { timeout_id = g_timeout_add_seconds (LOGIN_TIMEOUT, (GSourceFunc) on_login_timeout, NULL); /* Not a login daemon. Startup stuff now.*/ } else { /* These are things that can run before forking */ if (!gkr_daemon_startup_steps (run_components)) cleanup_and_exit (1); } signal (SIGPIPE, SIG_IGN); /* The whole forking and daemonizing dance starts here. */ fork_and_print_environment(); g_unix_signal_add (SIGTERM, on_signal_term, loop); g_unix_signal_add (SIGHUP, on_signal_term, loop); g_unix_signal_add (SIGUSR1, on_signal_usr1, loop); /* Prepare logging a second time, since we may be in a different process */ prepare_logging(); /* Remainder initialization after forking, if initialization not delayed */ if (!run_for_login) { gkr_daemon_initialize_steps (run_components); /* * Close stdout and so that the caller knows that we're * all initialized, (when run in foreground mode). * * However since some logging goes to stdout, redirect that * to stderr. We don't want the caller confusing that with * valid output anyway. */ if (dup2 (2, 1) < 1) g_warning ("couldn't redirect stdout to stderr"); g_debug ("initialization complete"); } g_main_loop_run (loop); /* This wraps everything up in order */ egg_cleanup_perform (); g_free (control_directory); g_debug ("exiting cleanly"); return 0; }
void gkm_crypto_initialize (void) { egg_libgcrypt_initialize (); }