93 |
center_window (dlg, NULL); |
center_window (dlg, NULL); |
94 |
} |
} |
95 |
|
|
96 |
|
/* Generate the data expected by the gpg command handler. */ |
97 |
|
static char* |
98 |
|
generate_revoke_input (int code, const char *cmt, const char *pass) |
99 |
|
{ |
100 |
|
const char *fmt; |
101 |
|
char *p; |
102 |
|
size_t n; |
103 |
|
|
104 |
|
fmt = "Y\n" /* gen_revoke.okay */ |
105 |
|
"%d\n" /* ask_revocation_reason.code */ |
106 |
|
"%s\n" /* ask_revocation_reason.text */ |
107 |
|
"%s" /* text != NULL '\n' otherwise '' */ |
108 |
|
"Y\n" /* ask_revocation_reason.okay */ |
109 |
|
"%s\n"; /* passphrase.enter. */ |
110 |
|
n = strlen (fmt) + 32; |
111 |
|
if (pass) |
112 |
|
n += strlen (pass) + 1; |
113 |
|
if (cmt) |
114 |
|
n += strlen (cmt) + 1; |
115 |
|
p = new char[n+1]; |
116 |
|
if (!p) |
117 |
|
BUG (0); |
118 |
|
sprintf (p, fmt, code, cmt? cmt : "", cmt? "\n" : "", pass? pass : ""); |
119 |
|
return p; |
120 |
|
} |
121 |
|
|
122 |
|
|
123 |
/* Dialog box procedure for key revocation. */ |
/* Dialog box procedure for key revocation. */ |
124 |
BOOL CALLBACK |
BOOL CALLBACK |
142 |
case WM_INITDIALOG: |
case WM_INITDIALOG: |
143 |
if (!lparam) |
if (!lparam) |
144 |
dlg_fatal_error (dlg, "Could not get dialog param!"); |
dlg_fatal_error (dlg, "Could not get dialog param!"); |
145 |
k = (winpt_key_t )lparam; |
k = (winpt_key_t)lparam; |
146 |
on_init_dialog (dlg); |
on_init_dialog (dlg); |
147 |
return TRUE; |
return TRUE; |
148 |
|
|
184 |
} |
} |
185 |
|
|
186 |
inp_data = generate_revoke_input (idx, desc, pwd); |
inp_data = generate_revoke_input (idx, desc, pwd); |
187 |
err = gpg_revoke_cert (inp_data, k->keyid, &revcert); |
err = gpg_revoke_cert (k->internal, inp_data, k->keyid, &revcert); |
188 |
wipememory (pwd, sizeof (pwd)); |
wipememory (pwd, sizeof (pwd)); |
189 |
wipememory (inp_data, strlen (inp_data)); |
wipememory (inp_data, strlen (inp_data)); |
190 |
if (err) { |
if (err) { |
196 |
msg_box (dlg, warning, _("Key Revocation Cert"), MB_INFO); |
msg_box (dlg, warning, _("Key Revocation Cert"), MB_INFO); |
197 |
release_cert_as_file (revcert, file); |
release_cert_as_file (revcert, file); |
198 |
} |
} |
199 |
safe_free (inp_data); |
free_if_alloc (inp_data); |
200 |
free_if_alloc (desc); |
free_if_alloc (desc); |
201 |
EndDialog (dlg, TRUE); |
EndDialog (dlg, TRUE); |
202 |
return TRUE; |
return TRUE; |