| 162 | | } |
| 163 | | |
| 164 | | |
| 165 | | |
| 166 | | static int pgp_send_menu (HEADER *msg, int *redraw) |
| 167 | | { |
| 168 | | pgp_key_t p; |
| 169 | | char input_signas[SHORT_STRING]; |
| 170 | | |
| 171 | | if (!(WithCrypto & APPLICATION_PGP)) |
| 172 | | return msg->security; |
| 173 | | |
| 174 | | switch (mutt_multi_choice (_("PGP (e)ncrypt, (s)ign, sign (a)s, (b)oth, (i)nline, or (f)orget it? "), |
| 175 | | _("esabif"))) |
| 176 | | { |
| 177 | | case 1: /* (e)ncrypt */ |
| 178 | | msg->security ^= ENCRYPT; |
| 179 | | break; |
| 180 | | |
| 181 | | case 2: /* (s)ign */ |
| 182 | | msg->security ^= SIGN; |
| 183 | | break; |
| 184 | | |
| 185 | | case 3: /* sign (a)s */ |
| 186 | | unset_option(OPTPGPCHECKTRUST); |
| 187 | | |
| 188 | | if ((p = crypt_pgp_ask_for_key (_("Sign as: "), NULL, |
| 189 | | KEYFLAG_CANSIGN, PGP_PUBRING))) |
| 190 | | { |
| 191 | | snprintf (input_signas, sizeof (input_signas), "0x%s", |
| 192 | | crypt_pgp_keyid (p)); |
| 193 | | mutt_str_replace (&PgpSignAs, input_signas); |
| 194 | | crypt_pgp_free_key (&p); |
| 195 | | |
| 196 | | msg->security |= SIGN; |
| 197 | | |
| 198 | | crypt_pgp_void_passphrase (); /* probably need a different passphrase */ |
| 199 | | } |
| 200 | | else |
| 201 | | { |
| 202 | | msg->security &= ~SIGN; |
| 203 | | } |
| 204 | | |
| 205 | | *redraw = REDRAW_FULL; |
| 206 | | break; |
| 207 | | |
| 208 | | case 4: /* (b)oth */ |
| 209 | | if ((msg->security & (ENCRYPT | SIGN)) == (ENCRYPT | SIGN)) |
| 210 | | msg->security = 0; |
| 211 | | else |
| 212 | | msg->security |= (ENCRYPT | SIGN); |
| 213 | | break; |
| 214 | | |
| 215 | | case 5: /* (i)nline */ |
| 216 | | if ((msg->security & (ENCRYPT | SIGN))) |
| 217 | | msg->security ^= INLINE; |
| 218 | | else |
| 219 | | msg->security &= ~INLINE; |
| 220 | | break; |
| 221 | | |
| 222 | | case 6: /* (f)orget it */ |
| 223 | | msg->security = 0; |
| 224 | | break; |
| 225 | | } |
| 226 | | |
| 227 | | if (msg->security) |
| 228 | | { |
| 229 | | if (! (msg->security & (ENCRYPT | SIGN))) |
| 230 | | msg->security = 0; |
| 231 | | else |
| 232 | | msg->security |= APPLICATION_PGP; |
| 233 | | } |
| 234 | | |
| 235 | | if(*redraw) |
| 236 | | redraw_crypt_lines (msg); |
| 237 | | return (msg->security); |
| 238 | | } |
| 239 | | |
| 240 | | |
| 241 | | |
| 242 | | static int smime_send_menu (HEADER *msg, int *redraw) |
| 243 | | { |
| 244 | | char *p; |
| 245 | | |
| 246 | | if (!(WithCrypto & APPLICATION_SMIME)) |
| 247 | | return msg->security; |
| 248 | | |
| 249 | | switch (mutt_multi_choice (_("S/MIME (e)ncrypt, (s)ign, encrypt (w)ith, sign (a)s, (b)oth, or (f)orget it? "), |
| 250 | | _("eswabf"))) |
| 251 | | { |
| 252 | | case 1: /* (e)ncrypt */ |
| 253 | | msg->security |= ENCRYPT; |
| 254 | | break; |
| 255 | | |
| 256 | | case 3: /* encrypt (w)ith */ |
| 257 | | msg->security |= ENCRYPT; |
| 258 | | switch (mutt_multi_choice (_("1: DES, 2: Triple-DES, 3: RC2-40," |
| 259 | | " 4: RC2-64, 5: RC2-128, or (f)orget it? "), |
| 260 | | _("12345f"))) { |
| 261 | | case 1: |
| 262 | | mutt_str_replace (&SmimeCryptAlg, "des"); |
| 263 | | break; |
| 264 | | case 2: |
| 265 | | mutt_str_replace (&SmimeCryptAlg, "des3"); |
| 266 | | break; |
| 267 | | case 3: |
| 268 | | mutt_str_replace (&SmimeCryptAlg, "rc2-40"); |
| 269 | | break; |
| 270 | | case 4: |
| 271 | | mutt_str_replace (&SmimeCryptAlg, "rc2-64"); |
| 272 | | break; |
| 273 | | case 5: |
| 274 | | mutt_str_replace (&SmimeCryptAlg, "rc2-128"); |
| 275 | | break; |
| 276 | | case 6: /* forget it */ |
| 277 | | break; |
| 278 | | } |
| 279 | | break; |
| 280 | | |
| 281 | | case 2: /* (s)ign */ |
| 282 | | |
| 283 | | if(!SmimeDefaultKey) |
| 284 | | mutt_message("Can\'t sign: No key specified. use sign(as)."); |
| 285 | | else |
| 286 | | msg->security |= SIGN; |
| 287 | | break; |
| 288 | | |
| 289 | | case 4: /* sign (a)s */ |
| 290 | | |
| 291 | | if ((p = crypt_smime_ask_for_key (_("Sign as: "), NULL, 0))) { |
| 292 | | p[mutt_strlen (p)-1] = '\0'; |
| 293 | | mutt_str_replace (&SmimeDefaultKey, p); |
| 294 | | |
| 295 | | msg->security |= SIGN; |
| 296 | | |
| 297 | | /* probably need a different passphrase */ |
| 298 | | crypt_smime_void_passphrase (); |
| 299 | | } |
| 300 | | else |
| 301 | | msg->security &= ~SIGN; |
| 302 | | |
| 303 | | *redraw = REDRAW_FULL; |
| 304 | | break; |
| 305 | | |
| 306 | | case 5: /* (b)oth */ |
| 307 | | msg->security = ENCRYPT | SIGN; |
| 308 | | break; |
| 309 | | |
| 310 | | case 6: /* (f)orget it */ |
| 311 | | msg->security = 0; |
| 312 | | break; |
| 313 | | } |
| 314 | | |
| 315 | | if (msg->security && msg->security != APPLICATION_SMIME) |
| 316 | | msg->security |= APPLICATION_SMIME; |
| 317 | | else |
| 318 | | msg->security = 0; |
| 319 | | |
| 320 | | if(*redraw) |
| 321 | | redraw_crypt_lines (msg); |
| 322 | | return (msg->security); |