|
|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
#include "libublsettingsui-gtk3.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define sha256_encrypt_command(target) yon_char_unite("echo -n \"",target,"\" | sha256sum | cut -f 1 -d ' '",NULL)
|
|
|
|
|
#define sha512_encrypt_command(target) yon_char_unite("echo -n \"",target,"\" | sha512sum | cut -f 1 -d ' '",NULL)
|
|
|
|
|
|
|
|
|
|
@ -112,10 +111,15 @@ void yon_hash_entry_sensitiveness_update(GtkWidget *, yon_password_window *dialo
|
|
|
|
|
|
|
|
|
|
void yon_password_hash_list_set(yon_password_window *window, config_str hashes, config_str get_hash_commands, int size){
|
|
|
|
|
gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(window->EncryptionCombo));
|
|
|
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->EncryptionCombo),_ENCRYPTION_DEFAULT_LABEL,"");
|
|
|
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->EncryptionCombo),"",_ENCRYPTION_DEFAULT_LABEL);
|
|
|
|
|
if (!size){
|
|
|
|
|
gtk_widget_hide(gtk_widget_get_parent(window->EncryptionCombo));
|
|
|
|
|
gtk_widget_hide(window->NoEncriptionCheck);
|
|
|
|
|
gtk_widget_hide(window->HashBox);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (int i=0;i<size;i++){
|
|
|
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->EncryptionCombo),hashes[i],get_hash_commands[i]);
|
|
|
|
|
gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(window->EncryptionCombo),get_hash_commands[i],hashes[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -149,6 +153,10 @@ void on_password_hash_sensitiveness(GtkWidget *,yon_password_window *window){
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void yon_password_function_set(yon_password_window *window, double *password_func){
|
|
|
|
|
window->strength_func = password_func;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_password_accept(GtkWidget *,dictionary *dict){
|
|
|
|
|
yon_password_window *window = yon_dictionary_get_data(dict->first,yon_password_window*);
|
|
|
|
|
GtkWidget *target = yon_dictionary_get_data(dict->first->next,GtkWidget*);
|
|
|
|
|
@ -157,6 +165,14 @@ void on_password_accept(GtkWidget *,dictionary *dict){
|
|
|
|
|
char *final = NULL;
|
|
|
|
|
if (encription_active == 0||gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(window->NoEncriptionCheck))){
|
|
|
|
|
final = yon_password_unencrypted_password_get(window);
|
|
|
|
|
|
|
|
|
|
if (window->strength_func){
|
|
|
|
|
double password_strength = ((double(*)(yon_password_window *,const char*))window->strength_func)(window,final);
|
|
|
|
|
if (password_strength<0.3){
|
|
|
|
|
yon_ubl_status_box_spawn(GTK_CONTAINER(window->StatusBox),WEAK_PASSWORD_LABEL,5,BACKGROUND_IMAGE_FAIL_TYPE);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!final) return;
|
|
|
|
|
} else {
|
|
|
|
|
final = yon_password_hash_get(window);
|
|
|
|
|
@ -166,6 +182,11 @@ void on_password_accept(GtkWidget *,dictionary *dict){
|
|
|
|
|
gtk_widget_destroy(window->Window);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void on_password_changed(GtkWidget *, yon_password_window *window){
|
|
|
|
|
const char *password_str = gtk_entry_get_text(GTK_ENTRY(window->PasswordEntry));
|
|
|
|
|
double strength = ((double(*)(yon_password_window *,const char*))window->strength_func)(window,password_str);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
yon_password_window *yon_password_window_new(){
|
|
|
|
|
GtkBuilder *builder = gtk_builder_new_from_resource(ui_glade_path_password);
|
|
|
|
|
yon_password_window *window = malloc(sizeof(yon_password_window));
|
|
|
|
|
@ -177,6 +198,7 @@ yon_password_window *yon_password_window_new(){
|
|
|
|
|
window->EncryptionCombo = yon_gtk_builder_get_widget(builder,"EncryptionCombo");
|
|
|
|
|
window->NoEncriptionCheck = yon_gtk_builder_get_widget(builder,"NoEncriptionCheck");
|
|
|
|
|
window->PasswordHashEntry = yon_gtk_builder_get_widget(builder,"PasswordHashEntry");
|
|
|
|
|
window->PasswordStrengthProgress= yon_gtk_builder_get_widget(builder,"PasswordStrengthProgress");
|
|
|
|
|
window->UserCancelButton = yon_gtk_builder_get_widget(builder,"UserCancelButton");
|
|
|
|
|
window->AcceptButton = yon_gtk_builder_get_widget(builder,"UserOkButton");
|
|
|
|
|
window->PasswordBox = yon_gtk_builder_get_widget(builder,"PasswordBox");
|
|
|
|
|
@ -188,6 +210,7 @@ yon_password_window *yon_password_window_new(){
|
|
|
|
|
g_signal_connect(G_OBJECT(window->NoEncriptionCheck),"toggled",G_CALLBACK(on_password_hash_sensitiveness),window);
|
|
|
|
|
g_signal_connect(G_OBJECT(window->PasswordHashEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window);
|
|
|
|
|
g_signal_connect(G_OBJECT(window->PasswordEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window);
|
|
|
|
|
g_signal_connect(G_OBJECT(window->PasswordEntry),"changed",G_CALLBACK(on_password_changed),window);
|
|
|
|
|
g_signal_connect(G_OBJECT(window->RepeatPasswordEntry),"changed",G_CALLBACK(on_password_hash_sensitiveness),window);
|
|
|
|
|
gtk_widget_show(window->Window);
|
|
|
|
|
return window;
|
|
|
|
|
|