Ticket #2994: aj-smime-algo-hack.diff

File aj-smime-algo-hack.diff, 1.8 kB (added by AndreasJ, 14 months ago)

Patch for #2994

  • crypt-gpgme.c

    old new  
    756756   which must have been allocated by the caller with size BUFLEN. 
    757757   Returns 0 on success or -1 in case of an error.  The return string 
    758758   is truncted to BUFLEN - 1. */ 
    759 static int get_micalg (gpgme_ctx_t ctx, char *buf, size_t buflen) 
     759static int get_micalg (gpgme_ctx_t ctx, int use_smime, char *buf, size_t buflen) 
    760760{ 
    761761  gpgme_sign_result_t result = NULL; 
    762762  const char *algorithm_name = NULL; 
     
    771771    algorithm_name = gpgme_hash_algo_name (result->signatures->hash_algo); 
    772772    if (algorithm_name) 
    773773    { 
    774       /* convert GPGME raw hash name to RFC 3156 format */ 
    775       snprintf (buf, buflen, "pgp-%s", algorithm_name); 
    776       ascii_strlower (buf + 4); 
     774      if (use_smime) 
     775      { 
     776        /* convert GPGME raw hash name to RFC 2633 format */ 
     777        snprintf (buf, buflen, "%s", algorithm_name); 
     778        ascii_strlower (buf); 
     779      } else { 
     780        /* convert GPGME raw hash name to RFC 3156 format */ 
     781        snprintf (buf, buflen, "pgp-%s", algorithm_name); 
     782        ascii_strlower (buf + 4); 
     783      } 
    777784    } 
    778785  } 
    779786 
     
    873880                      &t->parameter); 
    874881  /* Get the micalg from gpgme.  Old gpgme versions don't support this 
    875882     for S/MIME so we assume sha-1 in this case. */ 
    876   if (!get_micalg (ctx, buf, sizeof buf)) 
     883  if (!get_micalg (ctx, use_smime, buf, sizeof buf)) 
    877884    mutt_set_parameter ("micalg", buf, &t->parameter); 
    878885  else if (use_smime) 
    879     mutt_set_parameter ("micalg", "pgp-sha1", &t->parameter); 
     886    mutt_set_parameter ("micalg", "sha1", &t->parameter); 
    880887  gpgme_release (ctx); 
    881888 
    882889  t->parts = a;