version 1.35, 2015/09/11 14:30:23 |
version 1.36, 2015/09/13 12:41:01 |
|
|
#include <openssl/pem.h> |
#include <openssl/pem.h> |
#include <openssl/pkcs12.h> |
#include <openssl/pkcs12.h> |
#include <openssl/safestack.h> |
#include <openssl/safestack.h> |
#include <openssl/ui.h> |
|
#include <openssl/x509.h> |
#include <openssl/x509.h> |
#include <openssl/x509v3.h> |
#include <openssl/x509v3.h> |
|
|
|
|
unsigned long mask; |
unsigned long mask; |
} NAME_EX_TBL; |
} NAME_EX_TBL; |
|
|
static UI_METHOD *ui_method = NULL; |
UI_METHOD *ui_method = NULL; |
|
|
static int set_table_opts(unsigned long *flags, const char *arg, |
static int set_table_opts(unsigned long *flags, const char *arg, |
const NAME_EX_TBL *in_tbl); |
const NAME_EX_TBL *in_tbl); |
|
|
return 0; |
return 0; |
} |
} |
|
|
static int |
int |
ui_open(UI *ui) |
ui_open(UI *ui) |
{ |
{ |
return UI_method_get_opener(UI_OpenSSL()) (ui); |
return UI_method_get_opener(UI_OpenSSL()) (ui); |
} |
} |
|
|
static int |
int |
ui_read(UI *ui, UI_STRING *uis) |
ui_read(UI *ui, UI_STRING *uis) |
{ |
{ |
|
const char *password; |
|
int string_type; |
|
|
if (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD && |
if (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD && |
UI_get0_user_data(ui)) { |
UI_get0_user_data(ui)) { |
switch (UI_get_string_type(uis)) { |
string_type = UI_get_string_type(uis); |
case UIT_PROMPT: |
if (string_type == UIT_PROMPT || string_type == UIT_VERIFY) { |
case UIT_VERIFY: |
password = |
{ |
((PW_CB_DATA *)UI_get0_user_data(ui))->password; |
const char *password = |
if (password && password[0] != '\0') { |
((PW_CB_DATA *)UI_get0_user_data(ui))->password; |
UI_set_result(ui, uis, password); |
if (password && password[0] != '\0') { |
return 1; |
UI_set_result(ui, uis, password); |
|
return 1; |
|
} |
|
} |
} |
break; |
|
default: |
|
break; |
|
} |
} |
} |
} |
return UI_method_get_reader(UI_OpenSSL()) (ui, uis); |
return UI_method_get_reader(UI_OpenSSL()) (ui, uis); |
} |
} |
|
|
static int |
int |
ui_write(UI *ui, UI_STRING *uis) |
ui_write(UI *ui, UI_STRING *uis) |
{ |
{ |
|
const char *password; |
|
int string_type; |
|
|
if (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD && |
if (UI_get_input_flags(uis) & UI_INPUT_FLAG_DEFAULT_PWD && |
UI_get0_user_data(ui)) { |
UI_get0_user_data(ui)) { |
switch (UI_get_string_type(uis)) { |
string_type = UI_get_string_type(uis); |
case UIT_PROMPT: |
if (string_type == UIT_PROMPT || string_type == UIT_VERIFY) { |
case UIT_VERIFY: |
password = |
{ |
((PW_CB_DATA *)UI_get0_user_data(ui))->password; |
const char *password = |
if (password && password[0] != '\0') |
((PW_CB_DATA *)UI_get0_user_data(ui))->password; |
return 1; |
if (password && password[0] != '\0') |
|
return 1; |
|
} |
|
break; |
|
default: |
|
break; |
|
} |
} |
} |
} |
return UI_method_get_writer(UI_OpenSSL()) (ui, uis); |
return UI_method_get_writer(UI_OpenSSL()) (ui, uis); |
} |
} |
|
|
static int |
int |
ui_close(UI *ui) |
ui_close(UI *ui) |
{ |
{ |
return UI_method_get_closer(UI_OpenSSL()) (ui); |
return UI_method_get_closer(UI_OpenSSL()) (ui); |
} |
|
|
|
int |
|
setup_ui_method(void) |
|
{ |
|
ui_method = UI_create_method("OpenSSL application user interface"); |
|
UI_method_set_opener(ui_method, ui_open); |
|
UI_method_set_reader(ui_method, ui_read); |
|
UI_method_set_writer(ui_method, ui_write); |
|
UI_method_set_closer(ui_method, ui_close); |
|
return 0; |
|
} |
|
|
|
void |
|
destroy_ui_method(void) |
|
{ |
|
if (ui_method) { |
|
UI_destroy_method(ui_method); |
|
ui_method = NULL; |
|
} |
|
} |
} |
|
|
int |
int |