struct smime_command_context {
const char *key; /* %k */
const char *cryptalg; /* %a */
+ const char *digestalg; /* %d */
const char *fname; /* %f */
const char *sig_fname; /* %s */
const char *certificates; /* %c */
break;
}
+ case 'd':
+ { /* algorithm for the signature message digest */
+ if (!optional) {
+ snprintf (fmt, sizeof (fmt), "%%%ss", prefix);
+ snprintf (dest, destlen, fmt, NONULL (cctx->digestalg));
+ }
+ else if (!cctx->key)
+ optional = 0;
+ break;
+ }
+
default:
*dest = '\0';
break;
const char *fname,
const char *sig_fname,
const char *cryptalg,
+ const char *digestalg,
const char *key,
const char *certificates,
const char *intermediates,
cctx.sig_fname = sig_fname;
cctx.key = key;
cctx.cryptalg = cryptalg;
+ cctx.digestalg = digestalg;
cctx.certificates = certificates;
cctx.intermediates = intermediates;
if ((thepid = smime_invoke (NULL, NULL, NULL,
-1, fileno (fpout), fileno (fperr),
- certificate, NULL, NULL, NULL, NULL, NULL,
+ certificate, NULL, NULL, NULL, NULL, NULL, NULL,
SmimeGetCertEmailCommand))== -1)
{
mutt_message (_("Error: unable to create OpenSSL subprocess!"));
*/
if ((thepid = smime_invoke (NULL, NULL, NULL,
-1, fileno (fpout), fileno (fperr),
- infile, NULL, NULL, NULL, NULL, NULL,
+ infile, NULL, NULL, NULL, NULL, NULL, NULL,
SmimePk7outCommand))== -1)
{
mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!"));
*/
if ((thepid = smime_invoke (NULL, NULL, NULL,
-1, fileno (fpout), fileno (fperr),
- pk7out, NULL, NULL, NULL, NULL, NULL,
+ pk7out, NULL, NULL, NULL, NULL, NULL, NULL,
SmimeGetCertCommand))== -1)
{
mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!"));
*/
if ((thepid = smime_invoke (NULL, NULL, NULL,
-1, -1, fileno (fperr),
- infile, NULL, NULL, NULL, certfile, NULL,
+ infile, NULL, NULL, NULL, NULL, certfile, NULL,
SmimeGetSignerCertCommand))== -1)
{
mutt_any_key_to_continue (_("Error: unable to create OpenSSL subprocess!"));
if ((thepid = smime_invoke (&smimein, NULL, NULL,
-1, fileno(fpout), fileno(fperr),
- certfile, NULL, NULL, NULL, NULL, NULL,
+ certfile, NULL, NULL, NULL, NULL, NULL, NULL,
SmimeImportCertCommand))== -1)
{
mutt_message (_("Error: unable to create OpenSSL subprocess!"));
{
return smime_invoke (smimein, smimeout, smimeerr,
smimeinfd, smimeoutfd, smimeerrfd,
- fname, NULL, SmimeCryptAlg, NULL, uids, NULL,
+ fname, NULL, SmimeCryptAlg, NULL, NULL, uids, NULL,
SmimeEncryptCommand);
}
const char *fname)
{
return smime_invoke (smimein, smimeout, smimeerr, smimeinfd, smimeoutfd,
- smimeerrfd, fname, NULL, NULL, SmimeKeyToUse,
+ smimeerrfd, fname, NULL, NULL, SmimeDigestAlg, SmimeKeyToUse,
SmimeCertToUse, SmimeIntermediateToUse,
SmimeSignCommand);
}
}
+/* The openssl -md doesn't want hyphens:
+ * md5, sha1, sha224, sha256, sha384, sha512
+ * However, the micalg does:
+ * md5, sha-1, sha-224, sha-256, sha-384, sha-512
+ */
+static char *openssl_md_to_smime_micalg(char *md)
+{
+ char *micalg;
+ size_t l;
+
+ if (!md)
+ return 0;
+
+ if (mutt_strncasecmp ("sha", md, 3) == 0)
+ {
+ l = strlen (md) + 2;
+ micalg = (char *)safe_malloc (l);
+ snprintf (micalg, l, "sha-%s", md +3);
+ }
+ else
+ {
+ micalg = safe_strdup (md);
+ }
+
+ return micalg;
+}
+
BODY *smime_sign_message (BODY *a )
pid_t thepid;
smime_key_t *default_key;
char *intermediates;
+ char *micalg;
if (!SmimeDefaultKey)
{
t->disposition = DISPINLINE;
mutt_generate_boundary (&t->parameter);
- /* check if this can be extracted from private key somehow.... */
- mutt_set_parameter ("micalg", "sha1", &t->parameter);
+
+ micalg = openssl_md_to_smime_micalg (SmimeDigestAlg);
+ mutt_set_parameter ("micalg", micalg, &t->parameter);
+ FREE (&micalg);
+
mutt_set_parameter ("protocol", "application/x-pkcs7-signature",
&t->parameter);
const char *fname, const char *sig_fname, int opaque)
{
return smime_invoke (smimein, smimeout, smimeerr, smimeinfd, smimeoutfd,
- smimeerrfd, fname, sig_fname, NULL, NULL, NULL, NULL,
+ smimeerrfd, fname, sig_fname, NULL, NULL, NULL, NULL, NULL,
(opaque ? SmimeVerifyOpaqueCommand : SmimeVerifyCommand));
}
const char *fname)
{
return smime_invoke (smimein, smimeout, smimeerr, smimeinfd, smimeoutfd,
- smimeerrfd, fname, NULL, NULL, SmimeKeyToUse,
+ smimeerrfd, fname, NULL, NULL, NULL, SmimeKeyToUse,
SmimeCertToUse, NULL, SmimeDecryptCommand);
}