diff --git a/extensions/formhistory/formhistory-crypt.c b/extensions/formhistory/formhistory-crypt.c deleted file mode 100644 index 3c968c0c..00000000 --- a/extensions/formhistory/formhistory-crypt.c +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2009-2012 Alexander Butenko - Copyright (C) 2009-2012 Christian Dywan - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. -*/ -#include -#include -#include -#include -#include -#define BUF_SIZE 256 - -typedef unsigned char uc; - -const char *iv ="12345678"; - -gchar* -formhistory_encrypt (const gchar* input, - const gchar* key) -{ - int outlen=0, auxlen=0; - EVP_CIPHER_CTX ctx; - size_t inputSize; - char buff[BUF_SIZE]; - - if (!input) - return NULL; - - inputSize = strlen (input); - memset (&buff[0], '\0', BUF_SIZE); - - EVP_CIPHER_CTX_init (&ctx); - EVP_EncryptInit (&ctx, EVP_bf_cbc (), (unsigned char*)key, (unsigned char*)iv); - - if (EVP_EncryptUpdate (&ctx, (uc*)&buff, &outlen, (uc*)input, inputSize) != 1) - return NULL; - if (EVP_EncryptFinal (&ctx, (uc*)&buff + outlen, &auxlen) != 1) - return NULL; - - outlen += auxlen; - EVP_CIPHER_CTX_cleanup (&ctx); - return g_base64_encode ((const guchar*)&buff, outlen); -} - -gchar* -formhistory_decrypt (const gchar* b64input, - const gchar* key) -{ - int outlen=0, auxlen=0; - EVP_CIPHER_CTX ctx; - char buff[BUF_SIZE]; - guchar* input; - size_t inputSize; - - if (!b64input) - return NULL; - - input = g_base64_decode (b64input, &inputSize); - memset (&buff, 0, BUF_SIZE); - - EVP_CIPHER_CTX_init (& ctx); - EVP_DecryptInit (& ctx, EVP_bf_cbc(), (unsigned char*)key, (uc*)iv); - - if (EVP_DecryptUpdate (& ctx, (uc*)&buff, &outlen, (uc*)input, inputSize) != 1) - return NULL; - if (EVP_DecryptFinal (& ctx, (uc*)&buff + outlen, &auxlen) != 1) - return NULL; - - outlen += auxlen; - g_free (input); - EVP_CIPHER_CTX_cleanup (&ctx); - return g_strndup (buff, outlen); -} diff --git a/extensions/formhistory/formhistory-crypt.h b/extensions/formhistory/formhistory-crypt.h deleted file mode 100644 index 0aada77c..00000000 --- a/extensions/formhistory/formhistory-crypt.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2009-2012 Alexander Butenko - Copyright (C) 2009-2012 Christian Dywan - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. -*/ - -#ifndef __FORMHISTORY_CRYPT_H__ -#define __FORMHISTORY_CRYPT_H__ - -typedef struct -{ - gchar* domain; - gchar* form_data; - FormHistoryPriv* priv; -} FormhistoryPasswordEntry; - -gchar* -formhistory_encrypt (const gchar* input, const gchar* key); - -gchar* -formhistory_decrypt (const gchar* b64input, const char* key); - -#endif diff --git a/extensions/formhistory/formhistory-frontend.h b/extensions/formhistory/formhistory-frontend.h index c483e848..378ae65e 100644 --- a/extensions/formhistory/formhistory-frontend.h +++ b/extensions/formhistory/formhistory-frontend.h @@ -41,9 +41,15 @@ typedef struct #endif gchar* master_password; int master_password_canceled; - int password_manager_enabled; } FormHistoryPriv; +typedef struct +{ + gchar* domain; + gchar* form_data; + FormHistoryPriv* priv; +} FormhistoryPasswordEntry; + FormHistoryPriv* formhistory_private_new (); diff --git a/extensions/formhistory/formhistory.c b/extensions/formhistory/formhistory.c index f7a49104..90d61858 100644 --- a/extensions/formhistory/formhistory.c +++ b/extensions/formhistory/formhistory.c @@ -11,7 +11,6 @@ #define MINCHARS 2 #define GTK_RESPONSE_IGNORE 99 #include "formhistory-frontend.h" -#include "formhistory-crypt.h" static void formhistory_toggle_state_cb (GtkAction* action, @@ -141,6 +140,14 @@ formhistory_check_master_password (GtkWidget* parent, return ret; } +static gchar* +formhistory_encrypt (const gchar* data, + const gchar* password) +{ + /* TODO: Implement persistent storage/ keyring support */ + return NULL; +} + static void formhistory_remember_password_response (GtkWidget* infobar, gint response_id, @@ -156,9 +163,9 @@ formhistory_remember_password_response (GtkWidget* infobar, if (response_id != GTK_RESPONSE_ACCEPT) katze_assign (entry->form_data, g_strdup ("never")); - encrypted_form = formhistory_encrypt (entry->form_data, entry->priv->master_password); + if ((encrypted_form = formhistory_encrypt (entry->form_data, + entry->priv->master_password))) formhistory_update_database (entry->priv->db, entry->domain, "MidoriPasswordManager", encrypted_form); - g_free (encrypted_form); } @@ -177,7 +184,6 @@ formhistory_navigation_decision_cb (WebKitWebView* web_view, WebKitWebPolicyDecision* decision, MidoriExtension* extension) { - FormhistoryPasswordEntry* entry; FormHistoryPriv* priv; JSContextRef js_context; gchar* value; @@ -227,9 +233,9 @@ formhistory_navigation_decision_cb (WebKitWebView* web_view, { gchar* data; gchar* domain; - - if (!priv->password_manager_enabled) - break; + #if 0 + FormhistoryPasswordEntry* entry; + #endif domain = midori_uri_parse_hostname (webkit_web_frame_get_uri (web_frame), NULL); data = formhistory_get_login_data (priv->db, domain); @@ -239,12 +245,14 @@ formhistory_navigation_decision_cb (WebKitWebView* web_view, g_free (domain); break; } + #if 0 entry = g_slice_new (FormhistoryPasswordEntry); /* Domain and form data are freed from infopanel callback*/ entry->form_data = g_strdup (value); entry->domain = domain; entry->priv = priv; g_object_set_data (G_OBJECT (web_view), "FormHistoryPasswordEntry", entry); + #endif } #endif } @@ -265,7 +273,6 @@ formhistory_window_object_cleared_cb (WebKitWebView* web_view, MidoriExtension* extension) { const gchar* page_uri; - FormHistoryPriv* priv; FormhistoryPasswordEntry* entry; GtkWidget* view; @@ -279,10 +286,6 @@ formhistory_window_object_cleared_cb (WebKitWebView* web_view, formhistory_setup_suggestions (web_view, js_context, extension); #if WEBKIT_CHECK_VERSION (1, 3, 8) - priv = g_object_get_data (G_OBJECT (extension), "priv"); - if (!priv->password_manager_enabled) - return; - entry = g_object_get_data (G_OBJECT (web_view), "FormHistoryPasswordEntry"); if (entry) { @@ -300,6 +303,14 @@ formhistory_window_object_cleared_cb (WebKitWebView* web_view, } #if WEBKIT_CHECK_VERSION (1, 3, 8) +static gchar* +formhistory_decrypt (const gchar* data, + const gchar* password) +{ + /* TODO: Implement persistent storage/ keyring support */ + return NULL; +} + static void formhistory_fill_login_data (JSContextRef js_context, FormHistoryPriv* priv, @@ -314,8 +325,10 @@ formhistory_fill_login_data (JSContextRef js_context, if (!strncmp (data, "never", 5)) return; + #if 0 if (!formhistory_check_master_password (NULL, priv)) return; + #endif if (!(decrypted_data = formhistory_decrypt (data, priv->master_password))) return; @@ -391,17 +404,13 @@ formhistory_add_tab_cb (MidoriBrowser* browser, MidoriExtension* extension) { GtkWidget* web_view = midori_view_get_web_view (view); - FormHistoryPriv* priv; - priv = g_object_get_data (G_OBJECT (extension), "priv"); g_signal_connect (web_view, "window-object-cleared", G_CALLBACK (formhistory_window_object_cleared_cb), extension); g_signal_connect (web_view, "navigation-policy-decision-requested", G_CALLBACK (formhistory_navigation_decision_cb), extension); #if WEBKIT_CHECK_VERSION (1, 3, 8) - if (!priv->password_manager_enabled) - return; g_signal_connect (web_view, "onload-event", G_CALLBACK (formhistory_frame_loaded_cb), extension); #endif @@ -452,17 +461,12 @@ formhistory_deactivate_tab (MidoriView* view, MidoriExtension* extension) { GtkWidget* web_view = midori_view_get_web_view (view); - FormHistoryPriv* priv; - priv = g_object_get_data (G_OBJECT (extension), "priv"); g_signal_handlers_disconnect_by_func ( web_view, formhistory_window_object_cleared_cb, extension); g_signal_handlers_disconnect_by_func ( web_view, formhistory_navigation_decision_cb, extension); #if WEBKIT_CHECK_VERSION (1, 3, 8) - if (!priv->password_manager_enabled) - return; - g_signal_handlers_disconnect_by_func ( web_view, formhistory_frame_loaded_cb, extension); #endif @@ -513,7 +517,6 @@ formhistory_activate_cb (MidoriExtension* extension, priv = formhistory_private_new (); priv->master_password = NULL; priv->master_password_canceled = 0; - priv->password_manager_enabled = 1; formhistory_construct_popup_gui (priv); config_dir = midori_extension_get_config_dir (extension);