Discussion:
pkcs7_sign() / cms_sign() : using SHA256 hash
Francis GASCHET
2014-09-12 12:44:46 UTC
Permalink
Hello,

From the man page, it looks like signing packages always use SHA1, and
there is no argument to pkcs7_sign and cms_sign functions which would
allow to chose the algorithm.
May be I missed something... Or is there some method to sign with
another hsah algorithm ?

Thanks in advance.
Best regards,
--
Francis

______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
Salz, Rich
2014-09-12 14:12:53 UTC
Permalink
You are right, that the toplevel API doesn't have take a digest parameter. The only kind of signature you get is the "default" where default is defined per-key-type.

We should probably have PKCS7_sign_ex() that took a "const EVP_MD*" parameter. It'd be trivial to do this. Same for CMS_sign. Please open a ticket.

--
Principal Security Engineer, Akamai Technologies
IM: rsalz-dbVaDHFsUTizQB+***@public.gmane.org Twitter: RichSalz

______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
Dr. Stephen Henson
2014-09-19 23:36:14 UTC
Permalink
Post by Francis GASCHET
Hello,
From the man page, it looks like signing packages always use SHA1,
and there is no argument to pkcs7_sign and cms_sign functions which
would allow to chose the algorithm.
May be I missed something... Or is there some method to sign with
another hsah algorithm ?
CMS_sign() does use the default digest only. The cms application can use
a different digest though. You can do the same: it's slightly more
complex but not difficult. In outline you do this:

Call CMS_sign() set the private key argument to NULL and include the flag
CMS_PARTIAL (if you don't already). This just initialises the structure
without actually signing anything.

Add the signer(s) using CMS_add1_signer() you can specify the digest algorithm
to use with this call. You can add multiplers signer using different digest
algorithms here.

If you're streaming call SMIME_write_CMS() as normal. If not call CMS_final()
which will finalise the structure and you can then write it out. This
finalises the strcutures and performs the content digesting and signing.

There is an example of this for two signers (but which doesn't use a different
digest) in demos/cms/cms_sign2.c

Steve.
--
Dr Stephen N. Henson. OpenSSL project core developer.
Commercial tech support now available see: http://www.openssl.org
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
f.gaschet-KCajlHxIPtVQFI55V6+
2014-09-22 12:25:48 UTC
Permalink
Thank you Stephen. I'll try to do that and then I'll tell the others
OFTP2 editors how to do !

BTW: Rich told me : "open a ticket". I tried to do by writing to
rt-MCmKBN63+***@public.gmane.org but I got nothing back.

Best regards,
--
Francis
Post by Dr. Stephen Henson
Post by Francis GASCHET
Hello,
From the man page, it looks like signing packages always use SHA1,
and there is no argument to pkcs7_sign and cms_sign functions which
would allow to chose the algorithm.
May be I missed something... Or is there some method to sign with
another hsah algorithm ?
CMS_sign() does use the default digest only. The cms application can use
a different digest though. You can do the same: it's slightly more
Call CMS_sign() set the private key argument to NULL and include the flag
CMS_PARTIAL (if you don't already). This just initialises the structure
without actually signing anything.
Add the signer(s) using CMS_add1_signer() you can specify the digest algorithm
to use with this call. You can add multiplers signer using different digest
algorithms here.
If you're streaming call SMIME_write_CMS() as normal. If not call CMS_final()
which will finalise the structure and you can then write it out. This
finalises the strcutures and performs the content digesting and signing______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
Salz, Rich
2014-09-23 15:43:31 UTC
Permalink
RT is sometimes slow. If you sent email to rt, give it a couple of days and resend.


--
Principal Security Engineer, Akamai Technologies
IM: rsalz-dbVaDHFsUTizQB+***@public.gmane.org Twitter: RichSalz
______________________________________________________________________
OpenSSL Project http://www.openssl.org
User Support Mailing List openssl-users-MCmKBN63+***@public.gmane.org
Automated List Manager majordomo-MCmKBN63+***@public.gmane.org
Loading...